@rr0/ufoathome 0.58.0 → 0.58.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -511,15 +511,15 @@ input[type=range] {
511
511
  pointer-events: none;
512
512
  white-space: nowrap;
513
513
  }
514
- `,Ba=[{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 Ve{static get default(){return Ba[0]}static byId(t){return Ba.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:Ve.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:Ve.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*Ve.aspectOf(t))}static availableAt(t){return t===void 0?Ba:Ba.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const n=t.frame;if(!(!n||e<=0))return 2*Math.atan(n.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const n=t.frame;if(!(!n||e<=0||e>=180))return n.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const n=e??t.fNumber;if(n===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??Ve.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class _a{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const n of t.witnessTrack.allKeyframes){const{lat:i,lng:r,headingDeg:a}=n.pose;i===void 0||r===void 0||e.push({t:n.t,lat:i,lng:r,headingDeg:a})}if(e.length===0){const n=t.event.place?.[0];if(!n)return;e.push({t:0,lat:n.lat,lng:n.lng})}return new _a(e)}get moved(){return this.spanM>_a.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,n=(t.west+t.east)/2;return Math.max(Math.abs(tn(e,t.east,e,t.west).x),Math.abs(tn(t.north,n,t.south,n).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:n,lng:i}=this.center,r=Math.max(this.spanM*(1+e),t)/2;return{north:Ni(0,-r,n,i).lat,south:Ni(0,r,n,i).lat,east:Ni(r,0,n,i).lng,west:Ni(-r,0,n,i).lng}}get box(){const t=this.points.map(n=>n.lat),e=this.points.map(n=>n.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class Ge{constructor(t,e){this.stretches=t,this.rotationPassed=e}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(t){const e=_a.of(t);if(!e||e.points.length<2)return;const n=[];let i=0;for(let r=1;r<e.points.length;r++){const a=e.points[r-1],o=e.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=tn(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=Ge.stepHzFor(f);n.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=p*c}for(let r=0;r<n.length;r++){const a=n[r-1],o=n[r+1];n[r].rampsIn=a===void 0||a.stepHz===0,n[r].rampsOut=o===void 0||o.stepHz===0}if(n.some(r=>r.stepHz>0))return new Ge(n,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<Ge.SLOWEST_WALK_M_PER_S||t>Ge.FASTEST_WALK_M_PER_S?0:Ge.REFERENCE_STEP_HZ*Math.pow(t/Ge.REFERENCE_SPEED_M_PER_S,Ge.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return Ge.STILL;const n=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,i=2*Math.PI*n,r=this.amplitudeAt(e,t),a=Ge.SWAY_M*r*Math.cos(i/2),o=r*this.rotationPassed*e.speedMPerS/Ge.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:Ge.RISE_M_PER_M_PER_S*e.speedMPerS*r*Math.cos(i),rollDeg:Ge.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Ge.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(t,e){const n=1e3/t.stepHz,i=Math.min(n,(t.endMs-t.startMs)/2);if(i<=0)return 1;const r=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?r/i:1,t.rampsOut?a/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class me{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/me.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function lg(s,t,e){if(!s||!t)return e<1?s:t;const n=((t.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*e)%360+360)%360,altitudeDeg:s.altitudeDeg+(t.altitudeDeg-s.altitudeDeg)*e}}function hg(s,t,e){const{bounds:n}=s;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function Sn(s,t,e){return s+(t-s)*e}function hd(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function ug(s){return`#${s.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function dg(s,t,e){const n=hd(s),i=hd(t);return!n||!i?e<1?s:t:ug([Sn(n[0],i[0],e),Sn(n[1],i[1],e),Sn(n[2],i[2],e)])}function fg(s,t,e){const n={x:Sn(s.bounds.x,t.bounds.x,e),y:Sn(s.bounds.y,t.bounds.y,e),width:Sn(s.bounds.width,t.bounds.width,e),height:Sn(s.bounds.height,t.bounds.height,e)},i=Sn(s.angle,t.angle,e),r=Sn(s.transparency,t.transparency,e),a=Sn(s.haloScale,t.haloScale,e),o=Sn(s.blur??0,t.blur??0,e),c=Sn(s.brightness??0,t.brightness??0,e),l=dg(s.color,t.color,e),h=me.lerpAngular(s.angular,t.angular,e),u=lg(s.aim,t.aim,e);return s.kind==="polygon"&&t.kind==="polygon"&&s.points.length===t.points.length?{...s,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:s.points.map((d,f)=>({x:Sn(d.x,t.points[f].x,e),y:Sn(d.y,t.points[f].y,e)}))}:{...e<1?s:t,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class Sc{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const i=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!i.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const i=this.findShapeAtOrAfter(t,e);return n?i?fg(n.shape,i.shape,(t-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(t,e,n,i){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(i?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&hg(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const n=this.groups[e].filter(i=>i!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new Sc;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(i=>e.order.includes(i))).filter(n=>n.length>=2)),e}}function pg(s,t,e){return Math.max(t,Math.min(e,s))}function mg(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function Xs(s,t,e){return s+(t-s)*e}function gg(s,t,e){return{lat:s.lat===void 0||t.lat===void 0?void 0:Xs(s.lat,t.lat,e),lng:s.lng===void 0||t.lng===void 0?void 0:Xs(s.lng,t.lng,e),elevationM:Xs(s.elevationM,t.elevationM,e),headingDeg:s.headingDeg===void 0||t.headingDeg===void 0?void 0:mg(s.headingDeg,t.headingDeg,e),pitchDeg:Xs(s.pitchDeg,t.pitchDeg,e),rollDeg:Xs(s.rollDeg??0,t.rollDeg??0,e),fovDeg:Xs(s.fovDeg,t.fovDeg,e),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class ya{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?gg(n.pose,i.pose,pg((t-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ya;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function _e(s,t,e){return s+(t-s)*e}function bu(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function vg(s,t,e){return Math.max(t,Math.min(e,s))}function Mg(s=[],t=[],e){if(!(!s.length&&!t.length))return[...new Set([...s.map(n=>n.id),...t.map(n=>n.id)])].map(n=>{const i=s.find(c=>c.id===n),r=t.find(c=>c.id===n),a=i??{...r,density:0},o=r??{...i,density:0};return{...a,eastM:_e(a.eastM,o.eastM,e),northM:_e(a.northM,o.northM,e),baseM:_e(a.baseM,o.baseM,e),thicknessM:_e(a.thicknessM,o.thicknessM,e),widthM:_e(a.widthM,o.widthM,e),depthM:_e(a.depthM,o.depthM,e),rotationDeg:bu(a.rotationDeg,o.rotationDeg,e),density:_e(a.density,o.density,e),darkness:_e(a.darkness??0,o.darkness??0,e)}})}function xg(s,t,e){if(s.cloudLayers===void 0&&t.cloudLayers===void 0)return;const n=jo(s),i=jo(t);return e>=1?i.map(a=>({...a})):[...new Set([...n.map(a=>a.id),...i.map(a=>a.id)])].map(a=>{const o=n.find(u=>u.id===a),c=i.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:Mg(o?.instances,c?.instances,e),baseM:_e(l.baseM,h.baseM,e),thicknessM:_e(l.thicknessM,h.thicknessM,e),coverage:_e(l.coverage,h.coverage,e),sizeM:_e(l.sizeM,h.sizeM,e),density:_e(l.density,h.density,e),darkness:_e(l.darkness??s.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:_e(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:_e(l.windSpeed??s.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:bu(l.windDirectionDeg??s.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function _g(s,t,e){return{cloudLayers:xg(s,t,e),cloudCover:_e(s.cloudCover,t.cloudCover,e),cloudDarkness:_e(s.cloudDarkness,t.cloudDarkness,e),highCloudCover:s.highCloudCover===void 0||t.highCloudCover===void 0?void 0:_e(s.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:s.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:_e(s.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:s.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:_e(s.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:s.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:_e(s.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?s.precipitationType:t.precipitationType,precipitationIntensity:_e(s.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:bu(s.windDirectionDeg,t.windDirectionDeg,e),windSpeed:_e(s.windSpeed,t.windSpeed,e),storm:e<1?s.storm:t.storm}}class Sa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?_g(n.weather,i.weather,vg((t-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Sa;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class ba{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return i?.sound;if(!i)return n.sound;const r=(t-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ba;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}}const yg=100,Sg={kind:"none",volume:0,pitchHz:yg};class kn{constructor(t){this.entries=t}static empty(){return new kn(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new kn(new Map);return{recording:kn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const n=structuredClone(t);for(const i of e.paths()){const r=e.at(i),a=i.split("."),o=kn.holderOf(n,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 n}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,n){return kn.isWrapper(t)?(n.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),kn.stripValue(t.value,e,n)):Array.isArray(t)?t.map((i,r)=>kn.stripValue(i,[...e,String(r)],n)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,kn.stripValue(r,[...e,i],n)])):t}static holderOf(t,e){let n=t;for(const i of e.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}function Jl(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 ud(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const bg=["year","month","day","hour","minute"],Eg=["day","hour","minute"];function dd(s,t){return t.filter(e=>s[e]!==void 0).join(",")}function wg(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const t=s.time.year!==void 0&&s.endTime.year!==void 0,e=t?bg:Eg,n=dd(s.time,e);if(!(n===""||n!==dd(s.endTime,e)))return t?Jl(s.endTime)-Jl(s.time):ud(s.endTime)-ud(s.time)}class bc{constructor(t,e,n,i,r,a,o,c,l=[],h,u,d,f=[]){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=i,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}provenance=kn.empty();testimony;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Ve.byId(this.instrumentId)}static create(t,e,n){return new bc({eventType:"sighting",time:t,place:e},new Sc,new ya,new Sa,new ba,n)}}const Ag=0,Tg=0;function Qe(s,t){const e=s.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Ag,headingDeg:void 0,pitchDeg:Tg,fovDeg:Ve.fieldOfViewDeg(s.instrument)}}function Ha(s,t){return s.weatherTrack.getInterpolatedWeatherAt(t)??s.weather??pp}function Rg(s,t){return s.soundTrack.getInterpolatedSoundAt(t)??Sg}class Dg{constructor(t,e){this.timeline=t,this.onFrame=e}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 t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}this.onFrame(t,e)}}const vp=["nw","n","ne","e","se","s","sw","w"],Cg=24,Ga=8,Pg=3,Ig=8;function Va(s,t,e){const n=s.x-t.x,i=s.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-i*a,y:t.y+n*a+i*r}}function Br(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const Lg={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 Cn{static handlePointsFor(t){const{x:e,y:n,width:i,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+i/2,y:n},ne:{x:e+i,y:n},e:{x:e+i,y:n+r/2},se:{x:e+i,y:n+r},s:{x:e+i/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+i/2,y:n-Cg}},o=Br(t.bounds),c={};for(const l of Object.keys(a))c[l]=Va(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,i=[...vp,"rotate"]){const r=Cn.handlePointsFor(t);for(const a of i)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((Cn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(i)%r.length]}static resizeBounds(t,e,n,i){const r=Br(t),a=Va(i,r,-e),{x:o,y:c,width:l,height:h}=t,u=Lg[n];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-Ga)),u.right&&(p=Math.max(a.x,d+Ga)),u.top&&(f=Math.min(a.y,v-Ga)),u.bottom&&(v=Math.max(a.y,f+Ga)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:r}=t.bounds,a=Cn.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=i===0?1:a.width/i,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Br(t.bounds),i=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),i=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:i-e,height:r-n}}static vertexPointsFor(t){const e=Br(t.bounds);return t.points.map(n=>Va({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=Ig){const i=Cn.vertexPointsFor(t);let r,a=n;return i.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Br(t.bounds),i=Va(e,n,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,n){const i=t.points.map((u,d)=>d===e?Cn.toLocalPoint(t,n):u),r=Math.min(...i.map(u=>u.x)),a=Math.min(...i.map(u=>u.y)),o=Math.max(...i.map(u=>u.x)),c=Math.max(...i.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=i.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=Cn.toLocalPoint(t,e),{points:i}=t;let r=i.length-1,a=1/0;for(let c=0;c<i.length;c++){const l=i[c],h=i[(c+1)%i.length],u=Cn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...i.slice(0,r+1),n,...i.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const i=n.x-e.x,r=n.y-e.y,a=i*i+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*r)/a)),c=e.x+o*i,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Pg?t:{...t,points:t.points.filter((n,i)=>i!==e)}}}const jl=6,Wa=jl/2,fd=20,pd=24,md=9,gd=6,vd=7,Md=6,xd=4;class Ql{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:n,width:i,height:r}=t.bounds,a=e+i/2,o=n+r/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(i,r)/2,h=c?l:i/2,u=c?l:r/2,d=Math.max(i,r)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+md*f),Md*f)-d:0,v=f>0?d*(1+vd*f)-d:0,g=3*pd*(t.blur??0)+1.5*fd*t.haloScale,m=Math.max(p,v,0)+g+2;return{x:a-h-m,y:o-u-m,width:2*(h+m),height:2*(u+m)}}paintInto(t,e,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-e.x,-e.y),this.paintShape(t.selected?{...t,selected:!1}:t),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(pd*e).toFixed(2)}px)`);const n=t.brightness??0;n>0&&this.paintDazzle(t,n),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:n,y:i,width:r,height:a}=t.bounds,o=n+r/2,c=i+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+md*e),Md*e);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<=gd;d++){const f=d/gd,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.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+vd*e);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,g=c+Math.sin(p)*d,m=this.ctx.createLinearGradient(o,c,v,g);m.addColorStop(0,this.withAlpha(t.color,e*.55)),m.addColorStop(.35,this.withAlpha(t.color,e*.22)),m.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,g),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const n=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!n)return t.color;const i=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*e);return`rgb(${r(i>>16&255)}, ${r(i>>8&255)}, ${r(i&255)})`}withAlpha(t,e){const n=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const r=Number.parseInt(i[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:i,height:r}=t.bounds,a=i/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:i,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=fd*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(Cn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of Cn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,xd,xd,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(Cn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintGroupHandles(t){this.paintHandleFrame(Cn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of vp){const i=t[n];this.ctx.fillRect(i.x-Wa,i.y-Wa,jl,jl)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Wa+1,Wa+1,0,0,2*Math.PI),this.ctx.fill())}}const _d=.05,yd=.08,Sd=2,bd=3,Ng=14,Og=.02;class Ug{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const i=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,_d);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),i,_d)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),i.connect(r),r.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,i.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(i).connect(r).connect(t.destination),n.start(),{key:e,nodes:[i,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(i).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[i,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const i=this.context;if(!i)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=i.createBufferSource();a.buffer=r,a.loop=!0;const o=i.createGain();o.gain.value=0,a.connect(o).connect(i.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*Sd),t.sampleRate),n=e.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*Sd),t.sampleRate),n=e.getChannelData(0);let i=0,r=0;for(let a=0;a<n.length;a++)i=(i+.02*(Math.random()*2-1))/1.02,n[a]=i,r=Math.max(r,Math.abs(i));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*bd),t.sampleRate),n=e.getChannelData(0),i=Math.max(1,Math.floor(Og*t.sampleRate)),r=Math.round(bd*Ng);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<i&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,yd/3);const i=n+yd;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(i)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}function tc(s){return[...s].sort((t,e)=>t.t-e.t)}function Ed(s,t){let e;for(const n of tc(s)){if(n.t>t)break;e=n}return e}const Uc=Math.PI/180,Xa=180/Math.PI;class Oi{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const i=n*Uc/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,n){return new Oi(t.projection,e,n)}degToPx(t){const e=t*Uc;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Xa:2*Math.atan(t/(2*this.focalPx))*Xa}angleDegToRadiusPx(t){const e=t*Uc;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*Xa:Math.atan(t/this.focalPx)*Xa}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(me.angularWidthDeg(t))}}class Bn{static fovOf(t,e){return Qe(t,e)?.fovDeg??Ve.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:i,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:i,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:i/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,n,i)=>{const r=this.aimFrom(t,n,i,e.bounds);return r?{...e,aim:r}:e})}static aimOf(t,e,n){const i=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,i,Qe(t,e),n)}static aimFrom(t,e,n,i){if(n?.headingDeg===void 0)return;const r=this.frameCentre(t),a=e.radiusPxToAngleDeg(i.x+i.width/2-r.x),o=e.radiusPxToAngleDeg(r.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+a)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,n,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,c=r.x+this.offAxisPx(n,a)-e.bounds.width/2,l=r.y-this.offAxisPx(n,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:c,y:l}}})}static frameCentre(t){return{x:Ve.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,y:me.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Bn.OFF_CANVAS_DEG?Math.sign(e)*Bn.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,n){const i=Ve.frameWidthPx(e,me.CANVAS_HEIGHT_PX)/2,r=Ve.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,a=me.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=n?.get(o.t)??c,h=Oi.of(e,me.CANVAS_HEIGHT_PX,l),u=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-i,v=f.y+f.height/2-a,g=Math.hypot(p,v),m=g===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(g))/g,S={...f,x:r+p*m-f.width/2,y:a+v*m-f.height/2};return{...d,shape:{...d.shape,bounds:S}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const i of[...n.allKeyframes]){const r=Qe(t,i.t),a=this.fovOf(t,i.t),o=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,a);n.addKeyframe(i.t,i.shapes.map(c=>({...c,shape:e(c.shape,o,r)})))}}}function Fg(s){return kn.restore(zg(s),s.provenance)}function zg(s){return Bn.toAngular(s),Bn.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,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function kg(s){const{recording:t,provenance:e}=kn.strip(s),n=Bg(t);return n.provenance=e,n}function Bg(s){const t=new bc({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},Sc.fromJSON(s.timeline),s.witnessTrack?ya.fromJSON(s.witnessTrack):new ya,s.weatherTrack?Sa.fromJSON(s.weatherTrack):new Sa,s.soundTrack?ba.fromJSON(s.soundTrack):new ba,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),tc(s.milestones??[]));return t.testimony=s.testimony,Bn.toBounds(t),Bn.toPosition(t),t}function Eu(s,t){for(const e of s){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}class ec{static preferencesFor(t){const e=navigator.languages??[],n=this.declaredFor(t);return n?[n,...e]:e}static declaredFor(t){for(let e=t;e;){const n=e.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class rs{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const n of this.preferences){const i=t[n]??t[rs.base(n)];if(i)return i}const e=new Set(this.preferences.map(n=>rs.base(n)));for(const[n,i]of Object.entries(t))if(i&&e.has(rs.base(n)))return i;return Object.values(t).find(n=>n)??void 0}write(t,e,n){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const r={...t},a=Object.keys(r).find(o=>o===n)??Object.keys(r).find(o=>rs.base(o)===rs.base(n))??n;return i===void 0?delete r[a]:r[a]=i,Object.keys(r).length===0?void 0:r}static base(t){return t.toLowerCase().split("-")[0]}}const Hg="modulepreload",Gg=function(s,t){return new URL(s,t).href},wd={},th=function(t,e,n){let i=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");i=a(e.map(h=>{if(h=Gg(h,n),h in wd)return;wd[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const g=o[v];if(g.href===h&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":Hg,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((v,g)=>{p.addEventListener("load",v),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},Vg=["en","fr"],Wg={en:()=>th(()=>Promise.resolve().then(()=>qg),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>th(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function Xg(s){return Wg[s]()}const Mp={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},qg=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Mp},Symbol.toStringTag,{value:"Module"})),Ad=2;function xp(s){return s==="building"||s==="vehicle"}function Yg(s,t){const e=s.litKeyframes;if(!e||e.length===0)return s.lit??!1;let n=e[0];for(const i of e){if(i.t>t)break;n=i}return n.lit}function Kg(s,t){return s.pattern.kind==="steady"?!0:_p(s,t,t+1)>.5}function _p(s,t,e){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:r=0}=s.pattern,a=Math.min(Math.max(i,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function wu(s,t){const e=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return Td(e[0],s);const i=e[e.length-1];if(t>=i.t)return Td(i,s);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return n}function Td(s,t){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??t.headingDeg}}const yp=Math.PI/180,$g=180/Math.PI,Zg=256,Jg=19;function jg(s,t){return 156543.03392*Math.cos(s*yp)/2**t}function Qg(s,t){return jg(s,t)*Zg}function Sp(s,t){let e=0;for(;e<Jg&&Qg(s,e+1)>=t;)e++;return e}function Vo(s){const t=s*yp;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function bp(s,t,e){const n=2**e;return{x:(s+180)/360*n,y:Vo(t)*n}}function Ep(s,t,e){const n=Vo(s.north),i=Vo(s.south);return{x:(t-s.west)/(s.east-s.west),y:(Vo(e)-n)/(i-n)}}function t1(s,t,e){const{x:n,y:i}=bp(s,t,e);return{x:Math.floor(n),y:Math.floor(i),z:e}}function e1(s){const t=2**s.z,e=s.x/t*360-180,n=(s.x+1)/t*360-180,i=Rd(s.y,t);return{south:Rd(s.y+1,t),north:i,west:e,east:n}}function Rd(s,t){const e=s/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*$g}function wp(s,t,e,n){const i=t1(s,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:i.x+h,y:i.y+l,z:e});const o=a.map(e1),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 bs{constructor(t){this.ctx=t}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(t,e){let n,i=1/0;for(const r of this.targets){const a=Math.hypot(r.x-t,r.y-e);a>r.radius||a>i||(n=r,i=a)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,n){const i=Ep(t,n,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const n=t.imagery;if(!n)return;const i=this.toCanvas(t.bounds,n.bounds.north,n.bounds.west),r=this.toCanvas(t.bounds,n.bounds.south,n.bounds.east);e.drawImage(n.source,i.x,i.y,r.x-i.x,r.y-i.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const n of t.decor){const i=this.toCanvas(t.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),n.headingDeg===void 0)continue;const r=(n.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(r)*10,i.y+Math.sin(r)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,n=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:n,coneHalfAngleDeg:i}=t;if(n===void 0||i===void 0)return;const{ctx:r}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(n-90)*Math.PI/180,l=i*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(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const n of[...t.markers].sort((i,r)=>Number(i.current)-Number(r.current))){const i=this.toCanvas(t.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:bs.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,bs.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=n.current?"#1d2321":"#fff",e.fillText(n.label,i.x,i.y)}}paintWitness(t,e){const{ctx:n}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const r=t.markers.some(a=>{if(!a.current)return!1;const o=tn(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=bs.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,r?bs.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=r?3:2.5,n.strokeStyle=r?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,n=16;t.beginPath(),t.moveTo(e,n-9),t.lineTo(e-4.5,n+5),t.lineTo(e,n+2),t.lineTo(e+4.5,n+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,n+6),t.fillText("N",e,n+6)}paintFooter(t,e){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let r=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(t.south+t.north)/2,c=Math.abs(tn(a,t.east,a,t.west).x)/this.width,l=bs.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(u,d),n.lineTo(u+h,d),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,n),i.fillStyle="#fff",i.fillText(t,e,n)}wrap(t,e){const n=[];let i="";for(const r of t.split(" ")){const a=i?`${i} ${r}`:r;i&&this.ctx.measureText(a).width>e?(n.push(i),i=r):i=a}return i&&n.push(i),n}}const Nn=256,Dd=3,n1=32768;class i1{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,i=(t.west+t.east)/2,r=Math.abs(tn(n,t.east,n,t.west).x),a=Math.abs(tn(t.north,i,t.south,i).z),o=Sp(n,Math.max(r,a)),{tiles:c}=wp(i,n,o,Dd),l=Dd*Nn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const g=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,g,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,i){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Nn,c.height=Nn;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,Nn,Nn),u=(t.x-e.x)*Nn,d=(t.y-e.y)*Nn;for(let f=0;f<Nn;f++)for(let p=0;p<Nn;p++){const v=(f*Nn+p)*4,g=h[v]*256+h[v+1]+h[v+2]/256-n1,m=u+p,S=d+f;n[S*i+m]=g}}sampleAt(t,e,n,i,r,a){const{x:o,y:c}=bp(e,t,n),l=(o-i.x)*Nn,h=(c-i.y)*Nn,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,g=h-d,m=r[d*a+u],S=r[d*a+f],E=r[p*a+u],_=r[p*a+f],b=m+(S-m)*v,w=E+(_-E)*v;return b+(w-b)*g}}const Fc=256,Cd=3;async function s1(s,t,e,n){const i=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(tn(i,s.east,i,s.west).x),o=Math.abs(tn(s.north,r,s.south,r).z),c=Sp(i,Math.max(a,o)/2),{tiles:l,bounds:h}=wp(r,i,c,Cd),u=Cd*Fc,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 m=>{const S=e(m),E=await n(S);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${S}`);const _=await createImageBitmap(await E.blob());f.drawImage(_,(m.x-p.x)*Fc,(m.y-p.y)*Fc)}));const v=document.createElement("canvas");v.width=t.width,v.height=t.height;const g=v.getContext("2d");if(!g)throw new Error("2D canvas context unavailable");return g.drawImage(d,0,0,u,u,0,0,t.width,t.height),{source:v,width:t.width,height:t.height,bounds:h}}class r1{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return s1(t,e,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function a1(){return{elevation:new i1,imagery:Ap()}}function Ap(){return new r1}const o1=new Set,Sr="show-witness-map",br="hide-milestones";class Un extends HTMLElement{static get observedAttributes(){return["src",Sr,br]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;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=bc.create();sightingAudio=new Ug;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=Mp;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=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.shapeAt(e.x,e.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-r.left+12}px`,this.tooltip.style.top=`${t.clientY-r.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-n.left+12}px`,this.tooltip.style.top=`${t.clientY-n.top+12}px`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${cg}</style>${og}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ql(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),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 bs(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 e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),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(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.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.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t===Sr&&this.applyWitnessMapDefault(),t===br&&this.setMilestonesShown(!this.hasAttribute(br))}async loadFromSrc(t){this.sightingData=await gp.json(t)}get sightingData(){return Fg(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=kg(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==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(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?tc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`;const r=this.said.read(n.label)??"",a=this.said.read(n.note),o=a?`${r} — ${a}`:r;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?Ed(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const n=document.createElement("b");n.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),r=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(r))}exposureInstants(t){const e=this.exposureTimes(t),n=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(t=this.currentTime){const e=(this.currentSighting.exposure??0)*1e3;if(e<Un.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const n=Math.min(Un.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e/Un.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(t,e)/Un.EXPOSURE_STEP_PX),r=Math.min(Un.MAX_TRAVEL_STEPS,Math.max(n,i)),a=[];for(let o=0;o<r;o++)a.push(t+e*o/r);return a}travelPxOver(t,e){const n=this.shapesAt(t),i=this.shapesAt(t+e);let r=0;for(const[a,o]of n){const c=i.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(t,e,n){for(const i of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(i,t,e,n);if(r)return r}}shapesAt(t){const e=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=Ve.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:o1;this.canvasRenderer.setStarPoints(Ve.starPointsOf(this.sighting.instrument));const i=(Qe(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const r=this.exposureInstants(t),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)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(n.size>1){const o=Cn.groupBoundsFor([...e].filter(([c])=>n.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}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(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Rg(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Dg(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.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(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.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(Sr)&&this.witnessPath!==void 0)}setWitnessMapOpen(t){this.witnessMapPanel.hidden=!t,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(t)),this.updateWitnessMapButton(),t&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const e=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=e,this.witnessMapButton.setAttribute("aria-label",e)}updateWitnessMap(){const t=this.witnessPath!==void 0;if(this.witnessPath=_a.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!t&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const e=this.witnessPath.boundsAround(Un.WITNESS_MAP_MIN_SPAN_M,Un.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const n=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<n&&Math.abs(t.south-e.south)<n&&Math.abs(t.west-e.west)<n&&Math.abs(t.east-e.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Ap(),e=this.witnessMapBounds;try{const n=await t.getImageryTexture(e,{width:Un.WITNESS_MAP_IMAGERY_PX,height:Un.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=t.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(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepWitnessMapClear()}keepWitnessMapClear(){if(this.witnessMapPanel.hidden)return;const t=this.witnessMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],n=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},i=[this.canvas.width-t.width,this.canvas.width],r=[0,t.width],a=Un.WITNESS_MAP_CLEARANCE_PX,o=n(...i,0),c=n(...r,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!n(i[0],i[1],a))&&this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(r[0],r[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*n,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=Qe(this.currentSighting,t),n=this.currentSighting.instrument,i=[],r=this.currentSighting.milestones.length>0?Ed(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?tc(this.currentSighting.milestones):[]){const o=Qe(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||i.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:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Oi.of(n,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ve.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=Qe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=wu(n,t),{lat:r,lng:a}=Ni(i.eastM,-i.northM,e.lat,e.lng);return{lat:r,lng:a,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,n=this.lookPitchDeg+t.pitchDeg;if(e===0&&n===0)return{x:0,y:0};const i=Qe(this.currentSighting,this.currentTime),r=Oi.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-r.angleDegToRadiusPx(e),y:r.angleDegToRadiusPx(n)}}gaitAt(t){return Ge.of(this.currentSighting)?.offsetAt(t)??Ge.STILL}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new rs(ec.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=Eu(ec.preferencesFor(this),Vg);t!=="en"&&this.applyMessages(await Xg(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=wg(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Jl(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return qa(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Id(Pd(this.realStartMs+n)):qa(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?qa(this.currentSighting.timeline.duration):this.canShowClockTime?Id(Pd(this.realStartMs+this.realDurationMs)):qa(this.realDurationMs)}}function Pd(s){const t=new Date(s);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Id(s){if(s.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return s.second?`${t(s.hour)}:${t(s.minute??0)}:${t(s.second)}`:`${t(s.hour)}:${t(s.minute??0)}`}function qa(s){const t=Math.round(s/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const eh="rr0-ufo";function Tp(){customElements.get(eh)||customElements.define(eh,Un)}/**
514
+ `,Ba=[{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 Ve{static get default(){return Ba[0]}static byId(t){return Ba.find(e=>e.id===t)??this.default}static UNAIDED_FIELD_DEG=60;static UNAIDED_ASPECT=16/9;static fieldOfViewDeg(t){const e=t.frame;return e?2*Math.atan(e.heightMm/(2*e.focalLengthMm))*180/Math.PI:Ve.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:Ve.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*Ve.aspectOf(t))}static availableAt(t){return t===void 0?Ba:Ba.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const n=t.frame;if(!(!n||e<=0))return 2*Math.atan(n.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const n=t.frame;if(!(!n||e<=0||e>=180))return n.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const n=e??t.fNumber;if(n===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??Ve.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class _a{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const n of t.witnessTrack.allKeyframes){const{lat:i,lng:r,headingDeg:a}=n.pose;i===void 0||r===void 0||e.push({t:n.t,lat:i,lng:r,headingDeg:a})}if(e.length===0){const n=t.event.place?.[0];if(!n)return;e.push({t:0,lat:n.lat,lng:n.lng})}return new _a(e)}get moved(){return this.spanM>_a.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,n=(t.west+t.east)/2;return Math.max(Math.abs(tn(e,t.east,e,t.west).x),Math.abs(tn(t.north,n,t.south,n).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:n,lng:i}=this.center,r=Math.max(this.spanM*(1+e),t)/2;return{north:Ni(0,-r,n,i).lat,south:Ni(0,r,n,i).lat,east:Ni(r,0,n,i).lng,west:Ni(-r,0,n,i).lng}}get box(){const t=this.points.map(n=>n.lat),e=this.points.map(n=>n.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class Ge{constructor(t,e){this.stretches=t,this.rotationPassed=e}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(t){const e=_a.of(t);if(!e||e.points.length<2)return;const n=[];let i=0;for(let r=1;r<e.points.length;r++){const a=e.points[r-1],o=e.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=tn(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=Ge.stepHzFor(f);n.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=p*c}for(let r=0;r<n.length;r++){const a=n[r-1],o=n[r+1];n[r].rampsIn=a===void 0||a.stepHz===0,n[r].rampsOut=o===void 0||o.stepHz===0}if(n.some(r=>r.stepHz>0))return new Ge(n,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<Ge.SLOWEST_WALK_M_PER_S||t>Ge.FASTEST_WALK_M_PER_S?0:Ge.REFERENCE_STEP_HZ*Math.pow(t/Ge.REFERENCE_SPEED_M_PER_S,Ge.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return Ge.STILL;const n=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,i=2*Math.PI*n,r=this.amplitudeAt(e,t),a=Ge.SWAY_M*r*Math.cos(i/2),o=r*this.rotationPassed*e.speedMPerS/Ge.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:Ge.RISE_M_PER_M_PER_S*e.speedMPerS*r*Math.cos(i),rollDeg:Ge.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Ge.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(t,e){const n=1e3/t.stepHz,i=Math.min(n,(t.endMs-t.startMs)/2);if(i<=0)return 1;const r=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?r/i:1,t.rampsOut?a/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class me{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/me.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function lg(s,t,e){if(!s||!t)return e<1?s:t;const n=((t.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*e)%360+360)%360,altitudeDeg:s.altitudeDeg+(t.altitudeDeg-s.altitudeDeg)*e}}function hg(s,t,e){const{bounds:n}=s;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function Sn(s,t,e){return s+(t-s)*e}function hd(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function ug(s){return`#${s.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function dg(s,t,e){const n=hd(s),i=hd(t);return!n||!i?e<1?s:t:ug([Sn(n[0],i[0],e),Sn(n[1],i[1],e),Sn(n[2],i[2],e)])}function fg(s,t,e){const n={x:Sn(s.bounds.x,t.bounds.x,e),y:Sn(s.bounds.y,t.bounds.y,e),width:Sn(s.bounds.width,t.bounds.width,e),height:Sn(s.bounds.height,t.bounds.height,e)},i=Sn(s.angle,t.angle,e),r=Sn(s.transparency,t.transparency,e),a=Sn(s.haloScale,t.haloScale,e),o=Sn(s.blur??0,t.blur??0,e),c=Sn(s.brightness??0,t.brightness??0,e),l=dg(s.color,t.color,e),h=me.lerpAngular(s.angular,t.angular,e),u=lg(s.aim,t.aim,e);return s.kind==="polygon"&&t.kind==="polygon"&&s.points.length===t.points.length?{...s,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,points:s.points.map((d,f)=>({x:Sn(d.x,t.points[f].x,e),y:Sn(d.y,t.points[f].y,e)}))}:{...e<1?s:t,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class Sc{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const i=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!i.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const i=this.findShapeAtOrAfter(t,e);return n?i?fg(n.shape,i.shape,(t-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(t,e,n,i){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(i?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&hg(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const n=this.groups[e].filter(i=>i!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new Sc;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(i=>e.order.includes(i))).filter(n=>n.length>=2)),e}}function pg(s,t,e){return Math.max(t,Math.min(e,s))}function mg(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function Xs(s,t,e){return s+(t-s)*e}function gg(s,t,e){return{lat:s.lat===void 0||t.lat===void 0?void 0:Xs(s.lat,t.lat,e),lng:s.lng===void 0||t.lng===void 0?void 0:Xs(s.lng,t.lng,e),elevationM:Xs(s.elevationM,t.elevationM,e),headingDeg:s.headingDeg===void 0||t.headingDeg===void 0?void 0:mg(s.headingDeg,t.headingDeg,e),pitchDeg:Xs(s.pitchDeg,t.pitchDeg,e),rollDeg:Xs(s.rollDeg??0,t.rollDeg??0,e),fovDeg:Xs(s.fovDeg,t.fovDeg,e),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class ya{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?gg(n.pose,i.pose,pg((t-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ya;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function _e(s,t,e){return s+(t-s)*e}function bu(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function vg(s,t,e){return Math.max(t,Math.min(e,s))}function Mg(s=[],t=[],e){if(!(!s.length&&!t.length))return[...new Set([...s.map(n=>n.id),...t.map(n=>n.id)])].map(n=>{const i=s.find(c=>c.id===n),r=t.find(c=>c.id===n),a=i??{...r,density:0},o=r??{...i,density:0};return{...a,eastM:_e(a.eastM,o.eastM,e),northM:_e(a.northM,o.northM,e),baseM:_e(a.baseM,o.baseM,e),thicknessM:_e(a.thicknessM,o.thicknessM,e),widthM:_e(a.widthM,o.widthM,e),depthM:_e(a.depthM,o.depthM,e),rotationDeg:bu(a.rotationDeg,o.rotationDeg,e),density:_e(a.density,o.density,e),darkness:_e(a.darkness??0,o.darkness??0,e)}})}function xg(s,t,e){if(s.cloudLayers===void 0&&t.cloudLayers===void 0)return;const n=jo(s),i=jo(t);return e>=1?i.map(a=>({...a})):[...new Set([...n.map(a=>a.id),...i.map(a=>a.id)])].map(a=>{const o=n.find(u=>u.id===a),c=i.find(u=>u.id===a),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:Mg(o?.instances,c?.instances,e),baseM:_e(l.baseM,h.baseM,e),thicknessM:_e(l.thicknessM,h.thicknessM,e),coverage:_e(l.coverage,h.coverage,e),sizeM:_e(l.sizeM,h.sizeM,e),density:_e(l.density,h.density,e),darkness:_e(l.darkness??s.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:_e(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:_e(l.windSpeed??s.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:bu(l.windDirectionDeg??s.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function _g(s,t,e){return{cloudLayers:xg(s,t,e),cloudCover:_e(s.cloudCover,t.cloudCover,e),cloudDarkness:_e(s.cloudDarkness,t.cloudDarkness,e),highCloudCover:s.highCloudCover===void 0||t.highCloudCover===void 0?void 0:_e(s.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:s.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:_e(s.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:s.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:_e(s.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:s.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:_e(s.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?s.precipitationType:t.precipitationType,precipitationIntensity:_e(s.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:bu(s.windDirectionDeg,t.windDirectionDeg,e),windSpeed:_e(s.windSpeed,t.windSpeed,e),storm:e<1?s.storm:t.storm}}class Sa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?_g(n.weather,i.weather,vg((t-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Sa;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class ba{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return i?.sound;if(!i)return n.sound;const r=(t-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ba;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}}const yg=100,Sg={kind:"none",volume:0,pitchHz:yg};class kn{constructor(t){this.entries=t}static empty(){return new kn(new Map)}get size(){return this.entries.size}at(t){return this.entries.get(t)}paths(){return[...this.entries.keys()]}set(t,e){e.basis==="stated"&&e.rationale===void 0?this.entries.delete(t):this.entries.set(t,e)}clear(t){for(const e of this.entries.keys())(e===t||e.startsWith(`${t}.`))&&this.entries.delete(e)}static strip(t){const e=new kn(new Map);return{recording:kn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const n=structuredClone(t);for(const i of e.paths()){const r=e.at(i),a=i.split("."),o=kn.holderOf(n,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 n}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,n){return kn.isWrapper(t)?(n.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),kn.stripValue(t.value,e,n)):Array.isArray(t)?t.map((i,r)=>kn.stripValue(i,[...e,String(r)],n)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,kn.stripValue(r,[...e,i],n)])):t}static holderOf(t,e){let n=t;for(const i of e.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}function Jl(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 ud(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const bg=["year","month","day","hour","minute"],Eg=["day","hour","minute"];function dd(s,t){return t.filter(e=>s[e]!==void 0).join(",")}function wg(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const t=s.time.year!==void 0&&s.endTime.year!==void 0,e=t?bg:Eg,n=dd(s.time,e);if(!(n===""||n!==dd(s.endTime,e)))return t?Jl(s.endTime)-Jl(s.time):ud(s.endTime)-ud(s.time)}class bc{constructor(t,e,n,i,r,a,o,c,l=[],h,u,d,f=[]){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=i,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}provenance=kn.empty();testimony;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return Ve.byId(this.instrumentId)}static create(t,e,n){return new bc({eventType:"sighting",time:t,place:e},new Sc,new ya,new Sa,new ba,n)}}const Ag=0,Tg=0;function Qe(s,t){const e=s.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Ag,headingDeg:void 0,pitchDeg:Tg,fovDeg:Ve.fieldOfViewDeg(s.instrument)}}function Ha(s,t){return s.weatherTrack.getInterpolatedWeatherAt(t)??s.weather??pp}function Rg(s,t){return s.soundTrack.getInterpolatedSoundAt(t)??Sg}class Dg{constructor(t,e){this.timeline=t,this.onFrame=e}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 t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}this.onFrame(t,e)}}const vp=["nw","n","ne","e","se","s","sw","w"],Cg=24,Ga=8,Pg=3,Ig=8;function Va(s,t,e){const n=s.x-t.x,i=s.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-i*a,y:t.y+n*a+i*r}}function Br(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const Lg={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 Cn{static handlePointsFor(t){const{x:e,y:n,width:i,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+i/2,y:n},ne:{x:e+i,y:n},e:{x:e+i,y:n+r/2},se:{x:e+i,y:n+r},s:{x:e+i/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+i/2,y:n-Cg}},o=Br(t.bounds),c={};for(const l of Object.keys(a))c[l]=Va(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,i=[...vp,"rotate"]){const r=Cn.handlePointsFor(t);for(const a of i)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((Cn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(i)%r.length]}static resizeBounds(t,e,n,i){const r=Br(t),a=Va(i,r,-e),{x:o,y:c,width:l,height:h}=t,u=Lg[n];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(a.x,p-Ga)),u.right&&(p=Math.max(a.x,d+Ga)),u.top&&(f=Math.min(a.y,v-Ga)),u.bottom&&(v=Math.max(a.y,f+Ga)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:r}=t.bounds,a=Cn.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=i===0?1:a.width/i,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Br(t.bounds),i=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),i=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:i-e,height:r-n}}static vertexPointsFor(t){const e=Br(t.bounds);return t.points.map(n=>Va({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=Ig){const i=Cn.vertexPointsFor(t);let r,a=n;return i.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Br(t.bounds),i=Va(e,n,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,n){const i=t.points.map((u,d)=>d===e?Cn.toLocalPoint(t,n):u),r=Math.min(...i.map(u=>u.x)),a=Math.min(...i.map(u=>u.y)),o=Math.max(...i.map(u=>u.x)),c=Math.max(...i.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=i.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=Cn.toLocalPoint(t,e),{points:i}=t;let r=i.length-1,a=1/0;for(let c=0;c<i.length;c++){const l=i[c],h=i[(c+1)%i.length],u=Cn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...i.slice(0,r+1),n,...i.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const i=n.x-e.x,r=n.y-e.y,a=i*i+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*r)/a)),c=e.x+o*i,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Pg?t:{...t,points:t.points.filter((n,i)=>i!==e)}}}const jl=6,Wa=jl/2,fd=20,pd=24,md=9,gd=6,vd=7,Md=6,xd=4;class Ql{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:n,width:i,height:r}=t.bounds,a=e+i/2,o=n+r/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(i,r)/2,h=c?l:i/2,u=c?l:r/2,d=Math.max(i,r)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+md*f),Md*f)-d:0,v=f>0?d*(1+vd*f)-d:0,g=3*pd*(t.blur??0)+1.5*fd*t.haloScale,m=Math.max(p,v,0)+g+2;return{x:a-h-m,y:o-u-m,width:2*(h+m),height:2*(u+m)}}paintInto(t,e,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-e.x,-e.y),this.paintShape(t.selected?{...t,selected:!1}:t),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(pd*e).toFixed(2)}px)`);const n=t.brightness??0;n>0&&this.paintDazzle(t,n),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:n,y:i,width:r,height:a}=t.bounds,o=n+r/2,c=i+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+md*e),Md*e);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<=gd;d++){const f=d/gd,p=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,p*e*.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+vd*e);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,g=c+Math.sin(p)*d,m=this.ctx.createLinearGradient(o,c,v,g);m.addColorStop(0,this.withAlpha(t.color,e*.55)),m.addColorStop(.35,this.withAlpha(t.color,e*.22)),m.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,g),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const n=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!n)return t.color;const i=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*e);return`rgb(${r(i>>16&255)}, ${r(i>>8&255)}, ${r(i&255)})`}withAlpha(t,e){const n=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const r=Number.parseInt(i[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:i,height:r}=t.bounds,a=i/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:i,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=fd*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(Cn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of Cn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,xd,xd,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(Cn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintGroupHandles(t){this.paintHandleFrame(Cn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of vp){const i=t[n];this.ctx.fillRect(i.x-Wa,i.y-Wa,jl,jl)}e&&(this.ctx.beginPath(),this.ctx.moveTo(t.n.x,t.n.y),this.ctx.lineTo(t.rotate.x,t.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(t.rotate.x,t.rotate.y,Wa+1,Wa+1,0,0,2*Math.PI),this.ctx.fill())}}const _d=.05,yd=.08,Sd=2,bd=3,Ng=14,Og=.02;class Ug{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const i=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,_d);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),i,_d)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),i.connect(r),r.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,i.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(i).connect(r).connect(t.destination),n.start(),{key:e,nodes:[i,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(i).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[i,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const i=this.context;if(!i)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=i.createBufferSource();a.buffer=r,a.loop=!0;const o=i.createGain();o.gain.value=0,a.connect(o).connect(i.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*Sd),t.sampleRate),n=e.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*Sd),t.sampleRate),n=e.getChannelData(0);let i=0,r=0;for(let a=0;a<n.length;a++)i=(i+.02*(Math.random()*2-1))/1.02,n[a]=i,r=Math.max(r,Math.abs(i));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*bd),t.sampleRate),n=e.getChannelData(0),i=Math.max(1,Math.floor(Og*t.sampleRate)),r=Math.round(bd*Ng);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<i&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,yd/3);const i=n+yd;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(i)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}function tc(s){return[...s].sort((t,e)=>t.t-e.t)}function Ed(s,t){let e;for(const n of tc(s)){if(n.t>t)break;e=n}return e}const Uc=Math.PI/180,Xa=180/Math.PI;class Oi{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const i=n*Uc/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,n){return new Oi(t.projection,e,n)}degToPx(t){const e=t*Uc;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Xa:2*Math.atan(t/(2*this.focalPx))*Xa}angleDegToRadiusPx(t){const e=t*Uc;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}halfWidthAngleDeg(t){return this.radiusPxToAngleDeg(this.canvasHeightPx*t/2)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*Xa:Math.atan(t/this.focalPx)*Xa}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(me.angularWidthDeg(t))}}class Bn{static fovOf(t,e){return Qe(t,e)?.fovDeg??Ve.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:i,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:i,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:i/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,n,i)=>{const r=this.aimFrom(t,n,i,e.bounds);return r?{...e,aim:r}:e})}static aimOf(t,e,n){const i=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,i,Qe(t,e),n)}static aimFrom(t,e,n,i){if(n?.headingDeg===void 0)return;const r=this.frameCentre(t),a=e.radiusPxToAngleDeg(i.x+i.width/2-r.x),o=e.radiusPxToAngleDeg(r.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+a)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,n,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,c=r.x+this.offAxisPx(n,a)-e.bounds.width/2,l=r.y-this.offAxisPx(n,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:c,y:l}}})}static frameCentre(t){return{x:Ve.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,y:me.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Bn.OFF_CANVAS_DEG?Math.sign(e)*Bn.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,n){const i=Ve.frameWidthPx(e,me.CANVAS_HEIGHT_PX)/2,r=Ve.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,a=me.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=n?.get(o.t)??c,h=Oi.of(e,me.CANVAS_HEIGHT_PX,l),u=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-i,v=f.y+f.height/2-a,g=Math.hypot(p,v),m=g===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(g))/g,S={...f,x:r+p*m-f.width/2,y:a+v*m-f.height/2};return{...d,shape:{...d.shape,bounds:S}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const i of[...n.allKeyframes]){const r=Qe(t,i.t),a=this.fovOf(t,i.t),o=Oi.of(t.instrument,me.CANVAS_HEIGHT_PX,a);n.addKeyframe(i.t,i.shapes.map(c=>({...c,shape:e(c.shape,o,r)})))}}}function Fg(s){return kn.restore(zg(s),s.provenance)}function zg(s){return Bn.toAngular(s),Bn.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,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function kg(s){const{recording:t,provenance:e}=kn.strip(s),n=Bg(t);return n.provenance=e,n}function Bg(s){const t=new bc({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},Sc.fromJSON(s.timeline),s.witnessTrack?ya.fromJSON(s.witnessTrack):new ya,s.weatherTrack?Sa.fromJSON(s.weatherTrack):new Sa,s.soundTrack?ba.fromJSON(s.soundTrack):new ba,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),tc(s.milestones??[]));return t.testimony=s.testimony,Bn.toBounds(t),Bn.toPosition(t),t}const wd=2;function Mp(s){return s==="building"||s==="vehicle"}function Hg(s,t){const e=s.litKeyframes;if(!e||e.length===0)return s.lit??!1;let n=e[0];for(const i of e){if(i.t>t)break;n=i}return n.lit}function Gg(s,t){return s.pattern.kind==="steady"?!0:xp(s,t,t+1)>.5}function xp(s,t,e){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:r=0}=s.pattern,a=Math.min(Math.max(i,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function Eu(s,t){const e=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return Ad(e[0],s);const i=e[e.length-1];if(t>=i.t)return Ad(i,s);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return n}function Ad(s,t){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??t.headingDeg}}class $n{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const n=Number.isFinite(e)?Math.max(0,e):0,i=Math.max(0,t-n*1e3),r=Math.max(0,t-i);return{fromMs:i,toMs:t,ms:r,seconds:r/1e3}}static instants(t,e,n,i,r){if(!(i>0))return 1;const a=r>0?$n.travelDegOver(t,e,n,n+i*1e3)/r/$n.PIXELS_PER_INSTANT:0,o=$n.flashesOver(t,i)*$n.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min($n.MAX_INSTANTS,c)}static travelDegOver(t,e,n,i){let r=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=$n.directionAt(a,e,n),c=$n.directionAt(a,e,i),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(t,e){let n=0;for(const i of t)for(const r of i.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*e}static directionAt(t,e,n){const i=Eu(t,n),r=i.eastM,a=i.altitudeM-e,o=i.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 wu(s,t){for(const e of s){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}class ec{static preferencesFor(t){const e=navigator.languages??[],n=this.declaredFor(t);return n?[n,...e]:e}static declaredFor(t){for(let e=t;e;){const n=e.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class rs{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const n of this.preferences){const i=t[n]??t[rs.base(n)];if(i)return i}const e=new Set(this.preferences.map(n=>rs.base(n)));for(const[n,i]of Object.entries(t))if(i&&e.has(rs.base(n)))return i;return Object.values(t).find(n=>n)??void 0}write(t,e,n){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const r={...t},a=Object.keys(r).find(o=>o===n)??Object.keys(r).find(o=>rs.base(o)===rs.base(n))??n;return i===void 0?delete r[a]:r[a]=i,Object.keys(r).length===0?void 0:r}static base(t){return t.toLowerCase().split("-")[0]}}const Vg="modulepreload",Wg=function(s,t){return new URL(s,t).href},Td={},th=function(t,e,n){let i=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");i=a(e.map(h=>{if(h=Wg(h,n),h in Td)return;Td[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const g=o[v];if(g.href===h&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":Vg,u||(p.as="script"),p.crossOrigin="",p.href=h,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((v,g)=>{p.addEventListener("load",v),p.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},Xg=["en","fr"],qg={en:()=>th(()=>Promise.resolve().then(()=>Kg),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>th(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function Yg(s){return qg[s]()}const _p={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},Kg=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:_p},Symbol.toStringTag,{value:"Module"})),yp=Math.PI/180,$g=180/Math.PI,Zg=256,Jg=19;function jg(s,t){return 156543.03392*Math.cos(s*yp)/2**t}function Qg(s,t){return jg(s,t)*Zg}function Sp(s,t){let e=0;for(;e<Jg&&Qg(s,e+1)>=t;)e++;return e}function Vo(s){const t=s*yp;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function bp(s,t,e){const n=2**e;return{x:(s+180)/360*n,y:Vo(t)*n}}function Ep(s,t,e){const n=Vo(s.north),i=Vo(s.south);return{x:(t-s.west)/(s.east-s.west),y:(Vo(e)-n)/(i-n)}}function t1(s,t,e){const{x:n,y:i}=bp(s,t,e);return{x:Math.floor(n),y:Math.floor(i),z:e}}function e1(s){const t=2**s.z,e=s.x/t*360-180,n=(s.x+1)/t*360-180,i=Rd(s.y,t);return{south:Rd(s.y+1,t),north:i,west:e,east:n}}function Rd(s,t){const e=s/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*$g}function wp(s,t,e,n){const i=t1(s,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:i.x+h,y:i.y+l,z:e});const o=a.map(e1),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 bs{constructor(t){this.ctx=t}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(t,e){let n,i=1/0;for(const r of this.targets){const a=Math.hypot(r.x-t,r.y-e);a>r.radius||a>i||(n=r,i=a)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,n){const i=Ep(t,n,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const n=t.imagery;if(!n)return;const i=this.toCanvas(t.bounds,n.bounds.north,n.bounds.west),r=this.toCanvas(t.bounds,n.bounds.south,n.bounds.east);e.drawImage(n.source,i.x,i.y,r.x-i.x,r.y-i.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const n of t.decor){const i=this.toCanvas(t.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),n.headingDeg===void 0)continue;const r=(n.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(r)*10,i.y+Math.sin(r)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,n=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:n,coneHalfAngleDeg:i}=t;if(n===void 0||i===void 0)return;const{ctx:r}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(n-90)*Math.PI/180,l=i*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(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const n of[...t.markers].sort((i,r)=>Number(i.current)-Number(r.current))){const i=this.toCanvas(t.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:bs.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,bs.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=n.current?"#1d2321":"#fff",e.fillText(n.label,i.x,i.y)}}paintWitness(t,e){const{ctx:n}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const r=t.markers.some(a=>{if(!a.current)return!1;const o=tn(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=bs.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,r?bs.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=r?3:2.5,n.strokeStyle=r?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,n=16;t.beginPath(),t.moveTo(e,n-9),t.lineTo(e-4.5,n+5),t.lineTo(e,n+2),t.lineTo(e+4.5,n+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,n+6),t.fillText("N",e,n+6)}paintFooter(t,e){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let r=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(t.south+t.north)/2,c=Math.abs(tn(a,t.east,a,t.west).x)/this.width,l=bs.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(u,d),n.lineTo(u+h,d),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,n),i.fillStyle="#fff",i.fillText(t,e,n)}wrap(t,e){const n=[];let i="";for(const r of t.split(" ")){const a=i?`${i} ${r}`:r;i&&this.ctx.measureText(a).width>e?(n.push(i),i=r):i=a}return i&&n.push(i),n}}const Nn=256,Dd=3,n1=32768;class i1{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,i=(t.west+t.east)/2,r=Math.abs(tn(n,t.east,n,t.west).x),a=Math.abs(tn(t.north,i,t.south,i).z),o=Sp(n,Math.max(r,a)),{tiles:c}=wp(i,n,o,Dd),l=Dd*Nn,h=new Float32Array(l*l),u=c[0];await Promise.all(c.map(f=>this.decodeTileInto(f,u,h,l)));const d=new Float32Array(e.width*e.height);for(let f=0;f<e.height;f++){const p=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const g=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,g,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,i){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Nn,c.height=Nn;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,Nn,Nn),u=(t.x-e.x)*Nn,d=(t.y-e.y)*Nn;for(let f=0;f<Nn;f++)for(let p=0;p<Nn;p++){const v=(f*Nn+p)*4,g=h[v]*256+h[v+1]+h[v+2]/256-n1,m=u+p,S=d+f;n[S*i+m]=g}}sampleAt(t,e,n,i,r,a){const{x:o,y:c}=bp(e,t,n),l=(o-i.x)*Nn,h=(c-i.y)*Nn,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,g=h-d,m=r[d*a+u],S=r[d*a+f],E=r[p*a+u],_=r[p*a+f],b=m+(S-m)*v,w=E+(_-E)*v;return b+(w-b)*g}}const Fc=256,Cd=3;async function s1(s,t,e,n){const i=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(tn(i,s.east,i,s.west).x),o=Math.abs(tn(s.north,r,s.south,r).z),c=Sp(i,Math.max(a,o)/2),{tiles:l,bounds:h}=wp(r,i,c,Cd),u=Cd*Fc,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 m=>{const S=e(m),E=await n(S);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${S}`);const _=await createImageBitmap(await E.blob());f.drawImage(_,(m.x-p.x)*Fc,(m.y-p.y)*Fc)}));const v=document.createElement("canvas");v.width=t.width,v.height=t.height;const g=v.getContext("2d");if(!g)throw new Error("2D canvas context unavailable");return g.drawImage(d,0,0,u,u,0,0,t.width,t.height),{source:v,width:t.width,height:t.height,bounds:h}}class r1{attribution="Imagery © Esri, Maxar, Earthstar Geographics, and the GIS User Community";fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}"}async getImageryTexture(t,e){return s1(t,e,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function a1(){return{elevation:new i1,imagery:Ap()}}function Ap(){return new r1}const o1=new Set,Sr="show-witness-map",br="hide-milestones";class Un extends HTMLElement{static get observedAttributes(){return["src",Sr,br]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;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=bc.create();sightingAudio=new Ug;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=_p;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=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.shapeAt(e.x,e.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-r.left+12}px`,this.tooltip.style.top=`${t.clientY-r.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-n.left+12}px`,this.tooltip.style.top=`${t.clientY-n.top+12}px`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${cg}</style>${og}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ql(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),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 bs(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 e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),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(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.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.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t===Sr&&this.applyWitnessMapDefault(),t===br&&this.setMilestonesShown(!this.hasAttribute(br))}async loadFromSrc(t){this.sightingData=await gp.json(t)}get sightingData(){return Fg(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=kg(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==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(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?tc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`;const r=this.said.read(n.label)??"",a=this.said.read(n.note),o=a?`${r} — ${a}`:r;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?Ed(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const n=document.createElement("b");n.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),r=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(r))}exposureInstants(t){const e=this.exposureTimes(t),n=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(t=this.currentTime){const e=$n.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Un.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const n=Math.min(Un.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Un.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Un.EXPOSURE_STEP_PX),r=Math.min(Un.MAX_TRAVEL_STEPS,Math.max(n,i)),a=[];for(let o=0;o<r;o++)a.push(e.fromMs+e.ms*o/(r-1));return a}travelPxOver(t,e){const n=this.shapesAt(t),i=this.shapesAt(t+e);let r=0;for(const[a,o]of n){const c=i.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(t,e,n){for(const i of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(i,t,e,n);if(r)return r}}shapesAt(t){const e=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=Ve.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:o1;this.canvasRenderer.setStarPoints(Ve.starPointsOf(this.sighting.instrument));const i=(Qe(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const r=this.exposureInstants(t),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)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(n.size>1){const o=Cn.groupBoundsFor([...e].filter(([c])=>n.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}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(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Rg(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new Dg(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.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(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.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(Sr)&&this.witnessPath!==void 0)}setWitnessMapOpen(t){this.witnessMapPanel.hidden=!t,this.witnessMapPanel.removeAttribute("title"),this.witnessMapButton.setAttribute("aria-pressed",String(t)),this.updateWitnessMapButton(),t&&(this.sizeWitnessMapCanvas(),this.loadWitnessMapImagery(),this.paintWitnessMap(this.currentTime))}updateWitnessMapButton(){const e=!this.witnessMapPanel.hidden?this.messages.hideWitnessMap:this.messages.showWitnessMap;this.witnessMapButton.title=e,this.witnessMapButton.setAttribute("aria-label",e)}updateWitnessMap(){const t=this.witnessPath!==void 0;if(this.witnessPath=_a.of(this.currentSighting),this.witnessMapButton.hidden=this.witnessPath===void 0,!t&&this.witnessPath&&this.applyWitnessMapDefault(),!this.witnessPath){this.setWitnessMapOpen(!1),this.witnessMapBounds=void 0;return}const e=this.witnessPath.boundsAround(Un.WITNESS_MAP_MIN_SPAN_M,Un.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const n=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<n&&Math.abs(t.south-e.south)<n&&Math.abs(t.west-e.west)<n&&Math.abs(t.east-e.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Ap(),e=this.witnessMapBounds;try{const n=await t.getImageryTexture(e,{width:Un.WITNESS_MAP_IMAGERY_PX,height:Un.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=t.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(t){this.mapSceneBounds=t.map(e=>({x:e.x*this.canvas.width,y:e.y*this.canvas.height,width:e.width*this.canvas.width,height:e.height*this.canvas.height})),this.keepWitnessMapClear()}keepWitnessMapClear(){if(this.witnessMapPanel.hidden)return;const t=this.witnessMapBoxPx;if(!t)return;const e=[...this.mapShapeBounds,...this.mapSceneBounds],n=(l,h,u)=>{for(const d of e)if(!(d.x+d.width<l-u||d.x>h+u)&&!(d.y>t.bottom+u||d.y+d.height<t.top-u))return!0;return!1},i=[this.canvas.width-t.width,this.canvas.width],r=[0,t.width],a=Un.WITNESS_MAP_CLEARANCE_PX,o=n(...i,0),c=n(...r,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!n(i[0],i[1],a))&&this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(r[0],r[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*n,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=Qe(this.currentSighting,t),n=this.currentSighting.instrument,i=[],r=this.currentSighting.milestones.length>0?Ed(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?tc(this.currentSighting.milestones):[]){const o=Qe(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||i.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:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Oi.of(n,this.canvas.height,e.fovDeg).halfWidthAngleDeg(Ve.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=Qe(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=Eu(n,t),{lat:r,lng:a}=Ni(i.eastM,-i.northM,e.lat,e.lng);return{lat:r,lng:a,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,n=this.lookPitchDeg+t.pitchDeg;if(e===0&&n===0)return{x:0,y:0};const i=Qe(this.currentSighting,this.currentTime),r=Oi.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-r.angleDegToRadiusPx(e),y:r.angleDegToRadiusPx(n)}}gaitAt(t){return Ge.of(this.currentSighting)?.offsetAt(t)??Ge.STILL}updateFullscreenButton(){const t=this.simulatedFullscreen||document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}get said(){return this.saidTexts??=new rs(ec.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=wu(ec.preferencesFor(this),Xg);t!=="en"&&this.applyMessages(await Yg(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=wg(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Jl(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return qa(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Id(Pd(this.realStartMs+n)):qa(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?qa(this.currentSighting.timeline.duration):this.canShowClockTime?Id(Pd(this.realStartMs+this.realDurationMs)):qa(this.realDurationMs)}}function Pd(s){const t=new Date(s);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Id(s){if(s.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return s.second?`${t(s.hour)}:${t(s.minute??0)}:${t(s.second)}`:`${t(s.hour)}:${t(s.minute??0)}`}function qa(s){const t=Math.round(s/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const eh="rr0-ufo";function Tp(){customElements.get(eh)||customElements.define(eh,Un)}/**
515
515
  * @license
516
516
  * Copyright 2010-2026 Three.js Authors
517
517
  * SPDX-License-Identifier: MIT
518
- */const Au="185",c1=0,Ld=1,l1=2,da=1,h1=2,aa=3,us=0,ze=1,$n=2,Mi=0,Er=1,Qn=2,Nd=3,Od=4,u1=5,Es=100,d1=101,f1=102,p1=103,m1=104,g1=200,v1=201,M1=202,x1=203,nh=204,ih=205,_1=206,y1=207,S1=208,b1=209,E1=210,w1=211,A1=212,T1=213,R1=214,sh=0,rh=1,ah=2,Pr=3,oh=4,ch=5,lh=6,hh=7,Tu=0,D1=1,C1=2,xi=0,Rp=1,Dp=2,Cp=3,Pp=4,Ip=5,Lp=6,Np=7,Ud="attached",P1="detached",Op=300,Os=301,Ir=302,zc=303,kc=304,Ec=306,Ea=1e3,gn=1001,uh=1002,We=1003,I1=1004,Ya=1005,ye=1006,Bc=1007,Ds=1008,In=1009,Up=1010,Fp=1011,wa=1012,Ru=1013,ti=1014,Gn=1015,cn=1016,Du=1017,Cu=1018,Aa=1020,zp=35902,kp=35899,Bp=1021,Hp=1022,vn=1023,ki=1026,Cs=1027,wc=1028,Pu=1029,Us=1030,Iu=1031,Lu=1033,Wo=33776,Xo=33777,qo=33778,Yo=33779,dh=35840,fh=35841,ph=35842,mh=35843,gh=36196,vh=37492,Mh=37496,xh=37488,_h=37489,nc=37490,yh=37491,Sh=37808,bh=37809,Eh=37810,wh=37811,Ah=37812,Th=37813,Rh=37814,Dh=37815,Ch=37816,Ph=37817,Ih=37818,Lh=37819,Nh=37820,Oh=37821,Uh=36492,Fh=36494,zh=36495,kh=36283,Bh=36284,ic=36285,Hh=36286,sc=2300,Gh=2301,Hc=2302,Fd=2303,zd=2400,kd=2401,Bd=2402,L1=2500,ow=0,cw=1,lw=2,N1=3200,rc=0,O1=1,as="",Pn="srgb",ac="srgb-linear",oc="linear",se="srgb",qs=7680,Hd=519,U1=512,F1=513,z1=514,Nu=515,k1=516,B1=517,Ou=518,H1=519,Vh=35044,Gd="300 es",gi=2e3,Ta=2001;function G1(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function V1(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ra(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function W1(){const s=Ra("canvas");return s.style.display="block",s}const Vd={};function cc(...s){const t="THREE."+s.shift();console.log(t,...s)}function Gp(s){const t=s[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=s[1];e&&e.isStackTrace?s[0]+=" "+e.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function wt(...s){s=Gp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...s)}}function zt(...s){s=Gp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...s)}}function wr(...s){const t=s.join(" ");t in Vd||(Vd[t]=!0,wt(...s))}function X1(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const q1={[sh]:rh,[ah]:lh,[oh]:hh,[Pr]:ch,[rh]:sh,[lh]:ah,[hh]:oh,[ch]:Pr};class Bs{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,t);t.target=null}}}const sn=["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 Wd=1234567;const fa=Math.PI/180,Lr=180/Math.PI;function jn(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(sn[s&255]+sn[s>>8&255]+sn[s>>16&255]+sn[s>>24&255]+"-"+sn[t&255]+sn[t>>8&255]+"-"+sn[t>>16&15|64]+sn[t>>24&255]+"-"+sn[e&63|128]+sn[e>>8&255]+"-"+sn[e>>16&255]+sn[e>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function Kt(s,t,e){return Math.max(t,Math.min(e,s))}function Uu(s,t){return(s%t+t)%t}function Y1(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function K1(s,t,e){return s!==t?(e-s)/(t-s):0}function pa(s,t,e){return(1-e)*s+e*t}function $1(s,t,e,n){return pa(s,t,1-Math.exp(-e*n))}function Z1(s,t=1){return t-Math.abs(Uu(s,t*2)-t)}function J1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function j1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Q1(s,t){return s+Math.floor(Math.random()*(t-s+1))}function tv(s,t){return s+Math.random()*(t-s)}function ev(s){return s*(.5-Math.random())}function nv(s){s!==void 0&&(Wd=s);let t=Wd+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function iv(s){return s*fa}function sv(s){return s*Lr}function rv(s){return(s&s-1)===0&&s!==0}function av(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ov(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function cv(s,t,e,n,i){const r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),p=a((n-t)/2);switch(i){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:wt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Zn(s,t){switch(t.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 re(s,t){switch(t.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 hw={DEG2RAD:fa,RAD2DEG:Lr,generateUUID:jn,clamp:Kt,euclideanModulo:Uu,mapLinear:Y1,inverseLerp:K1,lerp:pa,damp:$1,pingpong:Z1,smoothstep:J1,smootherstep:j1,randInt:Q1,randFloat:tv,randFloatSpread:ev,seededRandom:nv,degToRad:iv,radToDeg:sv,isPowerOfTwo:rv,ceilPowerOfTwo:av,floorPowerOfTwo:ov,setQuaternionFromProperEuler:cv,normalize:re,denormalize:Zn};class Pt{static{Pt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Kt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fs{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+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 g=c*d+l*f+h*p+u*v;g<0&&(d=-d,f=-f,p=-p,v=-v,g=-g);let m=1-o;if(g<.9995){const S=Math.acos(g),E=Math.sin(S);m=Math.sin(m*S)/E,o=Math.sin(o*S)/E,c=c*m+d*o,l=l*m+f*o,h=h*m+p*o,u=u*m+v*o}else{c=c*m+d*o,l=l*m+f*o,h=h*m+p*o,u=u*m+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+3];return t[e]=o*p+h*u+c*f-l*d,t[e+1]=c*p+h*d+l*u-o*f,t[e+2]=l*p+h*f+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/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:wt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Kt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{static{C.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Xd.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Xd.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this.z=Kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this.z=Kt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Gc.copy(this).projectOnVector(t),this.sub(Gc)}reflect(t){return this.sub(Gc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Kt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Gc=new C,Xd=new fs;class kt{static{kt.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],v=i[0],g=i[3],m=i[6],S=i[1],E=i[4],_=i[7],b=i[2],w=i[5],R=i[8];return r[0]=a*v+o*S+c*b,r[3]=a*g+o*E+c*w,r[6]=a*m+o*_+c*R,r[1]=l*v+h*S+u*b,r[4]=l*g+h*E+u*w,r[7]=l*m+h*_+u*R,r[2]=d*v+f*S+p*b,r[5]=d*g+f*E+p*w,r[8]=d*m+f*_+p*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(i*l-h*n)*v,t[2]=(o*n-i*a)*v,t[3]=d*v,t[4]=(h*e-i*c)*v,t[5]=(i*r-o*e)*v,t[6]=f*v,t[7]=(n*c-l*e)*v,t[8]=(a*e-n*r)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return wr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vc.makeScale(t,e)),this}rotate(t){return wr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vc.makeRotation(-t)),this}translate(t,e){return wr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Vc=new kt,qd=new kt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Yd=new kt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function lv(){const s={enabled:!0,workingColorSpace:ac,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===se&&(i.r=Fi(i.r),i.g=Fi(i.g),i.b=Fi(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===se&&(i.r=Ar(i.r),i.g=Ar(i.g),i.b=Ar(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===as?oc:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return wr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return wr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ac]:{primaries:t,whitePoint:n,transfer:oc,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Pn},outputColorSpaceConfig:{drawingBufferColorSpace:Pn}},[Pn]:{primaries:t,whitePoint:n,transfer:se,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Pn}}}),s}const jt=lv();function Fi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ar(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Ys;class hv{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Ys===void 0&&(Ys=Ra("canvas")),Ys.width=t.width,Ys.height=t.height;const i=Ys.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Ys}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Ra("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Fi(r[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Fi(e[n]/255)*255):e[n]=Fi(e[n]);return{data:e,width:t.width,height:t.height}}else return wt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let uv=0;class Fu{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:uv++}),this.uuid=jn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Wc(i[a].image)):r.push(Wc(i[a]))}else r=Wc(i);n.url=r}return e||(t.images[this.uuid]=n),n}}function Wc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?hv.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(wt("Texture: Unable to serialize Texture."),{})}let dv=0;const Xc=new C;class en extends Bs{constructor(t=en.DEFAULT_IMAGE,e=en.DEFAULT_MAPPING,n=gn,i=gn,r=ye,a=Ds,o=vn,c=In,l=en.DEFAULT_ANISOTROPY,h=as){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dv++}),this.uuid=jn(),this.name="",this.source=new Fu(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Pt(0,0),this.repeat=new Pt(1,1),this.center=new Pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Xc).x}get height(){return this.source.getSize(Xc).y}get depth(){return this.source.getSize(Xc).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){wt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Op)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ea:t.x=t.x-Math.floor(t.x);break;case gn:t.x=t.x<0?0:1;break;case uh:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Ea:t.y=t.y-Math.floor(t.y);break;case gn:t.y=t.y<0?0:1;break;case uh:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=Op;en.DEFAULT_ANISOTROPY=1;class le{static{le.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],g=c[6],m=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const E=(l+1)/2,_=(f+1)/2,b=(m+1)/2,w=(h+d)/4,R=(u+v)/4,M=(p+g)/4;return E>_&&E>b?E<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(E),i=w/n,r=R/n):_>b?_<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(_),n=w/i,r=M/i):b<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(b),n=R/r,i=M/r),this.set(n,i,r,e),this}let S=Math.sqrt((g-p)*(g-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(g-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this.z=Kt(this.z,t.z,e.z),this.w=Kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this.z=Kt(this.z,t,e),this.w=Kt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fv extends Bs{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ye,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new le(0,0,t,e),this.scissorTest=!1,this.viewport=new le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new en(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:ye,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Fu(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class wn extends fv{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Vp extends en{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=We,this.minFilter=We,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wp extends en{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=We,this.minFilter=We,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wt{static{Wt.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=v,m[15]=g,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 Wt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Ks.setFromMatrixColumn(t,0).length(),r=1/Ks.setFromMatrixColumn(t,1).length(),a=1/Ks.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+p*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=p+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d+v*o,e[4]=p*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=p*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-p,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=p*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+p,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=o*h,e[10]=v*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(pv,t,mv)}lookAt(t,e,n){const i=this.elements;return Tn.subVectors(t,e),Tn.lengthSq()===0&&(Tn.z=1),Tn.normalize(),Ki.crossVectors(n,Tn),Ki.lengthSq()===0&&(Math.abs(n.z)===1?Tn.x+=1e-4:Tn.z+=1e-4,Tn.normalize(),Ki.crossVectors(n,Tn)),Ki.normalize(),Ka.crossVectors(Tn,Ki),i[0]=Ki.x,i[4]=Ka.x,i[8]=Tn.x,i[1]=Ki.y,i[5]=Ka.y,i[9]=Tn.y,i[2]=Ki.z,i[6]=Ka.z,i[10]=Tn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],v=n[6],g=n[10],m=n[14],S=n[3],E=n[7],_=n[11],b=n[15],w=i[0],R=i[4],M=i[8],A=i[12],P=i[1],D=i[5],I=i[9],F=i[13],H=i[2],O=i[6],V=i[10],k=i[14],Y=i[3],tt=i[7],J=i[11],nt=i[15];return r[0]=a*w+o*P+c*H+l*Y,r[4]=a*R+o*D+c*O+l*tt,r[8]=a*M+o*I+c*V+l*J,r[12]=a*A+o*F+c*k+l*nt,r[1]=h*w+u*P+d*H+f*Y,r[5]=h*R+u*D+d*O+f*tt,r[9]=h*M+u*I+d*V+f*J,r[13]=h*A+u*F+d*k+f*nt,r[2]=p*w+v*P+g*H+m*Y,r[6]=p*R+v*D+g*O+m*tt,r[10]=p*M+v*I+g*V+m*J,r[14]=p*A+v*F+g*k+m*nt,r[3]=S*w+E*P+_*H+b*Y,r[7]=S*R+E*D+_*O+b*tt,r[11]=S*M+E*I+_*V+b*J,r[15]=S*A+E*F+_*k+b*nt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],v=t[7],g=t[11],m=t[15],S=c*f-l*d,E=o*f-l*u,_=o*d-c*u,b=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return e*(v*S-g*E+m*_)-n*(p*S-g*b+m*w)+i*(p*E-v*b+m*R)-r*(p*_-v*w+g*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],v=t[13],g=t[14],m=t[15],S=e*o-n*a,E=e*c-i*a,_=e*l-r*a,b=n*c-i*o,w=n*l-r*o,R=i*l-r*c,M=h*v-u*p,A=h*g-d*p,P=h*m-f*p,D=u*g-d*v,I=u*m-f*v,F=d*m-f*g,H=S*F-E*I+_*D+b*P-w*A+R*M;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/H;return t[0]=(o*F-c*I+l*D)*O,t[1]=(i*I-n*F-r*D)*O,t[2]=(v*R-g*w+m*b)*O,t[3]=(d*w-u*R-f*b)*O,t[4]=(c*P-a*F-l*A)*O,t[5]=(e*F-i*P+r*A)*O,t[6]=(g*_-p*R-m*E)*O,t[7]=(h*R-d*_+f*E)*O,t[8]=(a*I-o*P+l*M)*O,t[9]=(n*P-e*I-r*M)*O,t[10]=(p*w-v*_+m*S)*O,t[11]=(u*_-h*w-f*S)*O,t[12]=(o*A-a*D-c*M)*O,t[13]=(e*D-n*A+i*M)*O,t[14]=(v*E-p*b-g*S)*O,t[15]=(h*b-u*E+d*S)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,g=a*u,m=o*u,S=c*l,E=c*h,_=c*u,b=n.x,w=n.y,R=n.z;return i[0]=(1-(v+m))*b,i[1]=(f+_)*b,i[2]=(p-E)*b,i[3]=0,i[4]=(f-_)*w,i[5]=(1-(d+m))*w,i[6]=(g+S)*w,i[7]=0,i[8]=(p+E)*R,i[9]=(g-S)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=Ks.set(i[0],i[1],i[2]).length();const o=Ks.set(i[4],i[5],i[6]).length(),c=Ks.set(i[8],i[9],i[10]).length();r<0&&(a=-a),Wn.copy(this);const l=1/a,h=1/o,u=1/c;return Wn.elements[0]*=l,Wn.elements[1]*=l,Wn.elements[2]*=l,Wn.elements[4]*=h,Wn.elements[5]*=h,Wn.elements[6]*=h,Wn.elements[8]*=u,Wn.elements[9]*=u,Wn.elements[10]*=u,e.setFromRotationMatrix(Wn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,i,r,a,o=gi,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===gi)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Ta)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(t,e,n,i,r,a,o=gi,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,v;if(c)p=1/(a-r),v=a/(a-r);else if(o===gi)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===Ta)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(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Ks=new C,Wn=new Wt,pv=new C(0,0,0),mv=new C(1,1,1),Ki=new C,Ka=new C,Tn=new C,Kd=new Wt,$d=new fs;class Bi{constructor(t=0,e=0,n=0,i=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Kt(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(-Kt(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(Kt(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(-Kt(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(Kt(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(-Kt(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:wt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Kd.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Kd,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return $d.setFromEuler(this),this.setFromQuaternion($d,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class zu{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let gv=0;const Zd=new C,$s=new fs,Si=new Wt,$a=new C,Hr=new C,vv=new C,Mv=new fs,Jd=new C(1,0,0),jd=new C(0,1,0),Qd=new C(0,0,1),t0={type:"added"},xv={type:"removed"},Zs={type:"childadded",child:null},qc={type:"childremoved",child:null};class Se extends Bs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gv++}),this.uuid=jn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Se.DEFAULT_UP.clone();const t=new C,e=new Bi,n=new fs,i=new C(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Wt},normalMatrix:{value:new kt}}),this.matrix=new Wt,this.matrixWorld=new Wt,this.matrixAutoUpdate=Se.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return $s.setFromAxisAngle(t,e),this.quaternion.multiply($s),this}rotateOnWorldAxis(t,e){return $s.setFromAxisAngle(t,e),this.quaternion.premultiply($s),this}rotateX(t){return this.rotateOnAxis(Jd,t)}rotateY(t){return this.rotateOnAxis(jd,t)}rotateZ(t){return this.rotateOnAxis(Qd,t)}translateOnAxis(t,e){return Zd.copy(t).applyQuaternion(this.quaternion),this.position.add(Zd.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Jd,t)}translateY(t){return this.translateOnAxis(jd,t)}translateZ(t){return this.translateOnAxis(Qd,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Si.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?$a.copy(t):$a.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Hr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Si.lookAt(Hr,$a,this.up):Si.lookAt($a,Hr,this.up),this.quaternion.setFromRotationMatrix(Si),i&&(Si.extractRotation(i.matrixWorld),$s.setFromRotationMatrix(Si),this.quaternion.premultiply($s.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(zt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(t0),Zs.child=t,this.dispatchEvent(Zs),Zs.child=null):zt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(xv),qc.child=t,this.dispatchEvent(qc),qc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),Si.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Si.multiply(t.parent.matrixWorld)),t.applyMatrix4(Si),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(t0),Zs.child=t,this.dispatchEvent(Zs),Zs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,t,vv),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,Mv,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));i.material=o}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),p=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}Se.DEFAULT_UP=new C(0,1,0);Se.DEFAULT_MATRIX_AUTO_UPDATE=!0;Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class on extends Se{constructor(){super(),this.isGroup=!0,this.type="Group"}}const _v={type:"move"};class Yc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new on,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 on,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new on,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const g=e.getJointPose(v,n),m=this._getHandJoint(l,v);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==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:t.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_v)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new on;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Xp={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},$i={h:0,s:0,l:0},Za={h:0,s:0,l:0};function Kc(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}class ct{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Pn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,jt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=jt.workingColorSpace){return this.r=t,this.g=e,this.b=n,jt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=jt.workingColorSpace){if(t=Uu(t,1),e=Kt(e,0,1),n=Kt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Kc(a,r,t+1/3),this.g=Kc(a,r,t),this.b=Kc(a,r,t-1/3)}return jt.colorSpaceToWorking(this,i),this}setStyle(t,e=Pn){function n(r){r!==void 0&&parseFloat(r)<1&&wt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:wt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);wt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Pn){const n=Xp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):wt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Fi(t.r),this.g=Fi(t.g),this.b=Fi(t.b),this}copyLinearToSRGB(t){return this.r=Ar(t.r),this.g=Ar(t.g),this.b=Ar(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Pn){return jt.workingToColorSpace(rn.copy(this),t),Math.round(Kt(rn.r*255,0,255))*65536+Math.round(Kt(rn.g*255,0,255))*256+Math.round(Kt(rn.b*255,0,255))}getHexString(t=Pn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=jt.workingColorSpace){jt.workingToColorSpace(rn.copy(this),e);const n=rn.r,i=rn.g,r=rn.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=jt.workingColorSpace){return jt.workingToColorSpace(rn.copy(this),e),t.r=rn.r,t.g=rn.g,t.b=rn.b,t}getStyle(t=Pn){jt.workingToColorSpace(rn.copy(this),t);const e=rn.r,n=rn.g,i=rn.b;return t!==Pn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL($i),this.setHSL($i.h+t,$i.s+e,$i.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL($i),t.getHSL(Za);const n=pa($i.h,Za.h,e),i=pa($i.s,Za.s,e),r=pa($i.l,Za.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const rn=new ct;ct.NAMES=Xp;class lc{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ct(t),this.near=e,this.far=n}clone(){return new lc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Da extends Se{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Bi,this.environmentIntensity=1,this.environmentRotation=new Bi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Xn=new C,bi=new C,$c=new C,Ei=new C,Js=new C,js=new C,e0=new C,Zc=new C,Jc=new C,jc=new C,Qc=new le,tl=new le,el=new le;class Hn{constructor(t=new C,e=new C,n=new C){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Xn.subVectors(t,e),i.cross(Xn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Xn.subVectors(i,e),bi.subVectors(n,e),$c.subVectors(t,e);const a=Xn.dot(Xn),o=Xn.dot(bi),c=Xn.dot($c),l=bi.dot(bi),h=bi.dot($c),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(t,e,n,i){return this.getBarycoord(t,e,n,i,Ei)===null?!1:Ei.x>=0&&Ei.y>=0&&Ei.x+Ei.y<=1}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,Ei)===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,Ei.x),c.addScaledVector(a,Ei.y),c.addScaledVector(o,Ei.z),c)}static getInterpolatedAttribute(t,e,n,i,r,a){return Qc.setScalar(0),tl.setScalar(0),el.setScalar(0),Qc.fromBufferAttribute(t,e),tl.fromBufferAttribute(t,n),el.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Qc,r.x),a.addScaledVector(tl,r.y),a.addScaledVector(el,r.z),a}static isFrontFacing(t,e,n,i){return Xn.subVectors(n,e),bi.subVectors(t,e),Xn.cross(bi).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Xn.subVectors(this.c,this.b),bi.subVectors(this.a,this.b),Xn.cross(bi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Hn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Hn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Hn.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Hn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Hn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;Js.subVectors(i,n),js.subVectors(r,n),Zc.subVectors(t,n);const c=Js.dot(Zc),l=js.dot(Zc);if(c<=0&&l<=0)return e.copy(n);Jc.subVectors(t,i);const h=Js.dot(Jc),u=js.dot(Jc);if(h>=0&&u<=h)return e.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(Js,a);jc.subVectors(t,r);const f=Js.dot(jc),p=js.dot(jc);if(p>=0&&f<=p)return e.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(n).addScaledVector(js,o);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return e0.subVectors(r,i),o=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(e0,o);const m=1/(g+v+d);return a=v*m,o=d*m,e.copy(n).addScaledVector(Js,a).addScaledVector(js,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class ei{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(qn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(qn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=qn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,qn):qn.fromBufferAttribute(r,a),qn.applyMatrix4(t.matrixWorld),this.expandByPoint(qn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ja.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ja.copy(n.boundingBox)),Ja.applyMatrix4(t.matrixWorld),this.union(Ja)}const i=t.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,qn),qn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Gr),ja.subVectors(this.max,Gr),Qs.subVectors(t.a,Gr),tr.subVectors(t.b,Gr),er.subVectors(t.c,Gr),Zi.subVectors(tr,Qs),Ji.subVectors(er,tr),ms.subVectors(Qs,er);let e=[0,-Zi.z,Zi.y,0,-Ji.z,Ji.y,0,-ms.z,ms.y,Zi.z,0,-Zi.x,Ji.z,0,-Ji.x,ms.z,0,-ms.x,-Zi.y,Zi.x,0,-Ji.y,Ji.x,0,-ms.y,ms.x,0];return!nl(e,Qs,tr,er,ja)||(e=[1,0,0,0,1,0,0,0,1],!nl(e,Qs,tr,er,ja))?!1:(Qa.crossVectors(Zi,Ji),e=[Qa.x,Qa.y,Qa.z],nl(e,Qs,tr,er,ja))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,qn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(qn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(wi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),wi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),wi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),wi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),wi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),wi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),wi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),wi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(wi),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const wi=[new C,new C,new C,new C,new C,new C,new C,new C],qn=new C,Ja=new ei,Qs=new C,tr=new C,er=new C,Zi=new C,Ji=new C,ms=new C,Gr=new C,ja=new C,Qa=new C,gs=new C;function nl(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){gs.fromArray(s,r);const o=i.x*Math.abs(gs.x)+i.y*Math.abs(gs.y)+i.z*Math.abs(gs.z),c=t.dot(gs),l=e.dot(gs),h=n.dot(gs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Li=yv();function yv(){const s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Sv(s){Math.abs(s)>65504&&wt("DataUtils.toHalfFloat(): Value out of range."),s=Kt(s,-65504,65504),Li.floatView[0]=s;const t=Li.uint32View[0],e=t>>23&511;return Li.baseTable[e]+((t&8388607)>>Li.shiftTable[e])}function bv(s){const t=s>>10;return Li.uint32View[0]=Li.mantissaTable[Li.offsetTable[t]+(s&1023)]+Li.exponentTable[t],Li.floatView[0]}class ls{static toHalfFloat(t){return Sv(t)}static fromHalfFloat(t){return bv(t)}}const He=new C,to=new Pt;let Ev=0;class de extends Bs{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Ev++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Vh,this.updateRanges=[],this.gpuType=Gn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.applyMatrix3(t),this.setXY(e,to.x,to.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyMatrix3(t),this.setXYZ(e,He.x,He.y,He.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyMatrix4(t),this.setXYZ(e,He.x,He.y,He.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyNormalMatrix(t),this.setXYZ(e,He.x,He.y,He.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.transformDirection(t),this.setXYZ(e,He.x,He.y,He.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Zn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Zn(e,this.array)),e}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Zn(e,this.array)),e}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Zn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Zn(e,this.array)),e}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Vh&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class qp extends de{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ku extends de{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Ee extends de{constructor(t,e,n){super(new Float32Array(t),e,n)}}const wv=new ei,Vr=new C,il=new C;class Hi{constructor(t=new C,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):wv.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;r<a;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Vr.subVectors(t,this.center);const e=Vr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Vr,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(il.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Vr.copy(t.center).add(il)),this.expandByPoint(Vr.copy(t.center).sub(il))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Av=0;const On=new Wt,sl=new Se,nr=new C,Rn=new ei,Wr=new ei,Ye=new C;class we extends Bs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Av++}),this.uuid=jn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(G1(t)?ku:qp)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new kt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return On.makeRotationFromQuaternion(t),this.applyMatrix4(On),this}rotateX(t){return On.makeRotationX(t),this.applyMatrix4(On),this}rotateY(t){return On.makeRotationY(t),this.applyMatrix4(On),this}rotateZ(t){return On.makeRotationZ(t),this.applyMatrix4(On),this}translate(t,e,n){return On.makeTranslation(t,e,n),this.applyMatrix4(On),this}scale(t,e,n){return On.makeScale(t,e,n),this.applyMatrix4(On),this}lookAt(t){return sl.lookAt(t),sl.updateMatrix(),this.applyMatrix4(sl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nr).negate(),this.translate(nr.x,nr.y,nr.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,r=t.length;i<r;i++){const a=t[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ee(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&wt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ei);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const r=e[n];Rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ye.addVectors(this.boundingBox.min,Rn.min),this.boundingBox.expandByPoint(Ye),Ye.addVectors(this.boundingBox.max,Rn.max),this.boundingBox.expandByPoint(Ye)):(this.boundingBox.expandByPoint(Rn.min),this.boundingBox.expandByPoint(Rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zt('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 Hi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(t){const n=this.boundingSphere.center;if(Rn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Wr.setFromBufferAttribute(o),this.morphTargetsRelative?(Ye.addVectors(Rn.min,Wr.min),Rn.expandByPoint(Ye),Ye.addVectors(Rn.max,Wr.max),Rn.expandByPoint(Ye)):(Rn.expandByPoint(Wr.min),Rn.expandByPoint(Wr.max))}Rn.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)Ye.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(Ye));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Ye.fromBufferAttribute(o,l),c&&(nr.fromBufferAttribute(t,l),Ye.add(nr)),i=Math.max(i,n.distanceToSquared(Ye))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){zt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new de(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let M=0;M<n.count;M++)o[M]=new C,c[M]=new C;const l=new C,h=new C,u=new C,d=new Pt,f=new Pt,p=new Pt,v=new C,g=new C;function m(M,A,P){l.fromBufferAttribute(n,M),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,P),d.fromBufferAttribute(r,M),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,P),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const D=1/(f.x*p.y-p.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(D),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(D),o[M].add(v),o[A].add(v),o[P].add(v),c[M].add(g),c[A].add(g),c[P].add(g))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let M=0,A=S.length;M<A;++M){const P=S[M],D=P.start,I=P.count;for(let F=D,H=D+I;F<H;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}const E=new C,_=new C,b=new C,w=new C;function R(M){b.fromBufferAttribute(i,M),w.copy(b);const A=o[M];E.copy(A),E.sub(b.multiplyScalar(b.dot(A))).normalize(),_.crossVectors(w,A);const D=_.dot(c[M])<0?-1:1;a.setXYZW(M,E.x,E.y,E.z,D)}for(let M=0,A=S.length;M<A;++M){const P=S[M],D=P.start,I=P.count;for(let F=D,H=D+I;F<H;F+=3)R(t.getX(F+0)),R(t.getX(F+1)),R(t.getX(F+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new de(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,c=new C,l=new C,h=new C,u=new C;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),r.fromBufferAttribute(e,v),a.fromBufferAttribute(e,g),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,p),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,g),o.add(h),c.add(h),l.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ye.fromBufferAttribute(t,e),Ye.normalize(),t.setXYZ(e,Ye.x,Ye.y,Ye.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,g=c.length;v<g;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let m=0;m<h;m++)d[p++]=l[f++]}return new de(d,h,u)}if(this.index===null)return wt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new we,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,n);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Tv{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Vh,this.updateRanges=[],this.version=0,this.uuid=jn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=jn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const hn=new C;class hc{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.applyMatrix4(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.applyNormalMatrix(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.transformDirection(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Zn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Zn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Zn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Zn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Zn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){cc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new de(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new hc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){cc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Rv=0;class Gi extends Bs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Rv++}),this.uuid=jn(),this.name="",this.type="Material",this.blending=Er,this.side=us,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nh,this.blendDst=ih,this.blendEquation=Es,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ct(0,0,0),this.blendAlpha=0,this.depthFunc=Pr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Hd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qs,this.stencilZFail=qs,this.stencilZPass=qs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){wt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Er&&(n.blending=this.blending),this.side!==us&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==nh&&(n.blendSrc=this.blendSrc),this.blendDst!==ih&&(n.blendDst=this.blendDst),this.blendEquation!==Es&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Pr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Hd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new ct().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Pt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Pt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class oa extends Gi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ct(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let ir;const Xr=new C,sr=new C,rr=new C,ar=new Pt,qr=new Pt,Yp=new Wt,eo=new C,Yr=new C,no=new C,n0=new Pt,rl=new Pt,i0=new Pt;class or extends Se{constructor(t=new oa){if(super(),this.isSprite=!0,this.type="Sprite",ir===void 0){ir=new we;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Tv(e,5);ir.setIndex([0,1,2,0,2,3]),ir.setAttribute("position",new hc(n,3,0,!1)),ir.setAttribute("uv",new hc(n,2,3,!1))}this.geometry=ir,this.material=t,this.center=new Pt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&zt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),sr.setFromMatrixScale(this.matrixWorld),Yp.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),rr.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&sr.multiplyScalar(-rr.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;io(eo.set(-.5,-.5,0),rr,a,sr,i,r),io(Yr.set(.5,-.5,0),rr,a,sr,i,r),io(no.set(.5,.5,0),rr,a,sr,i,r),n0.set(0,0),rl.set(1,0),i0.set(1,1);let o=t.ray.intersectTriangle(eo,Yr,no,!1,Xr);if(o===null&&(io(Yr.set(-.5,.5,0),rr,a,sr,i,r),rl.set(0,1),o=t.ray.intersectTriangle(eo,no,Yr,!1,Xr),o===null))return;const c=t.ray.origin.distanceTo(Xr);c<t.near||c>t.far||e.push({distance:c,point:Xr.clone(),uv:Hn.getInterpolation(Xr,eo,Yr,no,n0,rl,i0,new Pt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function io(s,t,e,n,i,r){ar.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(qr.x=r*ar.x-i*ar.y,qr.y=i*ar.x+r*ar.y):qr.copy(ar),s.copy(t),s.x+=qr.x,s.y+=qr.y,s.applyMatrix4(Yp)}const Ai=new C,al=new C,so=new C,ji=new C,ol=new C,ro=new C,cl=new C;class Pa{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ai)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ai.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ai.copy(this.origin).addScaledVector(this.direction,e),Ai.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){al.copy(t).add(e).multiplyScalar(.5),so.copy(e).sub(t).normalize(),ji.copy(this.origin).sub(al);const r=t.distanceTo(e)*.5,a=-this.direction.dot(so),o=ji.dot(this.direction),c=-ji.dot(so),l=ji.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 n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(al).addScaledVector(so,d),f}intersectSphere(t,e){Ai.subVectors(t.center,this.origin);const n=Ai.dot(this.direction),i=Ai.dot(Ai)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ai)!==null}intersectTriangle(t,e,n,i,r){ol.subVectors(e,t),ro.subVectors(n,t),cl.crossVectors(ol,ro);let a=this.direction.dot(cl),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ji.subVectors(this.origin,t);const c=o*this.direction.dot(ro.crossVectors(ji,ro));if(c<0)return null;const l=o*this.direction.dot(ol.cross(ji));if(l<0||c+l>a)return null;const h=-o*ji.dot(cl);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class zi extends Gi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Tu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const s0=new Wt,vs=new Pa,ao=new Hi,r0=new C,oo=new C,co=new C,lo=new C,ll=new C,ho=new C,a0=new C,uo=new C;class qt extends Se{constructor(t=new we,e=new zi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){ho.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(ll.fromBufferAttribute(u,t),a?ho.addScaledVector(ll,h):ho.addScaledVector(ll.sub(e),h))}e.add(ho)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ao.copy(n.boundingSphere),ao.applyMatrix4(r),vs.copy(t.ray).recast(t.near),!(ao.containsPoint(vs.origin)===!1&&(vs.intersectSphere(ao,r0)===null||vs.origin.distanceToSquared(r0)>(t.far-t.near)**2))&&(s0.copy(r).invert(),vs.copy(t.ray).applyMatrix4(s0),!(n.boundingBox!==null&&vs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,vs)))}_computeIntersections(t,e,n){let i;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 g=d[p],m=a[g.materialIndex],S=Math.max(g.start,f.start),E=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=S,b=E;_<b;_+=3){const w=o.getX(_),R=o.getX(_+1),M=o.getX(_+2);i=fo(this,m,t,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let g=p,m=v;g<m;g+=3){const S=o.getX(g),E=o.getX(g+1),_=o.getX(g+2);i=fo(this,a,t,n,l,h,u,S,E,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const g=d[p],m=a[g.materialIndex],S=Math.max(g.start,f.start),E=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let _=S,b=E;_<b;_+=3){const w=_,R=_+1,M=_+2;i=fo(this,m,t,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let g=p,m=v;g<m;g+=3){const S=g,E=g+1,_=g+2;i=fo(this,a,t,n,l,h,u,S,E,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function Dv(s,t,e,n,i,r,a,o){let c;if(t.side===ze?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,t.side===us,o),c===null)return null;uo.copy(o),uo.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(uo);return l<e.near||l>e.far?null:{distance:l,point:uo.clone(),object:s}}function fo(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,oo),s.getVertexPosition(c,co),s.getVertexPosition(l,lo);const h=Dv(s,t,e,n,oo,co,lo,a0);if(h){const u=new C;Hn.getBarycoord(a0,oo,co,lo,u),i&&(h.uv=Hn.getInterpolatedAttribute(i,o,c,l,u,new Pt)),r&&(h.uv1=Hn.getInterpolatedAttribute(r,o,c,l,u,new Pt)),a&&(h.normal=Hn.getInterpolatedAttribute(a,o,c,l,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new C,materialIndex:0};Hn.getNormal(oo,co,lo,d.normal),h.face=d,h.barycoord=u}return h}const Kr=new le,o0=new le,c0=new le,Cv=new le,l0=new Wt,po=new C,hl=new Hi,h0=new Wt,ul=new Pa;class uw extends qt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ud,this.bindMatrix=new Wt,this.bindMatrixInverse=new Wt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new ei),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,po),this.boundingBox.expandByPoint(po)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Hi),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,po),this.boundingSphere.expandByPoint(po)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hl.copy(this.boundingSphere),hl.applyMatrix4(i),t.ray.intersectsSphere(hl)!==!1&&(h0.copy(i).invert(),ul.copy(t.ray).applyMatrix4(h0),!(this.boundingBox!==null&&ul.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,ul)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===Ud?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===P1?this.bindMatrixInverse.copy(this.bindMatrix).invert():wt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;o0.fromBufferAttribute(i.attributes.skinIndex,t),c0.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(Kr.copy(e),e.set(0,0,0,0)):(Kr.set(...e,1),e.set(0,0,0)),Kr.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=c0.getComponent(r);if(a!==0){const o=o0.getComponent(r);l0.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(Cv.copy(Kr).applyMatrix4(l0),a)}}return e.isVector4&&(e.w=Kr.w),e.applyMatrix4(this.bindMatrixInverse)}}class Pv extends Se{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends en{constructor(t=null,e=1,n=1,i,r,a,o,c,l=We,h=We,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const u0=new Wt,Iv=new Wt;class Kp{constructor(t=[],e=[]){this.uuid=jn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){wt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Wt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Wt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=t.length;r<a;r++){const o=t[r]?t[r].matrixWorld:Iv;u0.multiplyMatrices(o,e[r]),u0.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Kp(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Ur(e,t,t,vn,Gn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const r=t.bones[n];let a=e[r];a===void 0&&(wt("Skeleton: No bone found with UUID:",r),a=new Pv),this.bones.push(a),this.boneInverses.push(new Wt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const a=e[i];t.bones.push(a.uuid);const o=n[i];t.boneInverses.push(o.toArray())}return t}}class d0 extends de{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const cr=new Wt,f0=new Wt,mo=[],p0=new ei,Lv=new Wt,$r=new qt,Zr=new Hi;class dw extends qt{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new d0(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Lv)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new ei),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,cr),p0.copy(t.boundingBox).applyMatrix4(cr),this.boundingBox.union(p0)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Hi),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,cr),Zr.copy(t.boundingSphere).applyMatrix4(cr),this.boundingSphere.union(Zr)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=t*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){const n=this.matrixWorld,i=this.count;if($r.geometry=this.geometry,$r.material=this.material,$r.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Zr.copy(this.boundingSphere),Zr.applyMatrix4(n),t.ray.intersectsSphere(Zr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,cr),f0.multiplyMatrices(n,cr),$r.matrixWorld=f0,$r.raycast(t,mo);for(let a=0,o=mo.length;a<o;a++){const c=mo[a];c.instanceId=r,c.object=this,e.push(c)}mo.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new d0(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(i*this.count),i,this.count,wc,Gn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*t;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const dl=new C,Nv=new C,Ov=new kt;class Ss{constructor(t=new C(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=dl.subVectors(n,e).cross(Nv.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(dl),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Ov.getNormalMatrix(t),i=this.coplanarPoint(dl).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ms=new Hi,Uv=new Pt(.5,.5),go=new C;class Bu{constructor(t=new Ss,e=new Ss,n=new Ss,i=new Ss,r=new Ss,a=new Ss){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=gi,n=!1){const i=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],g=r[10],m=r[11],S=r[12],E=r[13],_=r[14],b=r[15];if(i[0].setComponents(l-a,f-h,m-p,b-S).normalize(),i[1].setComponents(l+a,f+h,m+p,b+S).normalize(),i[2].setComponents(l+o,f+u,m+v,b+E).normalize(),i[3].setComponents(l-o,f-u,m-v,b-E).normalize(),n)i[4].setComponents(c,d,g,_).normalize(),i[5].setComponents(l-c,f-d,m-g,b-_).normalize();else if(i[4].setComponents(l-c,f-d,m-g,b-_).normalize(),e===gi)i[5].setComponents(l+c,f+d,m+g,b+_).normalize();else if(e===Ta)i[5].setComponents(c,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Ms.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Ms.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ms)}intersectsSprite(t){Ms.center.set(0,0,0);const e=Uv.distanceTo(t.center);return Ms.radius=.7071067811865476+e,Ms.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ms)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(go.x=i.normal.x>0?t.max.x:t.min.x,go.y=i.normal.y>0?t.max.y:t.min.y,go.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(go)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Fv extends Gi{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ct(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const uc=new C,dc=new C,m0=new Wt,Jr=new Pa,vo=new Hi,fl=new C,g0=new C;class $p extends Se{constructor(t=new we,e=new Fv){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)uc.fromBufferAttribute(e,i-1),dc.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=uc.distanceTo(dc);t.setAttribute("lineDistance",new Ee(n,1))}else wt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),vo.copy(n.boundingSphere),vo.applyMatrix4(i),vo.radius+=r,t.ray.intersectsSphere(vo)===!1)return;m0.copy(i).invert(),Jr.copy(t.ray).applyMatrix4(m0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,g=p-1;v<g;v+=l){const m=h.getX(v),S=h.getX(v+1),E=Mo(this,t,Jr,c,m,S,v);E&&e.push(E)}if(this.isLineLoop){const v=h.getX(p-1),g=h.getX(f),m=Mo(this,t,Jr,c,v,g,p-1);m&&e.push(m)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,g=p-1;v<g;v+=l){const m=Mo(this,t,Jr,c,v,v+1,v);m&&e.push(m)}if(this.isLineLoop){const v=Mo(this,t,Jr,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Mo(s,t,e,n,i,r,a){const o=s.geometry.attributes.position;if(uc.fromBufferAttribute(o,i),dc.fromBufferAttribute(o,r),e.distanceSqToSegment(uc,dc,fl,g0)>n)return;fl.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(fl);if(!(l<t.near||l>t.far))return{distance:l,point:g0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const v0=new C,M0=new C;class fw extends $p{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)v0.fromBufferAttribute(e,i),M0.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+v0.distanceTo(M0);t.setAttribute("lineDistance",new Ee(n,1))}else wt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class pw extends $p{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Zp extends Gi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ct(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const x0=new Wt,Wh=new Pa,xo=new Hi,_o=new C;class Ko extends Se{constructor(t=new we,e=new Zp){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xo.copy(n.boundingSphere),xo.applyMatrix4(i),xo.radius+=r,t.ray.intersectsSphere(xo)===!1)return;x0.copy(i).invert(),Wh.copy(t.ray).applyMatrix4(x0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const g=l.getX(p);_o.fromBufferAttribute(u,g),_0(_o,g,c,i,t,e,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++)_o.fromBufferAttribute(u,p),_0(_o,p,c,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function _0(s,t,e,n,i,r,a){const o=Wh.distanceSqToPoint(s);if(o<e){const c=new C;Wh.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Jp extends en{constructor(t=[],e=Os,n,i,r,a,o,c,l,h){super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class yi extends en{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fs extends en{constructor(t,e,n=ti,i,r,a,o=We,c=We,l,h=ki,u=1){if(h!==ki&&h!==Cs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Fu(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class zv extends Fs{constructor(t,e=ti,n=Os,i,r,a=We,o=We,c,l=ki){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class jp extends en{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Vn extends we{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,e,t,a,r,0),p("z","y","x",1,-1,n,e,-t,a,r,1),p("x","z","y",1,1,t,n,e,i,a,2),p("x","z","y",1,-1,t,n,-e,i,a,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Ee(l,3)),this.setAttribute("normal",new Ee(h,3)),this.setAttribute("uv",new Ee(u,2));function p(v,g,m,S,E,_,b,w,R,M,A){const P=_/R,D=b/M,I=_/2,F=b/2,H=w/2,O=R+1,V=M+1;let k=0,Y=0;const tt=new C;for(let J=0;J<V;J++){const nt=J*D-F;for(let at=0;at<O;at++){const Ht=at*P-I;tt[v]=Ht*S,tt[g]=nt*E,tt[m]=H,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[g]=0,tt[m]=w>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(at/R),u.push(1-J/M),k+=1}}for(let J=0;J<M;J++)for(let nt=0;nt<R;nt++){const at=d+nt+O*J,Ht=d+nt+O*(J+1),$t=d+(nt+1)+O*(J+1),Bt=d+(nt+1)+O*J;c.push(at,Ht,Bt),c.push(Ht,$t,Bt),Y+=6}o.addGroup(f,Y,A),f+=Y,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Hu extends we{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new C,h=new Pt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Ee(a,3)),this.setAttribute("normal",new Ee(o,3)),this.setAttribute("uv",new Ee(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hu(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Vi extends we{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],g=n/2;let m=0;S(),a===!1&&(t>0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new Ee(u,3)),this.setAttribute("normal",new Ee(d,3)),this.setAttribute("uv",new Ee(f,2));function S(){const _=new C,b=new C;let w=0;const R=(e-t)/n;for(let M=0;M<=r;M++){const A=[],P=M/r,D=P*(e-t)+t;for(let I=0;I<=i;I++){const F=I/i,H=F*c+o,O=Math.sin(H),V=Math.cos(H);b.x=D*O,b.y=-P*n+g,b.z=D*V,u.push(b.x,b.y,b.z),_.set(O,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(F,1-P),A.push(p++)}v.push(A)}for(let M=0;M<i;M++)for(let A=0;A<r;A++){const P=v[A][M],D=v[A+1][M],I=v[A+1][M+1],F=v[A][M+1];(t>0||A!==0)&&(h.push(P,D,F),w+=3),(e>0||A!==r-1)&&(h.push(D,I,F),w+=3)}l.addGroup(m,w,0),m+=w}function E(_){const b=p,w=new Pt,R=new C;let M=0;const A=_===!0?t:e,P=_===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,g*P,0),d.push(0,P,0),f.push(.5,.5),p++;const D=p;for(let I=0;I<=i;I++){const H=I/i*c+o,O=Math.cos(H),V=Math.sin(H);R.x=A*V,R.y=g*P,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,P,0),w.x=O*.5+.5,w.y=V*.5*P+.5,f.push(w.x,w.y),p++}for(let I=0;I<i;I++){const F=b+I,H=D+I;_===!0?h.push(H,H+1,F):h.push(H+1,H,F),M+=3}l.addGroup(m,M,_===!0?1:2),m+=M}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vi(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ia extends Vi{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Ia(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Wi extends we{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],g=[];for(let m=0;m<h;m++){const S=m*d-a;for(let E=0;E<l;E++){const _=E*u-r;p.push(_,-S,0),v.push(0,0,1),g.push(E/o),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let S=0;S<o;S++){const E=S+l*m,_=S+l*(m+1),b=S+1+l*(m+1),w=S+1+l*m;f.push(E,_,w),f.push(_,b,w)}this.setIndex(f),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.widthSegments,t.heightSegments)}}class ln extends we{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new C,d=new C,f=[],p=[],v=[],g=[];for(let m=0;m<=n;m++){const S=[],E=m/n,_=a+E*o,b=t*Math.cos(_),w=Math.sqrt(t*t-b*b);let R=0;m===0&&a===0?R=.5/e:m===n&&c===Math.PI&&(R=-.5/e);for(let M=0;M<=e;M++){const A=M/e,P=i+A*r;u.x=-w*Math.cos(P),u.y=b,u.z=w*Math.sin(P),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),g.push(A+R,1-E),S.push(l++)}h.push(S)}for(let m=0;m<n;m++)for(let S=0;S<e;S++){const E=h[m][S+1],_=h[m][S],b=h[m+1][S],w=h[m+1][S+1];(m!==0||a>0)&&f.push(E,_,w),(m!==n-1||c<Math.PI)&&f.push(_,b,w)}this.setIndex(f),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ln(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Nr(s){const t={};for(const e in s){t[e]={};for(const n in s[e]){const i=s[e][n];if(y0(i))i.isRenderTargetTexture?(wt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(y0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();t[e][n]=r}else t[e][n]=i.slice();else t[e][n]=i}}return t}function un(s){const t={};for(let e=0;e<s.length;e++){const n=Nr(s[e]);for(const i in n)t[i]=n[i]}return t}function y0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function kv(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function Qp(s){const t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:jt.workingColorSpace}const Bv={clone:Nr,merge:un};var Hv=`void main() {
518
+ */const Au="185",c1=0,Ld=1,l1=2,da=1,h1=2,aa=3,us=0,ze=1,Zn=2,xi=0,Er=1,ti=2,Nd=3,Od=4,u1=5,Es=100,d1=101,f1=102,p1=103,m1=104,g1=200,v1=201,M1=202,x1=203,nh=204,ih=205,_1=206,y1=207,S1=208,b1=209,E1=210,w1=211,A1=212,T1=213,R1=214,sh=0,rh=1,ah=2,Pr=3,oh=4,ch=5,lh=6,hh=7,Tu=0,D1=1,C1=2,_i=0,Rp=1,Dp=2,Cp=3,Pp=4,Ip=5,Lp=6,Np=7,Ud="attached",P1="detached",Op=300,Os=301,Ir=302,zc=303,kc=304,Ec=306,Ea=1e3,gn=1001,uh=1002,We=1003,I1=1004,Ya=1005,ye=1006,Bc=1007,Ds=1008,In=1009,Up=1010,Fp=1011,wa=1012,Ru=1013,ei=1014,Gn=1015,cn=1016,Du=1017,Cu=1018,Aa=1020,zp=35902,kp=35899,Bp=1021,Hp=1022,vn=1023,ki=1026,Cs=1027,wc=1028,Pu=1029,Us=1030,Iu=1031,Lu=1033,Wo=33776,Xo=33777,qo=33778,Yo=33779,dh=35840,fh=35841,ph=35842,mh=35843,gh=36196,vh=37492,Mh=37496,xh=37488,_h=37489,nc=37490,yh=37491,Sh=37808,bh=37809,Eh=37810,wh=37811,Ah=37812,Th=37813,Rh=37814,Dh=37815,Ch=37816,Ph=37817,Ih=37818,Lh=37819,Nh=37820,Oh=37821,Uh=36492,Fh=36494,zh=36495,kh=36283,Bh=36284,ic=36285,Hh=36286,sc=2300,Gh=2301,Hc=2302,Fd=2303,zd=2400,kd=2401,Bd=2402,L1=2500,ow=0,cw=1,lw=2,N1=3200,rc=0,O1=1,as="",Pn="srgb",ac="srgb-linear",oc="linear",se="srgb",qs=7680,Hd=519,U1=512,F1=513,z1=514,Nu=515,k1=516,B1=517,Ou=518,H1=519,Vh=35044,Gd="300 es",vi=2e3,Ta=2001;function G1(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function V1(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function Ra(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function W1(){const s=Ra("canvas");return s.style.display="block",s}const Vd={};function cc(...s){const t="THREE."+s.shift();console.log(t,...s)}function Gp(s){const t=s[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=s[1];e&&e.isStackTrace?s[0]+=" "+e.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function wt(...s){s=Gp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...s)}}function zt(...s){s=Gp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...s)}}function wr(...s){const t=s.join(" ");t in Vd||(Vd[t]=!0,wt(...s))}function X1(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const q1={[sh]:rh,[ah]:lh,[oh]:hh,[Pr]:ch,[rh]:sh,[lh]:ah,[hh]:oh,[ch]:Pr};class Bs{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,t);t.target=null}}}const sn=["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 Wd=1234567;const fa=Math.PI/180,Lr=180/Math.PI;function Qn(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(sn[s&255]+sn[s>>8&255]+sn[s>>16&255]+sn[s>>24&255]+"-"+sn[t&255]+sn[t>>8&255]+"-"+sn[t>>16&15|64]+sn[t>>24&255]+"-"+sn[e&63|128]+sn[e>>8&255]+"-"+sn[e>>16&255]+sn[e>>24&255]+sn[n&255]+sn[n>>8&255]+sn[n>>16&255]+sn[n>>24&255]).toLowerCase()}function Kt(s,t,e){return Math.max(t,Math.min(e,s))}function Uu(s,t){return(s%t+t)%t}function Y1(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function K1(s,t,e){return s!==t?(e-s)/(t-s):0}function pa(s,t,e){return(1-e)*s+e*t}function $1(s,t,e,n){return pa(s,t,1-Math.exp(-e*n))}function Z1(s,t=1){return t-Math.abs(Uu(s,t*2)-t)}function J1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function j1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function Q1(s,t){return s+Math.floor(Math.random()*(t-s+1))}function tv(s,t){return s+Math.random()*(t-s)}function ev(s){return s*(.5-Math.random())}function nv(s){s!==void 0&&(Wd=s);let t=Wd+=1831565813;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}function iv(s){return s*fa}function sv(s){return s*Lr}function rv(s){return(s&s-1)===0&&s!==0}function av(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function ov(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function cv(s,t,e,n,i){const r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),p=a((n-t)/2);switch(i){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:wt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Jn(s,t){switch(t.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 re(s,t){switch(t.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 hw={DEG2RAD:fa,RAD2DEG:Lr,generateUUID:Qn,clamp:Kt,euclideanModulo:Uu,mapLinear:Y1,inverseLerp:K1,lerp:pa,damp:$1,pingpong:Z1,smoothstep:J1,smootherstep:j1,randInt:Q1,randFloat:tv,randFloatSpread:ev,seededRandom:nv,degToRad:iv,radToDeg:sv,isPowerOfTwo:rv,ceilPowerOfTwo:av,floorPowerOfTwo:ov,setQuaternionFromProperEuler:cv,normalize:re,denormalize:Jn};class Pt{static{Pt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Kt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class fs{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+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 g=c*d+l*f+h*p+u*v;g<0&&(d=-d,f=-f,p=-p,v=-v,g=-g);let m=1-o;if(g<.9995){const S=Math.acos(g),E=Math.sin(S);m=Math.sin(m*S)/E,o=Math.sin(o*S)/E,c=c*m+d*o,l=l*m+f*o,h=h*m+p*o,u=u*m+v*o}else{c=c*m+d*o,l=l*m+f*o,h=h*m+p*o,u=u*m+v*o;const S=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=S,l*=S,h*=S,u*=S}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],p=r[a+3];return t[e]=o*p+h*u+c*f-l*d,t[e+1]=c*p+h*d+l*u-o*f,t[e+2]=l*p+h*f+o*d-c*u,t[e+3]=h*p-o*u-c*d-l*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/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:wt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Kt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class C{static{C.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(Xd.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(Xd.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this.z=Kt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this.z=Kt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Gc.copy(this).projectOnVector(t),this.sub(Gc)}reflect(t){return this.sub(Gc.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Kt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Gc=new C,Xd=new fs;class kt{static{kt.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],p=n[8],v=i[0],g=i[3],m=i[6],S=i[1],E=i[4],_=i[7],b=i[2],w=i[5],R=i[8];return r[0]=a*v+o*S+c*b,r[3]=a*g+o*E+c*w,r[6]=a*m+o*_+c*R,r[1]=l*v+h*S+u*b,r[4]=l*g+h*E+u*w,r[7]=l*m+h*_+u*R,r[2]=d*v+f*S+p*b,r[5]=d*g+f*E+p*w,r[8]=d*m+f*_+p*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,p=e*u+n*d+i*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(i*l-h*n)*v,t[2]=(o*n-i*a)*v,t[3]=d*v,t[4]=(h*e-i*c)*v,t[5]=(i*r-o*e)*v,t[6]=f*v,t[7]=(n*c-l*e)*v,t[8]=(a*e-n*r)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return wr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Vc.makeScale(t,e)),this}rotate(t){return wr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Vc.makeRotation(-t)),this}translate(t,e){return wr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Vc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Vc=new kt,qd=new kt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Yd=new kt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function lv(){const s={enabled:!0,workingColorSpace:ac,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===se&&(i.r=Fi(i.r),i.g=Fi(i.g),i.b=Fi(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===se&&(i.r=Ar(i.r),i.g=Ar(i.g),i.b=Ar(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===as?oc:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return wr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return wr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[ac]:{primaries:t,whitePoint:n,transfer:oc,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Pn},outputColorSpaceConfig:{drawingBufferColorSpace:Pn}},[Pn]:{primaries:t,whitePoint:n,transfer:se,toXYZ:qd,fromXYZ:Yd,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Pn}}}),s}const jt=lv();function Fi(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function Ar(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let Ys;class hv{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{Ys===void 0&&(Ys=Ra("canvas")),Ys.width=t.width,Ys.height=t.height;const i=Ys.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=Ys}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=Ra("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Fi(r[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Fi(e[n]/255)*255):e[n]=Fi(e[n]);return{data:e,width:t.width,height:t.height}}else return wt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let uv=0;class Fu{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:uv++}),this.uuid=Qn(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Wc(i[a].image)):r.push(Wc(i[a]))}else r=Wc(i);n.url=r}return e||(t.images[this.uuid]=n),n}}function Wc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?hv.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(wt("Texture: Unable to serialize Texture."),{})}let dv=0;const Xc=new C;class en extends Bs{constructor(t=en.DEFAULT_IMAGE,e=en.DEFAULT_MAPPING,n=gn,i=gn,r=ye,a=Ds,o=vn,c=In,l=en.DEFAULT_ANISOTROPY,h=as){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:dv++}),this.uuid=Qn(),this.name="",this.source=new Fu(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Pt(0,0),this.repeat=new Pt(1,1),this.center=new Pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new kt,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(t&&t.depth&&t.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Xc).x}get height(){return this.source.getSize(Xc).y}get depth(){return this.source.getSize(Xc).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){wt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==Op)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Ea:t.x=t.x-Math.floor(t.x);break;case gn:t.x=t.x<0?0:1;break;case uh:Math.abs(Math.floor(t.x)%2)===1?t.x=Math.ceil(t.x)-t.x:t.x=t.x-Math.floor(t.x);break}if(t.y<0||t.y>1)switch(this.wrapT){case Ea:t.y=t.y-Math.floor(t.y);break;case gn:t.y=t.y<0?0:1;break;case uh:Math.abs(Math.floor(t.y)%2)===1?t.y=Math.ceil(t.y)-t.y:t.y=t.y-Math.floor(t.y);break}return this.flipY&&(t.y=1-t.y),t}set needsUpdate(t){t===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(t){t===!0&&this.pmremVersion++}}en.DEFAULT_IMAGE=null;en.DEFAULT_MAPPING=Op;en.DEFAULT_ANISOTROPY=1;class le{static{le.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],p=c[9],v=c[2],g=c[6],m=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-g)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+g)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const E=(l+1)/2,_=(f+1)/2,b=(m+1)/2,w=(h+d)/4,R=(u+v)/4,M=(p+g)/4;return E>_&&E>b?E<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(E),i=w/n,r=R/n):_>b?_<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(_),n=w/i,r=M/i):b<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(b),n=R/r,i=M/r),this.set(n,i,r,e),this}let S=Math.sqrt((g-p)*(g-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(S)<.001&&(S=1),this.x=(g-p)/S,this.y=(u-v)/S,this.z=(d-h)/S,this.w=Math.acos((l+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Kt(this.x,t.x,e.x),this.y=Kt(this.y,t.y,e.y),this.z=Kt(this.z,t.z,e.z),this.w=Kt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Kt(this.x,t,e),this.y=Kt(this.y,t,e),this.z=Kt(this.z,t,e),this.w=Kt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Kt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class fv extends Bs{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ye,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new le(0,0,t,e),this.scissorTest=!1,this.viewport=new le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new en(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:ye,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new Fu(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class wn extends fv{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Vp extends en{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=We,this.minFilter=We,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class Wp extends en{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=We,this.minFilter=We,this.wrapR=gn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Wt{static{Wt.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,p,v,g){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=p,m[11]=v,m[15]=g,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 Wt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Ks.setFromMatrixColumn(t,0).length(),r=1/Ks.setFromMatrixColumn(t,1).length(),a=1/Ks.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+p*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=p+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d+v*o,e[4]=p*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,p=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,p=o*h,v=o*u;e[0]=c*h,e[4]=p*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-p,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=p*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+p,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,p=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-p,e[2]=p*u-f,e[6]=o*h,e[10]=v*u+d}return e[3]=0,e[7]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromQuaternion(t){return this.compose(pv,t,mv)}lookAt(t,e,n){const i=this.elements;return Tn.subVectors(t,e),Tn.lengthSq()===0&&(Tn.z=1),Tn.normalize(),Ki.crossVectors(n,Tn),Ki.lengthSq()===0&&(Math.abs(n.z)===1?Tn.x+=1e-4:Tn.z+=1e-4,Tn.normalize(),Ki.crossVectors(n,Tn)),Ki.normalize(),Ka.crossVectors(Tn,Ki),i[0]=Ki.x,i[4]=Ka.x,i[8]=Tn.x,i[1]=Ki.y,i[5]=Ka.y,i[9]=Tn.y,i[2]=Ki.z,i[6]=Ka.z,i[10]=Tn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],p=n[2],v=n[6],g=n[10],m=n[14],S=n[3],E=n[7],_=n[11],b=n[15],w=i[0],R=i[4],M=i[8],A=i[12],P=i[1],D=i[5],I=i[9],F=i[13],H=i[2],O=i[6],V=i[10],k=i[14],Y=i[3],tt=i[7],J=i[11],nt=i[15];return r[0]=a*w+o*P+c*H+l*Y,r[4]=a*R+o*D+c*O+l*tt,r[8]=a*M+o*I+c*V+l*J,r[12]=a*A+o*F+c*k+l*nt,r[1]=h*w+u*P+d*H+f*Y,r[5]=h*R+u*D+d*O+f*tt,r[9]=h*M+u*I+d*V+f*J,r[13]=h*A+u*F+d*k+f*nt,r[2]=p*w+v*P+g*H+m*Y,r[6]=p*R+v*D+g*O+m*tt,r[10]=p*M+v*I+g*V+m*J,r[14]=p*A+v*F+g*k+m*nt,r[3]=S*w+E*P+_*H+b*Y,r[7]=S*R+E*D+_*O+b*tt,r[11]=S*M+E*I+_*V+b*J,r[15]=S*A+E*F+_*k+b*nt,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[4]*=t,e[8]*=t,e[12]*=t,e[1]*=t,e[5]*=t,e[9]*=t,e[13]*=t,e[2]*=t,e[6]*=t,e[10]*=t,e[14]*=t,e[3]*=t,e[7]*=t,e[11]*=t,e[15]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],p=t[3],v=t[7],g=t[11],m=t[15],S=c*f-l*d,E=o*f-l*u,_=o*d-c*u,b=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return e*(v*S-g*E+m*_)-n*(p*S-g*b+m*w)+i*(p*E-v*b+m*R)-r*(p*_-v*w+g*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],p=t[12],v=t[13],g=t[14],m=t[15],S=e*o-n*a,E=e*c-i*a,_=e*l-r*a,b=n*c-i*o,w=n*l-r*o,R=i*l-r*c,M=h*v-u*p,A=h*g-d*p,P=h*m-f*p,D=u*g-d*v,I=u*m-f*v,F=d*m-f*g,H=S*F-E*I+_*D+b*P-w*A+R*M;if(H===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/H;return t[0]=(o*F-c*I+l*D)*O,t[1]=(i*I-n*F-r*D)*O,t[2]=(v*R-g*w+m*b)*O,t[3]=(d*w-u*R-f*b)*O,t[4]=(c*P-a*F-l*A)*O,t[5]=(e*F-i*P+r*A)*O,t[6]=(g*_-p*R-m*E)*O,t[7]=(h*R-d*_+f*E)*O,t[8]=(a*I-o*P+l*M)*O,t[9]=(n*P-e*I-r*M)*O,t[10]=(p*w-v*_+m*S)*O,t[11]=(u*_-h*w-f*S)*O,t[12]=(o*A-a*D-c*M)*O,t[13]=(e*D-n*A+i*M)*O,t[14]=(v*E-p*b-g*S)*O,t[15]=(h*b-u*E+d*S)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,p=r*u,v=a*h,g=a*u,m=o*u,S=c*l,E=c*h,_=c*u,b=n.x,w=n.y,R=n.z;return i[0]=(1-(v+m))*b,i[1]=(f+_)*b,i[2]=(p-E)*b,i[3]=0,i[4]=(f-_)*w,i[5]=(1-(d+m))*w,i[6]=(g+S)*w,i[7]=0,i[8]=(p+E)*R,i[9]=(g-S)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=Ks.set(i[0],i[1],i[2]).length();const o=Ks.set(i[4],i[5],i[6]).length(),c=Ks.set(i[8],i[9],i[10]).length();r<0&&(a=-a),Wn.copy(this);const l=1/a,h=1/o,u=1/c;return Wn.elements[0]*=l,Wn.elements[1]*=l,Wn.elements[2]*=l,Wn.elements[4]*=h,Wn.elements[5]*=h,Wn.elements[6]*=h,Wn.elements[8]*=u,Wn.elements[9]*=u,Wn.elements[10]*=u,e.setFromRotationMatrix(Wn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,i,r,a,o=vi,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let p,v;if(c)p=r/(a-r),v=a*r/(a-r);else if(o===vi)p=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===Ta)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(t,e,n,i,r,a,o=vi,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let p,v;if(c)p=1/(a-r),v=a/(a-r);else if(o===vi)p=-2/(a-r),v=-(a+r)/(a-r);else if(o===Ta)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(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Ks=new C,Wn=new Wt,pv=new C(0,0,0),mv=new C(1,1,1),Ki=new C,Ka=new C,Tn=new C,Kd=new Wt,$d=new fs;class Bi{constructor(t=0,e=0,n=0,i=Bi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Kt(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(-Kt(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(Kt(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(-Kt(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(Kt(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(-Kt(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:wt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Kd.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Kd,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return $d.setFromEuler(this),this.setFromQuaternion($d,t)}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._order===this._order}fromArray(t){return this._x=t[0],this._y=t[1],this._z=t[2],t[3]!==void 0&&(this._order=t[3]),this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._order,t}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}Bi.DEFAULT_ORDER="XYZ";class zu{constructor(){this.mask=1}set(t){this.mask=(1<<t|0)>>>0}enable(t){this.mask|=1<<t|0}enableAll(){this.mask=-1}toggle(t){this.mask^=1<<t|0}disable(t){this.mask&=~(1<<t|0)}disableAll(){this.mask=0}test(t){return(this.mask&t.mask)!==0}isEnabled(t){return(this.mask&(1<<t|0))!==0}}let gv=0;const Zd=new C,$s=new fs,bi=new Wt,$a=new C,Hr=new C,vv=new C,Mv=new fs,Jd=new C(1,0,0),jd=new C(0,1,0),Qd=new C(0,0,1),t0={type:"added"},xv={type:"removed"},Zs={type:"childadded",child:null},qc={type:"childremoved",child:null};class Se extends Bs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:gv++}),this.uuid=Qn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Se.DEFAULT_UP.clone();const t=new C,e=new Bi,n=new fs,i=new C(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Wt},normalMatrix:{value:new kt}}),this.matrix=new Wt,this.matrixWorld=new Wt,this.matrixAutoUpdate=Se.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new zu,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(t){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(t),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(t){return this.quaternion.premultiply(t),this}setRotationFromAxisAngle(t,e){this.quaternion.setFromAxisAngle(t,e)}setRotationFromEuler(t){this.quaternion.setFromEuler(t,!0)}setRotationFromMatrix(t){this.quaternion.setFromRotationMatrix(t)}setRotationFromQuaternion(t){this.quaternion.copy(t)}rotateOnAxis(t,e){return $s.setFromAxisAngle(t,e),this.quaternion.multiply($s),this}rotateOnWorldAxis(t,e){return $s.setFromAxisAngle(t,e),this.quaternion.premultiply($s),this}rotateX(t){return this.rotateOnAxis(Jd,t)}rotateY(t){return this.rotateOnAxis(jd,t)}rotateZ(t){return this.rotateOnAxis(Qd,t)}translateOnAxis(t,e){return Zd.copy(t).applyQuaternion(this.quaternion),this.position.add(Zd.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Jd,t)}translateY(t){return this.translateOnAxis(jd,t)}translateZ(t){return this.translateOnAxis(Qd,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(bi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?$a.copy(t):$a.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Hr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?bi.lookAt(Hr,$a,this.up):bi.lookAt($a,Hr,this.up),this.quaternion.setFromRotationMatrix(bi),i&&(bi.extractRotation(i.matrixWorld),$s.setFromRotationMatrix(bi),this.quaternion.premultiply($s.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(zt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(t0),Zs.child=t,this.dispatchEvent(Zs),Zs.child=null):zt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(xv),qc.child=t,this.dispatchEvent(qc),qc.child=null),this}removeFromParent(){const t=this.parent;return t!==null&&t.remove(this),this}clear(){return this.remove(...this.children)}attach(t){return this.updateWorldMatrix(!0,!1),bi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),bi.multiply(t.parent.matrixWorld)),t.applyMatrix4(bi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(t0),Zs.child=t,this.dispatchEvent(Zs),Zs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,t,vv),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Hr,Mv,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));i.material=o}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),p=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),p.length>0&&(n.nodes=p)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}Se.DEFAULT_UP=new C(0,1,0);Se.DEFAULT_MATRIX_AUTO_UPDATE=!0;Se.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class on extends Se{constructor(){super(),this.isGroup=!0,this.type="Group"}}const _v={type:"move"};class Yc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new on,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 on,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new C,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new C),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new on,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new C,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new C,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const g=e.getJointPose(v,n),m=this._getHandJoint(l,v);g!==null&&(m.matrix.fromArray(g.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=g.radius),m.visible=g!==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:t.handedness,target:this})):!l.inputState.pinching&&d<=f-p&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(_v)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new on;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const Xp={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},$i={h:0,s:0,l:0},Za={h:0,s:0,l:0};function Kc(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}class ct{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Pn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,jt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=jt.workingColorSpace){return this.r=t,this.g=e,this.b=n,jt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=jt.workingColorSpace){if(t=Uu(t,1),e=Kt(e,0,1),n=Kt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Kc(a,r,t+1/3),this.g=Kc(a,r,t),this.b=Kc(a,r,t-1/3)}return jt.colorSpaceToWorking(this,i),this}setStyle(t,e=Pn){function n(r){r!==void 0&&parseFloat(r)<1&&wt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:wt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);wt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Pn){const n=Xp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):wt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Fi(t.r),this.g=Fi(t.g),this.b=Fi(t.b),this}copyLinearToSRGB(t){return this.r=Ar(t.r),this.g=Ar(t.g),this.b=Ar(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Pn){return jt.workingToColorSpace(rn.copy(this),t),Math.round(Kt(rn.r*255,0,255))*65536+Math.round(Kt(rn.g*255,0,255))*256+Math.round(Kt(rn.b*255,0,255))}getHexString(t=Pn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=jt.workingColorSpace){jt.workingToColorSpace(rn.copy(this),e);const n=rn.r,i=rn.g,r=rn.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=jt.workingColorSpace){return jt.workingToColorSpace(rn.copy(this),e),t.r=rn.r,t.g=rn.g,t.b=rn.b,t}getStyle(t=Pn){jt.workingToColorSpace(rn.copy(this),t);const e=rn.r,n=rn.g,i=rn.b;return t!==Pn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL($i),this.setHSL($i.h+t,$i.s+e,$i.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL($i),t.getHSL(Za);const n=pa($i.h,Za.h,e),i=pa($i.s,Za.s,e),r=pa($i.l,Za.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const rn=new ct;ct.NAMES=Xp;class lc{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new ct(t),this.near=e,this.far=n}clone(){return new lc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Da extends Se{constructor(){super(),this.isScene=!0,this.type="Scene",this.background=null,this.environment=null,this.fog=null,this.backgroundBlurriness=0,this.backgroundIntensity=1,this.backgroundRotation=new Bi,this.environmentIntensity=1,this.environmentRotation=new Bi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(t,e){return super.copy(t,e),t.background!==null&&(this.background=t.background.clone()),t.environment!==null&&(this.environment=t.environment.clone()),t.fog!==null&&(this.fog=t.fog.clone()),this.backgroundBlurriness=t.backgroundBlurriness,this.backgroundIntensity=t.backgroundIntensity,this.backgroundRotation.copy(t.backgroundRotation),this.environmentIntensity=t.environmentIntensity,this.environmentRotation.copy(t.environmentRotation),t.overrideMaterial!==null&&(this.overrideMaterial=t.overrideMaterial.clone()),this.matrixAutoUpdate=t.matrixAutoUpdate,this}toJSON(t){const e=super.toJSON(t);return this.fog!==null&&(e.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(e.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(e.object.backgroundIntensity=this.backgroundIntensity),e.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(e.object.environmentIntensity=this.environmentIntensity),e.object.environmentRotation=this.environmentRotation.toArray(),e}}const Xn=new C,Ei=new C,$c=new C,wi=new C,Js=new C,js=new C,e0=new C,Zc=new C,Jc=new C,jc=new C,Qc=new le,tl=new le,el=new le;class Hn{constructor(t=new C,e=new C,n=new C){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Xn.subVectors(t,e),i.cross(Xn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Xn.subVectors(i,e),Ei.subVectors(n,e),$c.subVectors(t,e);const a=Xn.dot(Xn),o=Xn.dot(Ei),c=Xn.dot($c),l=Ei.dot(Ei),h=Ei.dot($c),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(t,e,n,i){return this.getBarycoord(t,e,n,i,wi)===null?!1:wi.x>=0&&wi.y>=0&&wi.x+wi.y<=1}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,wi)===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,wi.x),c.addScaledVector(a,wi.y),c.addScaledVector(o,wi.z),c)}static getInterpolatedAttribute(t,e,n,i,r,a){return Qc.setScalar(0),tl.setScalar(0),el.setScalar(0),Qc.fromBufferAttribute(t,e),tl.fromBufferAttribute(t,n),el.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Qc,r.x),a.addScaledVector(tl,r.y),a.addScaledVector(el,r.z),a}static isFrontFacing(t,e,n,i){return Xn.subVectors(n,e),Ei.subVectors(t,e),Xn.cross(Ei).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Xn.subVectors(this.c,this.b),Ei.subVectors(this.a,this.b),Xn.cross(Ei).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Hn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Hn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Hn.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Hn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Hn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;Js.subVectors(i,n),js.subVectors(r,n),Zc.subVectors(t,n);const c=Js.dot(Zc),l=js.dot(Zc);if(c<=0&&l<=0)return e.copy(n);Jc.subVectors(t,i);const h=Js.dot(Jc),u=js.dot(Jc);if(h>=0&&u<=h)return e.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(Js,a);jc.subVectors(t,r);const f=Js.dot(jc),p=js.dot(jc);if(p>=0&&f<=p)return e.copy(r);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(n).addScaledVector(js,o);const g=h*p-f*u;if(g<=0&&u-h>=0&&f-p>=0)return e0.subVectors(r,i),o=(u-h)/(u-h+(f-p)),e.copy(i).addScaledVector(e0,o);const m=1/(g+v+d);return a=v*m,o=d*m,e.copy(n).addScaledVector(Js,a).addScaledVector(js,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class ni{constructor(t=new C(1/0,1/0,1/0),e=new C(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(qn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(qn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=qn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,qn):qn.fromBufferAttribute(r,a),qn.applyMatrix4(t.matrixWorld),this.expandByPoint(qn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),Ja.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Ja.copy(n.boundingBox)),Ja.applyMatrix4(t.matrixWorld),this.union(Ja)}const i=t.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,qn),qn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Gr),ja.subVectors(this.max,Gr),Qs.subVectors(t.a,Gr),tr.subVectors(t.b,Gr),er.subVectors(t.c,Gr),Zi.subVectors(tr,Qs),Ji.subVectors(er,tr),ms.subVectors(Qs,er);let e=[0,-Zi.z,Zi.y,0,-Ji.z,Ji.y,0,-ms.z,ms.y,Zi.z,0,-Zi.x,Ji.z,0,-Ji.x,ms.z,0,-ms.x,-Zi.y,Zi.x,0,-Ji.y,Ji.x,0,-ms.y,ms.x,0];return!nl(e,Qs,tr,er,ja)||(e=[1,0,0,0,1,0,0,0,1],!nl(e,Qs,tr,er,ja))?!1:(Qa.crossVectors(Zi,Ji),e=[Qa.x,Qa.y,Qa.z],nl(e,Qs,tr,er,ja))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,qn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(qn).length()*.5),t}intersect(t){return this.min.max(t.min),this.max.min(t.max),this.isEmpty()&&this.makeEmpty(),this}union(t){return this.min.min(t.min),this.max.max(t.max),this}applyMatrix4(t){return this.isEmpty()?this:(Ai[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Ai[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Ai[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Ai[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Ai[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Ai[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Ai[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Ai[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Ai),this)}translate(t){return this.min.add(t),this.max.add(t),this}equals(t){return t.min.equals(this.min)&&t.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(t){return this.min.fromArray(t.min),this.max.fromArray(t.max),this}}const Ai=[new C,new C,new C,new C,new C,new C,new C,new C],qn=new C,Ja=new ni,Qs=new C,tr=new C,er=new C,Zi=new C,Ji=new C,ms=new C,Gr=new C,ja=new C,Qa=new C,gs=new C;function nl(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){gs.fromArray(s,r);const o=i.x*Math.abs(gs.x)+i.y*Math.abs(gs.y)+i.z*Math.abs(gs.z),c=t.dot(gs),l=e.dot(gs),h=n.dot(gs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Li=yv();function yv(){const s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Sv(s){Math.abs(s)>65504&&wt("DataUtils.toHalfFloat(): Value out of range."),s=Kt(s,-65504,65504),Li.floatView[0]=s;const t=Li.uint32View[0],e=t>>23&511;return Li.baseTable[e]+((t&8388607)>>Li.shiftTable[e])}function bv(s){const t=s>>10;return Li.uint32View[0]=Li.mantissaTable[Li.offsetTable[t]+(s&1023)]+Li.exponentTable[t],Li.floatView[0]}class ls{static toHalfFloat(t){return Sv(t)}static fromHalfFloat(t){return bv(t)}}const He=new C,to=new Pt;let Ev=0;class de extends Bs{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Ev++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=Vh,this.updateRanges=[],this.gpuType=Gn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)to.fromBufferAttribute(this,e),to.applyMatrix3(t),this.setXY(e,to.x,to.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyMatrix3(t),this.setXYZ(e,He.x,He.y,He.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyMatrix4(t),this.setXYZ(e,He.x,He.y,He.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.applyNormalMatrix(t),this.setXYZ(e,He.x,He.y,He.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)He.fromBufferAttribute(this,e),He.transformDirection(t),this.setXYZ(e,He.x,He.y,He.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Jn(e,this.array)),e}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Jn(e,this.array)),e}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Jn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Jn(e,this.array)),e}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==Vh&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class qp extends de{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class ku extends de{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Ee extends de{constructor(t,e,n){super(new Float32Array(t),e,n)}}const wv=new ni,Vr=new C,il=new C;class Hi{constructor(t=new C,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):wv.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;r<a;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Vr.subVectors(t,this.center);const e=Vr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Vr,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(il.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Vr.copy(t.center).add(il)),this.expandByPoint(Vr.copy(t.center).sub(il))),this)}equals(t){return t.center.equals(this.center)&&t.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(t){return this.radius=t.radius,this.center.fromArray(t.center),this}}let Av=0;const On=new Wt,sl=new Se,nr=new C,Rn=new ni,Wr=new ni,Ye=new C;class we extends Bs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:Av++}),this.uuid=Qn(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(t){return Array.isArray(t)?this.index=new(G1(t)?ku:qp)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new kt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return On.makeRotationFromQuaternion(t),this.applyMatrix4(On),this}rotateX(t){return On.makeRotationX(t),this.applyMatrix4(On),this}rotateY(t){return On.makeRotationY(t),this.applyMatrix4(On),this}rotateZ(t){return On.makeRotationZ(t),this.applyMatrix4(On),this}translate(t,e,n){return On.makeTranslation(t,e,n),this.applyMatrix4(On),this}scale(t,e,n){return On.makeScale(t,e,n),this.applyMatrix4(On),this}lookAt(t){return sl.lookAt(t),sl.updateMatrix(),this.applyMatrix4(sl.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(nr).negate(),this.translate(nr.x,nr.y,nr.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,r=t.length;i<r;i++){const a=t[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Ee(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&wt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ni);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new C(-1/0,-1/0,-1/0),new C(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const r=e[n];Rn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ye.addVectors(this.boundingBox.min,Rn.min),this.boundingBox.expandByPoint(Ye),Ye.addVectors(this.boundingBox.max,Rn.max),this.boundingBox.expandByPoint(Ye)):(this.boundingBox.expandByPoint(Rn.min),this.boundingBox.expandByPoint(Rn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zt('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 Hi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new C,1/0);return}if(t){const n=this.boundingSphere.center;if(Rn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];Wr.setFromBufferAttribute(o),this.morphTargetsRelative?(Ye.addVectors(Rn.min,Wr.min),Rn.expandByPoint(Ye),Ye.addVectors(Rn.max,Wr.max),Rn.expandByPoint(Ye)):(Rn.expandByPoint(Wr.min),Rn.expandByPoint(Wr.max))}Rn.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)Ye.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(Ye));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)Ye.fromBufferAttribute(o,l),c&&(nr.fromBufferAttribute(t,l),Ye.add(nr)),i=Math.max(i,n.distanceToSquared(Ye))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){zt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new de(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let M=0;M<n.count;M++)o[M]=new C,c[M]=new C;const l=new C,h=new C,u=new C,d=new Pt,f=new Pt,p=new Pt,v=new C,g=new C;function m(M,A,P){l.fromBufferAttribute(n,M),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,P),d.fromBufferAttribute(r,M),f.fromBufferAttribute(r,A),p.fromBufferAttribute(r,P),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const D=1/(f.x*p.y-p.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(D),g.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(D),o[M].add(v),o[A].add(v),o[P].add(v),c[M].add(g),c[A].add(g),c[P].add(g))}let S=this.groups;S.length===0&&(S=[{start:0,count:t.count}]);for(let M=0,A=S.length;M<A;++M){const P=S[M],D=P.start,I=P.count;for(let F=D,H=D+I;F<H;F+=3)m(t.getX(F+0),t.getX(F+1),t.getX(F+2))}const E=new C,_=new C,b=new C,w=new C;function R(M){b.fromBufferAttribute(i,M),w.copy(b);const A=o[M];E.copy(A),E.sub(b.multiplyScalar(b.dot(A))).normalize(),_.crossVectors(w,A);const D=_.dot(c[M])<0?-1:1;a.setXYZW(M,E.x,E.y,E.z,D)}for(let M=0,A=S.length;M<A;++M){const P=S[M],D=P.start,I=P.count;for(let F=D,H=D+I;F<H;F+=3)R(t.getX(F+0)),R(t.getX(F+1)),R(t.getX(F+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new de(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new C,r=new C,a=new C,o=new C,c=new C,l=new C,h=new C,u=new C;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),g=t.getX(d+2);i.fromBufferAttribute(e,p),r.fromBufferAttribute(e,v),a.fromBufferAttribute(e,g),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,p),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,g),o.add(h),c.add(h),l.add(h),n.setXYZ(p,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(g,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)Ye.fromBufferAttribute(t,e),Ye.normalize(),t.setXYZ(e,Ye.x,Ye.y,Ye.z)}toNonIndexed(){function t(o,c){const l=o.array,h=o.itemSize,u=o.normalized,d=new l.constructor(c.length*h);let f=0,p=0;for(let v=0,g=c.length;v<g;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let m=0;m<h;m++)d[p++]=l[f++]}return new de(d,h,u)}if(this.index===null)return wt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new we,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,n);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Tv{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Vh,this.updateRanges=[],this.version=0,this.uuid=Qn()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Qn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=Qn()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const hn=new C;class hc{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.applyMatrix4(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.applyNormalMatrix(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)hn.fromBufferAttribute(this,e),hn.transformDirection(t),this.setXYZ(e,hn.x,hn.y,hn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Jn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Jn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Jn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Jn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Jn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){cc("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new de(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new hc(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){cc("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Rv=0;class Gi extends Bs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Rv++}),this.uuid=Qn(),this.name="",this.type="Material",this.blending=Er,this.side=us,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=nh,this.blendDst=ih,this.blendEquation=Es,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new ct(0,0,0),this.blendAlpha=0,this.depthFunc=Pr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Hd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=qs,this.stencilZFail=qs,this.stencilZPass=qs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){wt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==Er&&(n.blending=this.blending),this.side!==us&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==nh&&(n.blendSrc=this.blendSrc),this.blendDst!==ih&&(n.blendDst=this.blendDst),this.blendEquation!==Es&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==Pr&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Hd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==qs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==qs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==qs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new ct().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Pt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Pt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class oa extends Gi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new ct(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.rotation=t.rotation,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}let ir;const Xr=new C,sr=new C,rr=new C,ar=new Pt,qr=new Pt,Yp=new Wt,eo=new C,Yr=new C,no=new C,n0=new Pt,rl=new Pt,i0=new Pt;class or extends Se{constructor(t=new oa){if(super(),this.isSprite=!0,this.type="Sprite",ir===void 0){ir=new we;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Tv(e,5);ir.setIndex([0,1,2,0,2,3]),ir.setAttribute("position",new hc(n,3,0,!1)),ir.setAttribute("uv",new hc(n,2,3,!1))}this.geometry=ir,this.material=t,this.center=new Pt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&zt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),sr.setFromMatrixScale(this.matrixWorld),Yp.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),rr.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&sr.multiplyScalar(-rr.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;io(eo.set(-.5,-.5,0),rr,a,sr,i,r),io(Yr.set(.5,-.5,0),rr,a,sr,i,r),io(no.set(.5,.5,0),rr,a,sr,i,r),n0.set(0,0),rl.set(1,0),i0.set(1,1);let o=t.ray.intersectTriangle(eo,Yr,no,!1,Xr);if(o===null&&(io(Yr.set(-.5,.5,0),rr,a,sr,i,r),rl.set(0,1),o=t.ray.intersectTriangle(eo,no,Yr,!1,Xr),o===null))return;const c=t.ray.origin.distanceTo(Xr);c<t.near||c>t.far||e.push({distance:c,point:Xr.clone(),uv:Hn.getInterpolation(Xr,eo,Yr,no,n0,rl,i0,new Pt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function io(s,t,e,n,i,r){ar.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(qr.x=r*ar.x-i*ar.y,qr.y=i*ar.x+r*ar.y):qr.copy(ar),s.copy(t),s.x+=qr.x,s.y+=qr.y,s.applyMatrix4(Yp)}const Ti=new C,al=new C,so=new C,ji=new C,ol=new C,ro=new C,cl=new C;class Pa{constructor(t=new C,e=new C(0,0,-1)){this.origin=t,this.direction=e}set(t,e){return this.origin.copy(t),this.direction.copy(e),this}copy(t){return this.origin.copy(t.origin),this.direction.copy(t.direction),this}at(t,e){return e.copy(this.origin).addScaledVector(this.direction,t)}lookAt(t){return this.direction.copy(t).sub(this.origin).normalize(),this}recast(t){return this.origin.copy(this.at(t,Ti)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ti.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ti.copy(this.origin).addScaledVector(this.direction,e),Ti.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){al.copy(t).add(e).multiplyScalar(.5),so.copy(e).sub(t).normalize(),ji.copy(this.origin).sub(al);const r=t.distanceTo(e)*.5,a=-this.direction.dot(so),o=ji.dot(this.direction),c=-ji.dot(so),l=ji.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 n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(al).addScaledVector(so,d),f}intersectSphere(t,e){Ti.subVectors(t.center,this.origin);const n=Ti.dot(this.direction),i=Ti.dot(Ti)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ti)!==null}intersectTriangle(t,e,n,i,r){ol.subVectors(e,t),ro.subVectors(n,t),cl.crossVectors(ol,ro);let a=this.direction.dot(cl),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;ji.subVectors(this.origin,t);const c=o*this.direction.dot(ro.crossVectors(ji,ro));if(c<0)return null;const l=o*this.direction.dot(ol.cross(ji));if(l<0||c+l>a)return null;const h=-o*ji.dot(cl);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class zi extends Gi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Tu,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.fog=t.fog,this}}const s0=new Wt,vs=new Pa,ao=new Hi,r0=new C,oo=new C,co=new C,lo=new C,ll=new C,ho=new C,a0=new C,uo=new C;class qt extends Se{constructor(t=new we,e=new zi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){ho.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(ll.fromBufferAttribute(u,t),a?ho.addScaledVector(ll,h):ho.addScaledVector(ll.sub(e),h))}e.add(ho)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),ao.copy(n.boundingSphere),ao.applyMatrix4(r),vs.copy(t.ray).recast(t.near),!(ao.containsPoint(vs.origin)===!1&&(vs.intersectSphere(ao,r0)===null||vs.origin.distanceToSquared(r0)>(t.far-t.near)**2))&&(s0.copy(r).invert(),vs.copy(t.ray).applyMatrix4(s0),!(n.boundingBox!==null&&vs.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,vs)))}_computeIntersections(t,e,n){let i;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 g=d[p],m=a[g.materialIndex],S=Math.max(g.start,f.start),E=Math.min(o.count,Math.min(g.start+g.count,f.start+f.count));for(let _=S,b=E;_<b;_+=3){const w=o.getX(_),R=o.getX(_+1),M=o.getX(_+2);i=fo(this,m,t,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let g=p,m=v;g<m;g+=3){const S=o.getX(g),E=o.getX(g+1),_=o.getX(g+2);i=fo(this,a,t,n,l,h,u,S,E,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let p=0,v=d.length;p<v;p++){const g=d[p],m=a[g.materialIndex],S=Math.max(g.start,f.start),E=Math.min(c.count,Math.min(g.start+g.count,f.start+f.count));for(let _=S,b=E;_<b;_+=3){const w=_,R=_+1,M=_+2;i=fo(this,m,t,n,l,h,u,w,R,M),i&&(i.faceIndex=Math.floor(_/3),i.face.materialIndex=g.materialIndex,e.push(i))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let g=p,m=v;g<m;g+=3){const S=g,E=g+1,_=g+2;i=fo(this,a,t,n,l,h,u,S,E,_),i&&(i.faceIndex=Math.floor(g/3),e.push(i))}}}}function Dv(s,t,e,n,i,r,a,o){let c;if(t.side===ze?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,t.side===us,o),c===null)return null;uo.copy(o),uo.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(uo);return l<e.near||l>e.far?null:{distance:l,point:uo.clone(),object:s}}function fo(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,oo),s.getVertexPosition(c,co),s.getVertexPosition(l,lo);const h=Dv(s,t,e,n,oo,co,lo,a0);if(h){const u=new C;Hn.getBarycoord(a0,oo,co,lo,u),i&&(h.uv=Hn.getInterpolatedAttribute(i,o,c,l,u,new Pt)),r&&(h.uv1=Hn.getInterpolatedAttribute(r,o,c,l,u,new Pt)),a&&(h.normal=Hn.getInterpolatedAttribute(a,o,c,l,u,new C),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new C,materialIndex:0};Hn.getNormal(oo,co,lo,d.normal),h.face=d,h.barycoord=u}return h}const Kr=new le,o0=new le,c0=new le,Cv=new le,l0=new Wt,po=new C,hl=new Hi,h0=new Wt,ul=new Pa;class uw extends qt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=Ud,this.bindMatrix=new Wt,this.bindMatrixInverse=new Wt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new ni),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,po),this.boundingBox.expandByPoint(po)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new Hi),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,po),this.boundingSphere.expandByPoint(po)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),hl.copy(this.boundingSphere),hl.applyMatrix4(i),t.ray.intersectsSphere(hl)!==!1&&(h0.copy(i).invert(),ul.copy(t.ray).applyMatrix4(h0),!(this.boundingBox!==null&&ul.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,ul)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===Ud?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===P1?this.bindMatrixInverse.copy(this.bindMatrix).invert():wt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;o0.fromBufferAttribute(i.attributes.skinIndex,t),c0.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(Kr.copy(e),e.set(0,0,0,0)):(Kr.set(...e,1),e.set(0,0,0)),Kr.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=c0.getComponent(r);if(a!==0){const o=o0.getComponent(r);l0.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(Cv.copy(Kr).applyMatrix4(l0),a)}}return e.isVector4&&(e.w=Kr.w),e.applyMatrix4(this.bindMatrixInverse)}}class Pv extends Se{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Ur extends en{constructor(t=null,e=1,n=1,i,r,a,o,c,l=We,h=We,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const u0=new Wt,Iv=new Wt;class Kp{constructor(t=[],e=[]){this.uuid=Qn(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){wt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Wt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Wt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=t.length;r<a;r++){const o=t[r]?t[r].matrixWorld:Iv;u0.multiplyMatrices(o,e[r]),u0.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Kp(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Ur(e,t,t,vn,Gn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const r=t.bones[n];let a=e[r];a===void 0&&(wt("Skeleton: No bone found with UUID:",r),a=new Pv),this.bones.push(a),this.boneInverses.push(new Wt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const a=e[i];t.bones.push(a.uuid);const o=n[i];t.boneInverses.push(o.toArray())}return t}}class d0 extends de{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const cr=new Wt,f0=new Wt,mo=[],p0=new ni,Lv=new Wt,$r=new qt,Zr=new Hi;class dw extends qt{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new d0(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,Lv)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new ni),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,cr),p0.copy(t.boundingBox).applyMatrix4(cr),this.boundingBox.union(p0)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new Hi),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,cr),Zr.copy(t.boundingSphere).applyMatrix4(cr),this.boundingSphere.union(Zr)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=t*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){const n=this.matrixWorld,i=this.count;if($r.geometry=this.geometry,$r.material=this.material,$r.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Zr.copy(this.boundingSphere),Zr.applyMatrix4(n),t.ray.intersectsSphere(Zr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,cr),f0.multiplyMatrices(n,cr),$r.matrixWorld=f0,$r.raycast(t,mo);for(let a=0,o=mo.length;a<o;a++){const c=mo[a];c.instanceId=r,c.object=this,e.push(c)}mo.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new d0(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Ur(new Float32Array(i*this.count),i,this.count,wc,Gn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*t;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const dl=new C,Nv=new C,Ov=new kt;class Ss{constructor(t=new C(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=dl.subVectors(n,e).cross(Nv.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(dl),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||Ov.getNormalMatrix(t),i=this.coplanarPoint(dl).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ms=new Hi,Uv=new Pt(.5,.5),go=new C;class Bu{constructor(t=new Ss,e=new Ss,n=new Ss,i=new Ss,r=new Ss,a=new Ss){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=vi,n=!1){const i=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],p=r[8],v=r[9],g=r[10],m=r[11],S=r[12],E=r[13],_=r[14],b=r[15];if(i[0].setComponents(l-a,f-h,m-p,b-S).normalize(),i[1].setComponents(l+a,f+h,m+p,b+S).normalize(),i[2].setComponents(l+o,f+u,m+v,b+E).normalize(),i[3].setComponents(l-o,f-u,m-v,b-E).normalize(),n)i[4].setComponents(c,d,g,_).normalize(),i[5].setComponents(l-c,f-d,m-g,b-_).normalize();else if(i[4].setComponents(l-c,f-d,m-g,b-_).normalize(),e===vi)i[5].setComponents(l+c,f+d,m+g,b+_).normalize();else if(e===Ta)i[5].setComponents(c,d,g,_).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Ms.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Ms.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Ms)}intersectsSprite(t){Ms.center.set(0,0,0);const e=Uv.distanceTo(t.center);return Ms.radius=.7071067811865476+e,Ms.applyMatrix4(t.matrixWorld),this.intersectsSphere(Ms)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(go.x=i.normal.x>0?t.max.x:t.min.x,go.y=i.normal.y>0?t.max.y:t.min.y,go.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(go)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Fv extends Gi{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new ct(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.linewidth=t.linewidth,this.linecap=t.linecap,this.linejoin=t.linejoin,this.fog=t.fog,this}}const uc=new C,dc=new C,m0=new Wt,Jr=new Pa,vo=new Hi,fl=new C,g0=new C;class $p extends Se{constructor(t=new we,e=new Fv){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)uc.fromBufferAttribute(e,i-1),dc.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=uc.distanceTo(dc);t.setAttribute("lineDistance",new Ee(n,1))}else wt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),vo.copy(n.boundingSphere),vo.applyMatrix4(i),vo.radius+=r,t.ray.intersectsSphere(vo)===!1)return;m0.copy(i).invert(),Jr.copy(t.ray).applyMatrix4(m0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),p=Math.min(h.count,a.start+a.count);for(let v=f,g=p-1;v<g;v+=l){const m=h.getX(v),S=h.getX(v+1),E=Mo(this,t,Jr,c,m,S,v);E&&e.push(E)}if(this.isLineLoop){const v=h.getX(p-1),g=h.getX(f),m=Mo(this,t,Jr,c,v,g,p-1);m&&e.push(m)}}else{const f=Math.max(0,a.start),p=Math.min(d.count,a.start+a.count);for(let v=f,g=p-1;v<g;v+=l){const m=Mo(this,t,Jr,c,v,v+1,v);m&&e.push(m)}if(this.isLineLoop){const v=Mo(this,t,Jr,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Mo(s,t,e,n,i,r,a){const o=s.geometry.attributes.position;if(uc.fromBufferAttribute(o,i),dc.fromBufferAttribute(o,r),e.distanceSqToSegment(uc,dc,fl,g0)>n)return;fl.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(fl);if(!(l<t.near||l>t.far))return{distance:l,point:g0.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const v0=new C,M0=new C;class fw extends $p{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)v0.fromBufferAttribute(e,i),M0.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+v0.distanceTo(M0);t.setAttribute("lineDistance",new Ee(n,1))}else wt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class pw extends $p{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Zp extends Gi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new ct(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.alphaMap=t.alphaMap,this.size=t.size,this.sizeAttenuation=t.sizeAttenuation,this.fog=t.fog,this}}const x0=new Wt,Wh=new Pa,xo=new Hi,_o=new C;class Ko extends Se{constructor(t=new we,e=new Zp){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),xo.copy(n.boundingSphere),xo.applyMatrix4(i),xo.radius+=r,t.ray.intersectsSphere(xo)===!1)return;x0.copy(i).invert(),Wh.copy(t.ray).applyMatrix4(x0);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let p=d,v=f;p<v;p++){const g=l.getX(p);_o.fromBufferAttribute(u,g),_0(_o,g,c,i,t,e,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++)_o.fromBufferAttribute(u,p),_0(_o,p,c,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function _0(s,t,e,n,i,r,a){const o=Wh.distanceSqToPoint(s);if(o<e){const c=new C;Wh.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Jp extends en{constructor(t=[],e=Os,n,i,r,a,o,c,l,h){super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class Si extends en{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Fs extends en{constructor(t,e,n=ei,i,r,a,o=We,c=We,l,h=ki,u=1){if(h!==ki&&h!==Cs)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Fu(Object.assign({},t.image)),this.compareFunction=t.compareFunction,this}toJSON(t){const e=super.toJSON(t);return this.compareFunction!==null&&(e.compareFunction=this.compareFunction),e}}class zv extends Fs{constructor(t,e=ei,n=Os,i,r,a=We,o=We,c,l=ki){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class jp extends en{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Vn extends we{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,n,e,t,a,r,0),p("z","y","x",1,-1,n,e,-t,a,r,1),p("x","z","y",1,1,t,n,e,i,a,2),p("x","z","y",1,-1,t,n,-e,i,a,3),p("x","y","z",1,-1,t,e,n,i,r,4),p("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Ee(l,3)),this.setAttribute("normal",new Ee(h,3)),this.setAttribute("uv",new Ee(u,2));function p(v,g,m,S,E,_,b,w,R,M,A){const P=_/R,D=b/M,I=_/2,F=b/2,H=w/2,O=R+1,V=M+1;let k=0,Y=0;const tt=new C;for(let J=0;J<V;J++){const nt=J*D-F;for(let at=0;at<O;at++){const Ht=at*P-I;tt[v]=Ht*S,tt[g]=nt*E,tt[m]=H,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[g]=0,tt[m]=w>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(at/R),u.push(1-J/M),k+=1}}for(let J=0;J<M;J++)for(let nt=0;nt<R;nt++){const at=d+nt+O*J,Ht=d+nt+O*(J+1),$t=d+(nt+1)+O*(J+1),Bt=d+(nt+1)+O*J;c.push(at,Ht,Bt),c.push(Ht,$t,Bt),Y+=6}o.addGroup(f,Y,A),f+=Y,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Hu extends we{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new C,h=new Pt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Ee(a,3)),this.setAttribute("normal",new Ee(o,3)),this.setAttribute("uv",new Ee(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hu(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Vi extends we{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let p=0;const v=[],g=n/2;let m=0;S(),a===!1&&(t>0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new Ee(u,3)),this.setAttribute("normal",new Ee(d,3)),this.setAttribute("uv",new Ee(f,2));function S(){const _=new C,b=new C;let w=0;const R=(e-t)/n;for(let M=0;M<=r;M++){const A=[],P=M/r,D=P*(e-t)+t;for(let I=0;I<=i;I++){const F=I/i,H=F*c+o,O=Math.sin(H),V=Math.cos(H);b.x=D*O,b.y=-P*n+g,b.z=D*V,u.push(b.x,b.y,b.z),_.set(O,R,V).normalize(),d.push(_.x,_.y,_.z),f.push(F,1-P),A.push(p++)}v.push(A)}for(let M=0;M<i;M++)for(let A=0;A<r;A++){const P=v[A][M],D=v[A+1][M],I=v[A+1][M+1],F=v[A][M+1];(t>0||A!==0)&&(h.push(P,D,F),w+=3),(e>0||A!==r-1)&&(h.push(D,I,F),w+=3)}l.addGroup(m,w,0),m+=w}function E(_){const b=p,w=new Pt,R=new C;let M=0;const A=_===!0?t:e,P=_===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,g*P,0),d.push(0,P,0),f.push(.5,.5),p++;const D=p;for(let I=0;I<=i;I++){const H=I/i*c+o,O=Math.cos(H),V=Math.sin(H);R.x=A*V,R.y=g*P,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,P,0),w.x=O*.5+.5,w.y=V*.5*P+.5,f.push(w.x,w.y),p++}for(let I=0;I<i;I++){const F=b+I,H=D+I;_===!0?h.push(H,H+1,F):h.push(H+1,H,F),M+=3}l.addGroup(m,M,_===!0?1:2),m+=M}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Vi(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Ia extends Vi{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Ia(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Wi extends we{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],g=[];for(let m=0;m<h;m++){const S=m*d-a;for(let E=0;E<l;E++){const _=E*u-r;p.push(_,-S,0),v.push(0,0,1),g.push(E/o),g.push(1-m/c)}}for(let m=0;m<c;m++)for(let S=0;S<o;S++){const E=S+l*m,_=S+l*(m+1),b=S+1+l*(m+1),w=S+1+l*m;f.push(E,_,w),f.push(_,b,w)}this.setIndex(f),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Wi(t.width,t.height,t.widthSegments,t.heightSegments)}}class ln extends we{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new C,d=new C,f=[],p=[],v=[],g=[];for(let m=0;m<=n;m++){const S=[],E=m/n,_=a+E*o,b=t*Math.cos(_),w=Math.sqrt(t*t-b*b);let R=0;m===0&&a===0?R=.5/e:m===n&&c===Math.PI&&(R=-.5/e);for(let M=0;M<=e;M++){const A=M/e,P=i+A*r;u.x=-w*Math.cos(P),u.y=b,u.z=w*Math.sin(P),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),g.push(A+R,1-E),S.push(l++)}h.push(S)}for(let m=0;m<n;m++)for(let S=0;S<e;S++){const E=h[m][S+1],_=h[m][S],b=h[m+1][S],w=h[m+1][S+1];(m!==0||a>0)&&f.push(E,_,w),(m!==n-1||c<Math.PI)&&f.push(_,b,w)}this.setIndex(f),this.setAttribute("position",new Ee(p,3)),this.setAttribute("normal",new Ee(v,3)),this.setAttribute("uv",new Ee(g,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ln(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Nr(s){const t={};for(const e in s){t[e]={};for(const n in s[e]){const i=s[e][n];if(y0(i))i.isRenderTargetTexture?(wt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(y0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();t[e][n]=r}else t[e][n]=i.slice();else t[e][n]=i}}return t}function un(s){const t={};for(let e=0;e<s.length;e++){const n=Nr(s[e]);for(const i in n)t[i]=n[i]}return t}function y0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function kv(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function Qp(s){const t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:jt.workingColorSpace}const Bv={clone:Nr,merge:un};var Hv=`void main() {
519
519
  gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
520
520
  }`,Gv=`void main() {
521
521
  gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
522
- }`;class Ae extends Gi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hv,this.fragmentShader=Gv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Nr(t.uniforms),this.uniformsGroups=kv(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new ct().setHex(i.value);break;case"v2":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new le().fromArray(i.value);break;case"m3":this.uniforms[n].value=new kt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Wt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Vv extends Ae{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wv extends Gi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ct(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 ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rc,this.normalScale=new Pt(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 Bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class mw extends Wv{constructor(t){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 Pt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Kt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ct(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 ct(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ct(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class La extends Gi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rc,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Tu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Xv extends Gi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=N1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class qv extends Gi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function yo(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function Yv(s){function t(i,r){return s[i]-s[r]}const e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function S0(s,t,e){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function Kv(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}class Na{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break t}a=e.length;break e}if(!(t>=r)){const o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let a=0;a!==i;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class $v extends Na{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:zd,endingEnd:zd}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case kd:r=t,o=2*e-n;break;case Bd:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case kd:a=t,c=2*n-e;break;case Bd:a=1,c=n+i[1]-i[0];break;default:a=t-1,c=e}const l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(i-e),v=p*p,g=v*p,m=-d*g+2*d*v-d*p,S=(1+d)*g+(-1.5-2*d)*v+(-.5+d)*p+1,E=(-1-f)*g+(1.5+f)*v+.5*p,_=f*g-f*v;for(let b=0;b!==o;++b)r[b]=m*a[h+b]+S*a[l+b]+E*a[c+b]+_*a[u+b];return r}}class Zv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Jv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class jv extends Na{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(n-e)/(i-e),v=1-p;for(let g=0;g!==o;++g)r[g]=a[l+g]*v+a[c+g]*p;return r}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=a[l+p],g=a[c+p],m=f*d+p*2,S=u[m],E=u[m+1],_=t*d+p*2,b=h[_],w=h[_+1];let R=(n-e)/(i-e),M,A,P,D,I;for(let F=0;F<8;F++){M=R*R,A=M*R,P=1-R,D=P*P,I=D*P;const O=I*e+3*D*R*S+3*P*M*b+A*i-n;if(Math.abs(O)<1e-10)break;const V=3*D*(S-e)+6*P*R*(b-S)+3*M*(i-b);if(Math.abs(V)<1e-10)break;R=R-O/V,R=Math.max(0,Math.min(1,R))}r[p]=I*v+3*D*R*E+3*P*M*w+A*g}return r}}class ni{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=yo(e,this.TimeBufferType),this.values=yo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:yo(t.times,Array),values:yo(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Jv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Zv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new $v(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new jv(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents),e}setInterpolation(t){let e;switch(t){case sc:e=this.InterpolantFactoryMethodDiscrete;break;case Gh:e=this.InterpolantFactoryMethodLinear;break;case Hc:e=this.InterpolantFactoryMethodSmooth;break;case Fd:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return wt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sc;case this.InterpolantFactoryMethodLinear:return Gh;case this.InterpolantFactoryMethodSmooth:return Hc;case this.InterpolantFactoryMethodBezier:return Fd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(zt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;r===0&&(zt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){zt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){zt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(i!==void 0&&V1(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){zt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Hc,r=t.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ni.prototype.ValueTypeName="";ni.prototype.TimeBufferType=Float32Array;ni.prototype.ValueBufferType=Float32Array;ni.prototype.DefaultInterpolation=Gh;class Fr extends ni{constructor(t,e,n){super(t,e,n)}}Fr.prototype.ValueTypeName="bool";Fr.prototype.ValueBufferType=Array;Fr.prototype.DefaultInterpolation=sc;Fr.prototype.InterpolantFactoryMethodLinear=void 0;Fr.prototype.InterpolantFactoryMethodSmooth=void 0;class tm extends ni{constructor(t,e,n,i){super(t,e,n,i)}}tm.prototype.ValueTypeName="color";class Gu extends ni{constructor(t,e,n,i){super(t,e,n,i)}}Gu.prototype.ValueTypeName="number";class Qv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e);let l=t*o;for(let h=l+o;l!==h;l+=4)fs.slerpFlat(r,0,a,l-o,a,l,c);return r}}class Vu extends ni{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Qv(this.times,this.values,this.getValueSize(),t)}}Vu.prototype.ValueTypeName="quaternion";Vu.prototype.InterpolantFactoryMethodSmooth=void 0;class zr extends ni{constructor(t,e,n){super(t,e,n)}}zr.prototype.ValueTypeName="string";zr.prototype.ValueBufferType=Array;zr.prototype.DefaultInterpolation=sc;zr.prototype.InterpolantFactoryMethodLinear=void 0;zr.prototype.InterpolantFactoryMethodSmooth=void 0;class em extends ni{constructor(t,e,n,i){super(t,e,n,i)}}em.prototype.ValueTypeName="vector";class gw{constructor(t="",e=-1,n=[],i=L1){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=jn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(e2(n[a]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,a=n.length;r!==a;++r)e.push(ni.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.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=Yv(c);c=S0(c,1,h),l=S0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new Gu(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function t2(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Gu;case"vector":case"vector2":case"vector3":case"vector4":return em;case"color":return tm;case"quaternion":return Vu;case"bool":case"boolean":return Fr;case"string":return zr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function e2(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=t2(s.type);if(s.times===void 0){const e=[],n=[];Kv(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}const Ui={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(b0(s)||(this.files[s]=t))},get:function(s){if(this.enabled!==!1&&!b0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function b0(s){try{const t=s.slice(s.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class n2{constructor(t,e,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.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 i2=new n2;class Oa{constructor(t){this.manager=t!==void 0?t:i2,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(t,e){const n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}Oa.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ti={};class s2 extends Error{constructor(t,e){super(t),this.response=e}}class vw extends Oa{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Ui.get(`file:${t}`);if(r!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0);return}if(Ti[t]!==void 0){Ti[t].push({onLoad:e,onProgress:n,onError:i});return}Ti[t]=[],Ti[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{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&&wt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=Ti[t],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 g=new ReadableStream({start(m){S();function S(){u.read().then(({done:E,value:_})=>{if(E)m.close();else{v+=_.byteLength;const b=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const M=h[w];M.onProgress&&M.onProgress(b)}m.enqueue(_),S()}},E=>{m.error(E)})}}});return new Response(g)}else throw new s2(`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=>{Ui.add(`file:${t}`,l);const h=Ti[t];delete Ti[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=Ti[t];if(h===void 0)throw this.manager.itemError(t),l;delete Ti[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const lr=new WeakMap;class r2 extends Oa{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Ui.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);else{let u=lr.get(a);u===void 0&&(u=[],lr.set(a,u)),u.push({onLoad:e,onError:i})}return a}const o=Ra("img");function c(){h(),e&&e(this);const u=lr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}lr.delete(this),r.manager.itemEnd(t)}function l(u){h(),i&&i(u),Ui.remove(`image:${t}`);const d=lr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}lr.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Ui.add(`image:${t}`,o),r.manager.itemStart(t),o.src=t,o}}class Mw extends Oa{constructor(t){super(t)}load(t,e,n,i){const r=new en,a=new r2(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}}class Ac extends Se{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ct(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class a2 extends Ac{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ct(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const pl=new Wt,E0=new C,w0=new C;class Wu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pt(512,512),this.mapType=In,this.map=null,this.mapPass=null,this.matrix=new Wt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Bu,this._frameExtents=new Pt(1,1),this._viewportCount=1,this._viewports=[new le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;E0.setFromMatrixPosition(t.matrixWorld),e.position.copy(E0),w0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(w0),e.updateMatrixWorld(),pl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pl,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Ta||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(pl)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const So=new C,bo=new fs,ai=new C;class nm extends Se{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Wt,this.projectionMatrix=new Wt,this.projectionMatrixInverse=new Wt,this.coordinateSystem=gi,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(So,bo,ai),ai.x===1&&ai.y===1&&ai.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(So,bo,ai.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(So,bo,ai),ai.x===1&&ai.y===1&&ai.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(So,bo,ai.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Qi=new C,A0=new Pt,T0=new Pt;class En extends nm{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Lr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(fa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Lr*2*Math.atan(Math.tan(fa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Qi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Qi.x,Qi.y).multiplyScalar(-t/Qi.z),Qi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Qi.x,Qi.y).multiplyScalar(-t/Qi.z)}getViewSize(t,e){return this.getViewBounds(t,A0,T0),e.subVectors(T0,A0)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(fa*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class o2 extends Wu{constructor(){super(new En(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=Lr*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class xw extends Ac{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.target=new Se,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new o2}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class c2 extends Wu{constructor(){super(new En(90,1,.5,500)),this.isPointLightShadow=!0}}class l2 extends Ac{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new c2}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Hs extends nm{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,c=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class h2 extends Wu{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class u2 extends Ac{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.target=new Se,this.shadow=new h2}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class _w{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}const ml=new WeakMap;class yw extends Oa{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&wt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&wt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Ui.get(`image-bitmap:${t}`);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(l=>{ml.has(a)===!0?(i&&i(ml.get(a)),r.manager.itemError(t),r.manager.itemEnd(t)):(e&&e(l),r.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},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(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Ui.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t)}).catch(function(l){i&&i(l),ml.set(c,l),Ui.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Ui.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const hr=-90,ur=1;class d2 extends Se{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new En(hr,ur,t,e);i.layers=this.layers,this.add(i);const r=new En(hr,ur,t,e);r.layers=this.layers,this.add(r);const a=new En(hr,ur,t,e);a.layers=this.layers,this.add(a);const o=new En(hr,ur,t,e);o.layers=this.layers,this.add(o);const c=new En(hr,ur,t,e);c.layers=this.layers,this.add(c);const l=new En(hr,ur,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===gi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ta)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class f2 extends En{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Xu="\\[\\]\\.:\\/",p2=new RegExp("["+Xu+"]","g"),qu="[^"+Xu+"]",m2="[^"+Xu.replace("\\.","")+"]",g2=/((?:WC+[\/:])*)/.source.replace("WC",qu),v2=/(WCOD+)?/.source.replace("WCOD",m2),M2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qu),x2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qu),_2=new RegExp("^"+g2+v2+M2+x2+"$"),y2=["material","materials","bones","map"];class S2{constructor(t,e,n){const i=n||ce.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class ce{constructor(t,e,n){this.path=e,this.parsedPath=n||ce.parseTrackName(e),this.node=ce.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new ce.Composite(t,e,n):new ce(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(p2,"")}static parseTrackName(t){const e=_2.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);y2.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===e||o.uuid===e)return o;const c=n(o.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=ce.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){wt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){zt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){zt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){zt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){zt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){zt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[i];if(a===void 0){const l=e.nodeName;zt("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.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=i;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}}ce.Composite=S2;ce.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ce.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ce.prototype.GetterByBindingType=[ce.prototype._getValue_direct,ce.prototype._getValue_array,ce.prototype._getValue_arrayElement,ce.prototype._getValue_toArray];ce.prototype.SetterByBindingTypeAndVersioning=[[ce.prototype._setValue_direct,ce.prototype._setValue_direct_setNeedsUpdate,ce.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_array,ce.prototype._setValue_array_setNeedsUpdate,ce.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_arrayElement,ce.prototype._setValue_arrayElement_setNeedsUpdate,ce.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_fromArray,ce.prototype._setValue_fromArray_setNeedsUpdate,ce.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const R0=new Wt;class gl{constructor(t,e,n=0,i=1/0){this.ray=new Pa(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new zu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):zt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return R0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(R0),this}intersectObject(t,e=!0,n=[]){return Xh(t,this,n,e),n.sort(D0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Xh(t[i],this,n,e);return n.sort(D0),n}}function D0(s,t){return s.distance-t.distance}function Xh(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)Xh(r[a],t,e,!0)}}class im{static{im.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function C0(s,t,e,n){const i=b2(n);switch(e){case Bp:return s*t;case wc:return s*t/i.components*i.byteLength;case Pu:return s*t/i.components*i.byteLength;case Us:return s*t*2/i.components*i.byteLength;case Iu:return s*t*2/i.components*i.byteLength;case Hp:return s*t*3/i.components*i.byteLength;case vn:return s*t*4/i.components*i.byteLength;case Lu:return s*t*4/i.components*i.byteLength;case Wo:case Xo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case qo:case Yo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case fh:case mh:return Math.max(s,16)*Math.max(t,8)/4;case dh:case ph:return Math.max(s,8)*Math.max(t,8)/2;case gh:case vh:case xh:case _h:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Mh:case nc:case yh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Sh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case bh:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case Eh:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case wh:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case Ah:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case Th:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case Rh:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case Dh:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case Ch:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case Ph:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case Ih:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case Lh:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case Nh:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case Oh:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case Uh:case Fh:case zh:return Math.ceil(s/4)*Math.ceil(t/4)*16;case kh:case Bh:return Math.ceil(s/4)*Math.ceil(t/4)*8;case ic:case Hh:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function b2(s){switch(s){case In:case Up:return{byteLength:1,components:1};case wa:case Fp:case cn:return{byteLength:2,components:1};case Du:case Cu:return{byteLength:2,components:4};case ti:case Ru:case Gn:return{byteLength:4,components:1};case zp:case kp: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:Au}}));typeof window<"u"&&(window.__THREE__?wt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Au);/**
522
+ }`;class Ae extends Gi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Hv,this.fragmentShader=Gv,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Nr(t.uniforms),this.uniformsGroups=kv(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new ct().setHex(i.value);break;case"v2":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new C().fromArray(i.value);break;case"v4":this.uniforms[n].value=new le().fromArray(i.value);break;case"m3":this.uniforms[n].value=new kt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Wt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Vv extends Ae{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Wv extends Gi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new ct(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 ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rc,this.normalScale=new Pt(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 Bi,this.envMapIntensity=1,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.defines={STANDARD:""},this.color.copy(t.color),this.roughness=t.roughness,this.metalness=t.metalness,this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.roughnessMap=t.roughnessMap,this.metalnessMap=t.metalnessMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.envMapIntensity=t.envMapIntensity,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class mw extends Wv{constructor(t){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 Pt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Kt(2.5*(this.ior-1)/(this.ior+1),0,1)},set:function(e){this.ior=(1+.4*e)/(1-.4*e)}}),this.iridescenceMap=null,this.iridescenceIOR=1.3,this.iridescenceThicknessRange=[100,400],this.iridescenceThicknessMap=null,this.sheenColor=new ct(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 ct(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new ct(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(t)}get anisotropy(){return this._anisotropy}set anisotropy(t){this._anisotropy>0!=t>0&&this.version++,this._anisotropy=t}get clearcoat(){return this._clearcoat}set clearcoat(t){this._clearcoat>0!=t>0&&this.version++,this._clearcoat=t}get iridescence(){return this._iridescence}set iridescence(t){this._iridescence>0!=t>0&&this.version++,this._iridescence=t}get dispersion(){return this._dispersion}set dispersion(t){this._dispersion>0!=t>0&&this.version++,this._dispersion=t}get sheen(){return this._sheen}set sheen(t){this._sheen>0!=t>0&&this.version++,this._sheen=t}get transmission(){return this._transmission}set transmission(t){this._transmission>0!=t>0&&this.version++,this._transmission=t}copy(t){return super.copy(t),this.defines={STANDARD:"",PHYSICAL:""},this.anisotropy=t.anisotropy,this.anisotropyRotation=t.anisotropyRotation,this.anisotropyMap=t.anisotropyMap,this.clearcoat=t.clearcoat,this.clearcoatMap=t.clearcoatMap,this.clearcoatRoughness=t.clearcoatRoughness,this.clearcoatRoughnessMap=t.clearcoatRoughnessMap,this.clearcoatNormalMap=t.clearcoatNormalMap,this.clearcoatNormalScale.copy(t.clearcoatNormalScale),this.dispersion=t.dispersion,this.ior=t.ior,this.iridescence=t.iridescence,this.iridescenceMap=t.iridescenceMap,this.iridescenceIOR=t.iridescenceIOR,this.iridescenceThicknessRange=[...t.iridescenceThicknessRange],this.iridescenceThicknessMap=t.iridescenceThicknessMap,this.sheen=t.sheen,this.sheenColor.copy(t.sheenColor),this.sheenColorMap=t.sheenColorMap,this.sheenRoughness=t.sheenRoughness,this.sheenRoughnessMap=t.sheenRoughnessMap,this.transmission=t.transmission,this.transmissionMap=t.transmissionMap,this.thickness=t.thickness,this.thicknessMap=t.thicknessMap,this.attenuationDistance=t.attenuationDistance,this.attenuationColor.copy(t.attenuationColor),this.specularIntensity=t.specularIntensity,this.specularIntensityMap=t.specularIntensityMap,this.specularColor.copy(t.specularColor),this.specularColorMap=t.specularColorMap,this}}class La extends Gi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new ct(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new ct(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rc,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Bi,this.combine=Tu,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(t)}copy(t){return super.copy(t),this.color.copy(t.color),this.map=t.map,this.lightMap=t.lightMap,this.lightMapIntensity=t.lightMapIntensity,this.aoMap=t.aoMap,this.aoMapIntensity=t.aoMapIntensity,this.emissive.copy(t.emissive),this.emissiveMap=t.emissiveMap,this.emissiveIntensity=t.emissiveIntensity,this.bumpMap=t.bumpMap,this.bumpScale=t.bumpScale,this.normalMap=t.normalMap,this.normalMapType=t.normalMapType,this.normalScale.copy(t.normalScale),this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.specularMap=t.specularMap,this.alphaMap=t.alphaMap,this.envMap=t.envMap,this.envMapRotation.copy(t.envMapRotation),this.combine=t.combine,this.reflectivity=t.reflectivity,this.envMapIntensity=t.envMapIntensity,this.refractionRatio=t.refractionRatio,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.wireframeLinecap=t.wireframeLinecap,this.wireframeLinejoin=t.wireframeLinejoin,this.flatShading=t.flatShading,this.fog=t.fog,this}}class Xv extends Gi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=N1,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(t)}copy(t){return super.copy(t),this.depthPacking=t.depthPacking,this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this}}class qv extends Gi{constructor(t){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(t)}copy(t){return super.copy(t),this.map=t.map,this.alphaMap=t.alphaMap,this.displacementMap=t.displacementMap,this.displacementScale=t.displacementScale,this.displacementBias=t.displacementBias,this}}function yo(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function Yv(s){function t(i,r){return s[i]-s[r]}const e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function S0(s,t,e){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function Kv(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}class Na{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break t}a=e.length;break e}if(!(t>=r)){const o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let a=0;a!==i;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class $v extends Na{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:zd,endingEnd:zd}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case kd:r=t,o=2*e-n;break;case Bd:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case kd:a=t,c=2*n-e;break;case Bd:a=1,c=n+i[1]-i[0];break;default:a=t-1,c=e}const l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(n-e)/(i-e),v=p*p,g=v*p,m=-d*g+2*d*v-d*p,S=(1+d)*g+(-1.5-2*d)*v+(-.5+d)*p+1,E=(-1-f)*g+(1.5+f)*v+.5*p,_=f*g-f*v;for(let b=0;b!==o;++b)r[b]=m*a[h+b]+S*a[l+b]+E*a[c+b]+_*a[u+b];return r}}class Zv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class Jv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class jv extends Na{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(n-e)/(i-e),v=1-p;for(let g=0;g!==o;++g)r[g]=a[l+g]*v+a[c+g]*p;return r}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=a[l+p],g=a[c+p],m=f*d+p*2,S=u[m],E=u[m+1],_=t*d+p*2,b=h[_],w=h[_+1];let R=(n-e)/(i-e),M,A,P,D,I;for(let F=0;F<8;F++){M=R*R,A=M*R,P=1-R,D=P*P,I=D*P;const O=I*e+3*D*R*S+3*P*M*b+A*i-n;if(Math.abs(O)<1e-10)break;const V=3*D*(S-e)+6*P*R*(b-S)+3*M*(i-b);if(Math.abs(V)<1e-10)break;R=R-O/V,R=Math.max(0,Math.min(1,R))}r[p]=I*v+3*D*R*E+3*P*M*w+A*g}return r}}class ii{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=yo(e,this.TimeBufferType),this.values=yo(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:yo(t.times,Array),values:yo(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new Jv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Zv(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new $v(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new jv(this.times,this.values,this.getValueSize(),t);return this.settings&&(e.inTangents=this.settings.inTangents,e.outTangents=this.settings.outTangents),e}setInterpolation(t){let e;switch(t){case sc:e=this.InterpolantFactoryMethodDiscrete;break;case Gh:e=this.InterpolantFactoryMethodLinear;break;case Hc:e=this.InterpolantFactoryMethodSmooth;break;case Fd:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return wt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return sc;case this.InterpolantFactoryMethodLinear:return Gh;case this.InterpolantFactoryMethodSmooth:return Hc;case this.InterpolantFactoryMethodBezier:return Fd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(zt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;r===0&&(zt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){zt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){zt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(i!==void 0&&V1(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){zt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===Hc,r=t.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let p=0;p!==n;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}ii.prototype.ValueTypeName="";ii.prototype.TimeBufferType=Float32Array;ii.prototype.ValueBufferType=Float32Array;ii.prototype.DefaultInterpolation=Gh;class Fr extends ii{constructor(t,e,n){super(t,e,n)}}Fr.prototype.ValueTypeName="bool";Fr.prototype.ValueBufferType=Array;Fr.prototype.DefaultInterpolation=sc;Fr.prototype.InterpolantFactoryMethodLinear=void 0;Fr.prototype.InterpolantFactoryMethodSmooth=void 0;class tm extends ii{constructor(t,e,n,i){super(t,e,n,i)}}tm.prototype.ValueTypeName="color";class Gu extends ii{constructor(t,e,n,i){super(t,e,n,i)}}Gu.prototype.ValueTypeName="number";class Qv extends Na{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e);let l=t*o;for(let h=l+o;l!==h;l+=4)fs.slerpFlat(r,0,a,l-o,a,l,c);return r}}class Vu extends ii{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new Qv(this.times,this.values,this.getValueSize(),t)}}Vu.prototype.ValueTypeName="quaternion";Vu.prototype.InterpolantFactoryMethodSmooth=void 0;class zr extends ii{constructor(t,e,n){super(t,e,n)}}zr.prototype.ValueTypeName="string";zr.prototype.ValueBufferType=Array;zr.prototype.DefaultInterpolation=sc;zr.prototype.InterpolantFactoryMethodLinear=void 0;zr.prototype.InterpolantFactoryMethodSmooth=void 0;class em extends ii{constructor(t,e,n,i){super(t,e,n,i)}}em.prototype.ValueTypeName="vector";class gw{constructor(t="",e=-1,n=[],i=L1){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=Qn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(e2(n[a]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,a=n.length;r!==a;++r)e.push(ii.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.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=Yv(c);c=S0(c,1,h),l=S0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new Gu(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function t2(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return Gu;case"vector":case"vector2":case"vector3":case"vector4":return em;case"color":return tm;case"quaternion":return Vu;case"bool":case"boolean":return Fr;case"string":return zr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function e2(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=t2(s.type);if(s.times===void 0){const e=[],n=[];Kv(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}const Ui={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(b0(s)||(this.files[s]=t))},get:function(s){if(this.enabled!==!1&&!b0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function b0(s){try{const t=s.slice(s.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class n2{constructor(t,e,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.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 i2=new n2;class Oa{constructor(t){this.manager=t!==void 0?t:i2,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(t,e){const n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}Oa.DEFAULT_MATERIAL_NAME="__DEFAULT";const Ri={};class s2 extends Error{constructor(t,e){super(t),this.response=e}}class vw extends Oa{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Ui.get(`file:${t}`);if(r!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0);return}if(Ri[t]!==void 0){Ri[t].push({onLoad:e,onProgress:n,onError:i});return}Ri[t]=[],Ri[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{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&&wt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=Ri[t],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 g=new ReadableStream({start(m){S();function S(){u.read().then(({done:E,value:_})=>{if(E)m.close();else{v+=_.byteLength;const b=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const M=h[w];M.onProgress&&M.onProgress(b)}m.enqueue(_),S()}},E=>{m.error(E)})}}});return new Response(g)}else throw new s2(`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=>{Ui.add(`file:${t}`,l);const h=Ri[t];delete Ri[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=Ri[t];if(h===void 0)throw this.manager.itemError(t),l;delete Ri[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onError&&f.onError(l)}this.manager.itemError(t)}).finally(()=>{this.manager.itemEnd(t)}),this.manager.itemStart(t)}setResponseType(t){return this.responseType=t,this}setMimeType(t){return this.mimeType=t,this}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const lr=new WeakMap;class r2 extends Oa{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Ui.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);else{let u=lr.get(a);u===void 0&&(u=[],lr.set(a,u)),u.push({onLoad:e,onError:i})}return a}const o=Ra("img");function c(){h(),e&&e(this);const u=lr.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}lr.delete(this),r.manager.itemEnd(t)}function l(u){h(),i&&i(u),Ui.remove(`image:${t}`);const d=lr.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}lr.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Ui.add(`image:${t}`,o),r.manager.itemStart(t),o.src=t,o}}class Mw extends Oa{constructor(t){super(t)}load(t,e,n,i){const r=new en,a=new r2(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}}class Ac extends Se{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new ct(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class a2 extends Ac{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.groundColor=new ct(e)}copy(t,e){return super.copy(t,e),this.groundColor.copy(t.groundColor),this}toJSON(t){const e=super.toJSON(t);return e.object.groundColor=this.groundColor.getHex(),e}}const pl=new Wt,E0=new C,w0=new C;class Wu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pt(512,512),this.mapType=In,this.map=null,this.mapPass=null,this.matrix=new Wt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Bu,this._frameExtents=new Pt(1,1),this._viewportCount=1,this._viewports=[new le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;E0.setFromMatrixPosition(t.matrixWorld),e.position.copy(E0),w0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(w0),e.updateMatrixWorld(),pl.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(pl,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Ta||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(pl)}getViewport(t){return this._viewports[t]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(t){return this.camera=t.camera.clone(),this.intensity=t.intensity,this.bias=t.bias,this.radius=t.radius,this.autoUpdate=t.autoUpdate,this.needsUpdate=t.needsUpdate,this.normalBias=t.normalBias,this.blurSamples=t.blurSamples,this.mapSize.copy(t.mapSize),this.biasNode=t.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const t={};return this.intensity!==1&&(t.intensity=this.intensity),this.bias!==0&&(t.bias=this.bias),this.normalBias!==0&&(t.normalBias=this.normalBias),this.radius!==1&&(t.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(t.mapSize=this.mapSize.toArray()),t.camera=this.camera.toJSON(!1).object,delete t.camera.matrix,t}}const So=new C,bo=new fs,oi=new C;class nm extends Se{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Wt,this.projectionMatrix=new Wt,this.projectionMatrixInverse=new Wt,this.coordinateSystem=vi,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(t,e){return super.copy(t,e),this.matrixWorldInverse.copy(t.matrixWorldInverse),this.projectionMatrix.copy(t.projectionMatrix),this.projectionMatrixInverse.copy(t.projectionMatrixInverse),this.coordinateSystem=t.coordinateSystem,this}getWorldDirection(t){return super.getWorldDirection(t).negate()}updateMatrixWorld(t){super.updateMatrixWorld(t),this.matrixWorld.decompose(So,bo,oi),oi.x===1&&oi.y===1&&oi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(So,bo,oi.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(So,bo,oi),oi.x===1&&oi.y===1&&oi.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(So,bo,oi.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Qi=new C,A0=new Pt,T0=new Pt;class En extends nm{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=Lr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(fa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return Lr*2*Math.atan(Math.tan(fa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Qi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Qi.x,Qi.y).multiplyScalar(-t/Qi.z),Qi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Qi.x,Qi.y).multiplyScalar(-t/Qi.z)}getViewSize(t,e){return this.getViewBounds(t,A0,T0),e.subVectors(T0,A0)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(fa*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class o2 extends Wu{constructor(){super(new En(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=Lr*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class xw extends Ac{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.target=new Se,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new o2}get power(){return this.intensity*Math.PI}set power(t){this.intensity=t/Math.PI}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.angle=t.angle,this.penumbra=t.penumbra,this.decay=t.decay,this.target=t.target.clone(),this.map=t.map,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.angle=this.angle,e.object.decay=this.decay,e.object.penumbra=this.penumbra,e.object.target=this.target.uuid,this.map&&this.map.isTexture&&(e.object.map=this.map.toJSON(t).uuid),e.object.shadow=this.shadow.toJSON(),e}}class c2 extends Wu{constructor(){super(new En(90,1,.5,500)),this.isPointLightShadow=!0}}class l2 extends Ac{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new c2}get power(){return this.intensity*4*Math.PI}set power(t){this.intensity=t/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(t,e){return super.copy(t,e),this.distance=t.distance,this.decay=t.decay,this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.distance=this.distance,e.object.decay=this.decay,e.object.shadow=this.shadow.toJSON(),e}}class Hs extends nm{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,c=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class h2 extends Wu{constructor(){super(new Hs(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class u2 extends Ac{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Se.DEFAULT_UP),this.updateMatrix(),this.target=new Se,this.shadow=new h2}dispose(){super.dispose(),this.shadow.dispose()}copy(t){return super.copy(t),this.target=t.target.clone(),this.shadow=t.shadow.clone(),this}toJSON(t){const e=super.toJSON(t);return e.object.shadow=this.shadow.toJSON(),e.object.target=this.target.uuid,e}}class _w{static extractUrlBase(t){const e=t.lastIndexOf("/");return e===-1?"./":t.slice(0,e+1)}static resolveURL(t,e){return typeof t!="string"||t===""?"":(/^https?:\/\//i.test(e)&&/^\//.test(t)&&(e=e.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(t)||/^data:.*,.*$/i.test(t)||/^blob:.*$/i.test(t)?t:e+t)}}const ml=new WeakMap;class yw extends Oa{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&wt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&wt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Ui.get(`image-bitmap:${t}`);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(l=>{ml.has(a)===!0?(i&&i(ml.get(a)),r.manager.itemError(t),r.manager.itemEnd(t)):(e&&e(l),r.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},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(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Ui.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t)}).catch(function(l){i&&i(l),ml.set(c,l),Ui.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Ui.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const hr=-90,ur=1;class d2 extends Se{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new En(hr,ur,t,e);i.layers=this.layers,this.add(i);const r=new En(hr,ur,t,e);r.layers=this.layers,this.add(r);const a=new En(hr,ur,t,e);a.layers=this.layers,this.add(a);const o=new En(hr,ur,t,e);o.layers=this.layers,this.add(o);const c=new En(hr,ur,t,e);c.layers=this.layers,this.add(c);const l=new En(hr,ur,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===vi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Ta)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),p=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let g=!1;t.isWebGLRenderer===!0?g=t.state.buffers.depth.getReversed():g=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),g&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,n.texture.needsPMREMUpdate=!0}}class f2 extends En{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Xu="\\[\\]\\.:\\/",p2=new RegExp("["+Xu+"]","g"),qu="[^"+Xu+"]",m2="[^"+Xu.replace("\\.","")+"]",g2=/((?:WC+[\/:])*)/.source.replace("WC",qu),v2=/(WCOD+)?/.source.replace("WCOD",m2),M2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",qu),x2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",qu),_2=new RegExp("^"+g2+v2+M2+x2+"$"),y2=["material","materials","bones","map"];class S2{constructor(t,e,n){const i=n||ce.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class ce{constructor(t,e,n){this.path=e,this.parsedPath=n||ce.parseTrackName(e),this.node=ce.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new ce.Composite(t,e,n):new ce(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(p2,"")}static parseTrackName(t){const e=_2.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);y2.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===e||o.uuid===e)return o;const c=n(o.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=ce.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){wt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){zt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){zt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){zt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){zt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){zt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[i];if(a===void 0){const l=e.nodeName;zt("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.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=i;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}}ce.Composite=S2;ce.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ce.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ce.prototype.GetterByBindingType=[ce.prototype._getValue_direct,ce.prototype._getValue_array,ce.prototype._getValue_arrayElement,ce.prototype._getValue_toArray];ce.prototype.SetterByBindingTypeAndVersioning=[[ce.prototype._setValue_direct,ce.prototype._setValue_direct_setNeedsUpdate,ce.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_array,ce.prototype._setValue_array_setNeedsUpdate,ce.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_arrayElement,ce.prototype._setValue_arrayElement_setNeedsUpdate,ce.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_fromArray,ce.prototype._setValue_fromArray_setNeedsUpdate,ce.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const R0=new Wt;class gl{constructor(t,e,n=0,i=1/0){this.ray=new Pa(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new zu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):zt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return R0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(R0),this}intersectObject(t,e=!0,n=[]){return Xh(t,this,n,e),n.sort(D0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Xh(t[i],this,n,e);return n.sort(D0),n}}function D0(s,t){return s.distance-t.distance}function Xh(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)Xh(r[a],t,e,!0)}}class im{static{im.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function C0(s,t,e,n){const i=b2(n);switch(e){case Bp:return s*t;case wc:return s*t/i.components*i.byteLength;case Pu:return s*t/i.components*i.byteLength;case Us:return s*t*2/i.components*i.byteLength;case Iu:return s*t*2/i.components*i.byteLength;case Hp:return s*t*3/i.components*i.byteLength;case vn:return s*t*4/i.components*i.byteLength;case Lu:return s*t*4/i.components*i.byteLength;case Wo:case Xo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case qo:case Yo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case fh:case mh:return Math.max(s,16)*Math.max(t,8)/4;case dh:case ph:return Math.max(s,8)*Math.max(t,8)/2;case gh:case vh:case xh:case _h:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Mh:case nc:case yh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case Sh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case bh:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case Eh:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case wh:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case Ah:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case Th:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case Rh:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case Dh:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case Ch:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case Ph:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case Ih:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case Lh:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case Nh:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case Oh:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case Uh:case Fh:case zh:return Math.ceil(s/4)*Math.ceil(t/4)*16;case kh:case Bh:return Math.ceil(s/4)*Math.ceil(t/4)*8;case ic:case Hh:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function b2(s){switch(s){case In:case Up:return{byteLength:1,components:1};case wa:case Fp:case cn:return{byteLength:2,components:1};case Du:case Cu:return{byteLength:2,components:4};case ei:case Ru:case Gn:return{byteLength:4,components:1};case zp:case kp: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:Au}}));typeof window<"u"&&(window.__THREE__?wt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Au);/**
523
523
  * @license
524
524
  * Copyright 2010-2026 Three.js Authors
525
525
  * SPDX-License-Identifier: MIT
@@ -4189,7 +4189,7 @@ void main() {
4189
4189
  #include <tonemapping_fragment>
4190
4190
  #include <colorspace_fragment>
4191
4191
  #include <fog_fragment>
4192
- }`,Xt={alphahash_fragment:w2,alphahash_pars_fragment:A2,alphamap_fragment:T2,alphamap_pars_fragment:R2,alphatest_fragment:D2,alphatest_pars_fragment:C2,aomap_fragment:P2,aomap_pars_fragment:I2,batching_pars_vertex:L2,batching_vertex:N2,begin_vertex:O2,beginnormal_vertex:U2,bsdfs:F2,iridescence_fragment:z2,bumpmap_pars_fragment:k2,clipping_planes_fragment:B2,clipping_planes_pars_fragment:H2,clipping_planes_pars_vertex:G2,clipping_planes_vertex:V2,color_fragment:W2,color_pars_fragment:X2,color_pars_vertex:q2,color_vertex:Y2,common:K2,cube_uv_reflection_fragment:$2,defaultnormal_vertex:Z2,displacementmap_pars_vertex:J2,displacementmap_vertex:j2,emissivemap_fragment:Q2,emissivemap_pars_fragment:tM,colorspace_fragment:eM,colorspace_pars_fragment:nM,envmap_fragment:iM,envmap_common_pars_fragment:sM,envmap_pars_fragment:rM,envmap_pars_vertex:aM,envmap_physical_pars_fragment:vM,envmap_vertex:oM,fog_vertex:cM,fog_pars_vertex:lM,fog_fragment:hM,fog_pars_fragment:uM,gradientmap_pars_fragment:dM,lightmap_pars_fragment:fM,lights_lambert_fragment:pM,lights_lambert_pars_fragment:mM,lights_pars_begin:gM,lights_toon_fragment:MM,lights_toon_pars_fragment:xM,lights_phong_fragment:_M,lights_phong_pars_fragment:yM,lights_physical_fragment:SM,lights_physical_pars_fragment:bM,lights_fragment_begin:EM,lights_fragment_maps:wM,lights_fragment_end:AM,lightprobes_pars_fragment:TM,logdepthbuf_fragment:RM,logdepthbuf_pars_fragment:DM,logdepthbuf_pars_vertex:CM,logdepthbuf_vertex:PM,map_fragment:IM,map_pars_fragment:LM,map_particle_fragment:NM,map_particle_pars_fragment:OM,metalnessmap_fragment:UM,metalnessmap_pars_fragment:FM,morphinstance_vertex:zM,morphcolor_vertex:kM,morphnormal_vertex:BM,morphtarget_pars_vertex:HM,morphtarget_vertex:GM,normal_fragment_begin:VM,normal_fragment_maps:WM,normal_pars_fragment:XM,normal_pars_vertex:qM,normal_vertex:YM,normalmap_pars_fragment:KM,clearcoat_normal_fragment_begin:$M,clearcoat_normal_fragment_maps:ZM,clearcoat_pars_fragment:JM,iridescence_pars_fragment:jM,opaque_fragment:QM,packing:tx,premultiplied_alpha_fragment:ex,project_vertex:nx,dithering_fragment:ix,dithering_pars_fragment:sx,roughnessmap_fragment:rx,roughnessmap_pars_fragment:ax,shadowmap_pars_fragment:ox,shadowmap_pars_vertex:cx,shadowmap_vertex:lx,shadowmask_pars_fragment:hx,skinbase_vertex:ux,skinning_pars_vertex:dx,skinning_vertex:fx,skinnormal_vertex:px,specularmap_fragment:mx,specularmap_pars_fragment:gx,tonemapping_fragment:vx,tonemapping_pars_fragment:Mx,transmission_fragment:xx,transmission_pars_fragment:_x,uv_pars_fragment:yx,uv_pars_vertex:Sx,uv_vertex:bx,worldpos_vertex:Ex,background_vert:wx,background_frag:Ax,backgroundCube_vert:Tx,backgroundCube_frag:Rx,cube_vert:Dx,cube_frag:Cx,depth_vert:Px,depth_frag:Ix,distance_vert:Lx,distance_frag:Nx,equirect_vert:Ox,equirect_frag:Ux,linedashed_vert:Fx,linedashed_frag:zx,meshbasic_vert:kx,meshbasic_frag:Bx,meshlambert_vert:Hx,meshlambert_frag:Gx,meshmatcap_vert:Vx,meshmatcap_frag:Wx,meshnormal_vert:Xx,meshnormal_frag:qx,meshphong_vert:Yx,meshphong_frag:Kx,meshphysical_vert:$x,meshphysical_frag:Zx,meshtoon_vert:Jx,meshtoon_frag:jx,points_vert:Qx,points_frag:t_,shadow_vert:e_,shadow_frag:n_,sprite_vert:i_,sprite_frag:s_},pt={common:{diffuse:{value:new ct(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new kt}},envmap:{envMap:{value:null},envMapRotation:{value:new kt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new kt},normalScale:{value:new Pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ct(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 C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new ct(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0},uvTransform:{value:new kt}},sprite:{diffuse:{value:new ct(16777215)},opacity:{value:1},center:{value:new Pt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}}},ui={basic:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},envMapIntensity:{value:1}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},specular:{value:new ct(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:un([pt.common,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.roughnessmap,pt.metalnessmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:un([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new ct(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:un([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:un([pt.points,pt.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:un([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:un([pt.common,pt.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:un([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:un([pt.sprite,pt.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new kt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distance:{uniforms:un([pt.common,pt.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distance_vert,fragmentShader:Xt.distance_frag},shadow:{uniforms:un([pt.lights,pt.fog,{color:{value:new ct(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};ui.physical={uniforms:un([ui.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new kt},clearcoatNormalScale:{value:new Pt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new kt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new kt},sheen:{value:0},sheenColor:{value:new ct(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new kt},transmissionSamplerSize:{value:new Pt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new kt},attenuationDistance:{value:0},attenuationColor:{value:new ct(0)},specularColor:{value:new ct(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new kt},anisotropyVector:{value:new Pt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new kt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};const Eo={r:0,b:0,g:0},r_=new Wt,rm=new kt;rm.set(-1,0,0,0,1,0,0,0,1);function a_(s,t,e,n,i,r){const a=new ct(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let E=S.isScene===!0?S.background:null;if(E&&E.isTexture){const _=S.backgroundBlurriness>0;E=t.get(E,_)}return E}function p(S){let E=!1;const _=f(S);_===null?g(a,o):_&&_.isColor&&(g(_,1),E=!0);const b=s.xr.getEnvironmentBlendMode();b==="additive"?e.buffers.color.setClear(0,0,0,1,r):b==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(s.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,E){const _=f(E);_&&(_.isCubeTexture||_.mapping===Ec)?(l===void 0&&(l=new qt(new Vn(1,1,1),new Ae({name:"BackgroundCubeMaterial",uniforms:Nr(ui.backgroundCube.uniforms),vertexShader:ui.backgroundCube.vertexShader,fragmentShader:ui.backgroundCube.fragmentShader,side:ze,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(r_.makeRotationFromEuler(E.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(rm),l.material.toneMapped=jt.getTransfer(_.colorSpace)!==se,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new qt(new Wi(2,2),new Ae({name:"BackgroundMaterial",uniforms:Nr(ui.background.uniforms),vertexShader:ui.background.vertexShader,fragmentShader:ui.background.fragmentShader,side:us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=jt.getTransfer(_.colorSpace)!==se,_.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(),S.unshift(c,c.geometry,c.material,0,0,null))}function g(S,E){S.getRGB(Eo,Qp(s)),e.buffers.color.setClear(Eo.r,Eo.g,Eo.b,E,r)}function m(){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(S,E=1){a.set(S),o=E,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,g(a,o)},render:p,addToRenderList:v,dispose:m}}function o_(s,t){const e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,I,F,H,O){let V=!1;const k=u(D,H,F,I);r!==k&&(r=k,l(r.object)),V=f(D,H,F,O),V&&p(D,H,F,O),O!==null&&t.update(O,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(D,I,F,H),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,I,F,H){const O=H.wireframe===!0;let V=n[I.id];V===void 0&&(V={},n[I.id]=V);const k=D.isInstancedMesh===!0?D.id:0;let Y=V[k];Y===void 0&&(Y={},V[k]=Y);let tt=Y[F.id];tt===void 0&&(tt={},Y[F.id]=tt);let J=tt[O];return J===void 0&&(J=d(c()),tt[O]=J),J}function d(D){const I=[],F=[],H=[];for(let O=0;O<e;O++)I[O]=0,F[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:F,attributeDivisors:H,object:D,attributes:{},index:null}}function f(D,I,F,H){const O=r.attributes,V=I.attributes;let k=0;const Y=F.getAttributes();for(const tt in Y)if(Y[tt].location>=0){const nt=O[tt];let at=V[tt];if(at===void 0&&(tt==="instanceMatrix"&&D.instanceMatrix&&(at=D.instanceMatrix),tt==="instanceColor"&&D.instanceColor&&(at=D.instanceColor)),nt===void 0||nt.attribute!==at||at&&nt.data!==at.data)return!0;k++}return r.attributesNum!==k||r.index!==H}function p(D,I,F,H){const O={},V=I.attributes;let k=0;const Y=F.getAttributes();for(const tt in Y)if(Y[tt].location>=0){let nt=V[tt];nt===void 0&&(tt==="instanceMatrix"&&D.instanceMatrix&&(nt=D.instanceMatrix),tt==="instanceColor"&&D.instanceColor&&(nt=D.instanceColor));const at={};at.attribute=nt,nt&&nt.data&&(at.data=nt.data),O[tt]=at,k++}r.attributes=O,r.attributesNum=k,r.index=H}function v(){const D=r.newAttributes;for(let I=0,F=D.length;I<F;I++)D[I]=0}function g(D){m(D,0)}function m(D,I){const F=r.newAttributes,H=r.enabledAttributes,O=r.attributeDivisors;F[D]=1,H[D]===0&&(s.enableVertexAttribArray(D),H[D]=1),O[D]!==I&&(s.vertexAttribDivisor(D,I),O[D]=I)}function S(){const D=r.newAttributes,I=r.enabledAttributes;for(let F=0,H=I.length;F<H;F++)I[F]!==D[F]&&(s.disableVertexAttribArray(F),I[F]=0)}function E(D,I,F,H,O,V,k){k===!0?s.vertexAttribIPointer(D,I,F,O,V):s.vertexAttribPointer(D,I,F,H,O,V)}function _(D,I,F,H){v();const O=H.attributes,V=F.getAttributes(),k=I.defaultAttributeValues;for(const Y in V){const tt=V[Y];if(tt.location>=0){let J=O[Y];if(J===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const nt=J.normalized,at=J.itemSize,Ht=t.get(J);if(Ht===void 0)continue;const $t=Ht.buffer,Bt=Ht.type,K=Ht.bytesPerElement,rt=Bt===s.INT||Bt===s.UNSIGNED_INT||J.gpuType===Ru;if(J.isInterleavedBufferAttribute){const it=J.data,B=it.stride,Et=J.offset;if(it.isInstancedInterleavedBuffer){for(let It=0;It<tt.locationSize;It++)m(tt.location+It,it.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=it.meshPerAttribute*it.count)}else for(let It=0;It<tt.locationSize;It++)g(tt.location+It);s.bindBuffer(s.ARRAY_BUFFER,$t);for(let It=0;It<tt.locationSize;It++)E(tt.location+It,at/tt.locationSize,Bt,nt,B*K,(Et+at/tt.locationSize*It)*K,rt)}else{if(J.isInstancedBufferAttribute){for(let it=0;it<tt.locationSize;it++)m(tt.location+it,J.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let it=0;it<tt.locationSize;it++)g(tt.location+it);s.bindBuffer(s.ARRAY_BUFFER,$t);for(let it=0;it<tt.locationSize;it++)E(tt.location+it,at/tt.locationSize,Bt,nt,at*K,at/tt.locationSize*it*K,rt)}}else if(k!==void 0){const nt=k[Y];if(nt!==void 0)switch(nt.length){case 2:s.vertexAttrib2fv(tt.location,nt);break;case 3:s.vertexAttrib3fv(tt.location,nt);break;case 4:s.vertexAttrib4fv(tt.location,nt);break;default:s.vertexAttrib1fv(tt.location,nt)}}}}S()}function b(){A();for(const D in n){const I=n[D];for(const F in I){const H=I[F];for(const O in H){const V=H[O];for(const k in V)h(V[k].object),delete V[k];delete H[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const F in I){const H=I[F];for(const O in H){const V=H[O];for(const k in V)h(V[k].object),delete V[k];delete H[O]}}delete n[D.id]}function R(D){for(const I in n){const F=n[I];for(const H in F){const O=F[H];if(O[D.id]===void 0)continue;const V=O[D.id];for(const k in V)h(V[k].object),delete V[k];delete O[D.id]}}}function M(D){for(const I in n){const F=n[I],H=D.isInstancedMesh===!0?D.id:0,O=F[H];if(O!==void 0){for(const V in O){const k=O[V];for(const Y in k)h(k[Y].object),delete k[Y];delete O[V]}delete F[H],Object.keys(F).length===0&&delete n[I]}}}function A(){P(),a=!0,r!==i&&(r=i,l(r.object))}function P(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:P,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:M,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:g,disableUnusedAttributes:S}}function c_(s,t,e){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function l_(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==vn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const M=R===cn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==In&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Gn&&!M)}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=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(wt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&wt("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),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),E=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),b=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:g,maxAttributes:m,maxVertexUniforms:S,maxVaryings:E,maxFragmentUniforms:_,maxSamples:b,samples:w}}function h_(s){const t=this;let e=null,n=0,i=!1,r=!1;const a=new Ss,o=new kt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,g=u.clipShadows,m=s.get(u);if(!i||p===null||p.length===0||r&&!g)r?h(null):l();else{const S=r?0:n,E=S*4;let _=m.clippingState||null;c.value=_,_=h(p,d,E,f);for(let b=0;b!==E;++b)_[b]=e[b];m.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let g=null;if(v!==0){if(g=c.value,p!==!0||g===null){const m=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(g===null||g.length<m)&&(g=new Float32Array(m));for(let E=0,_=f;E!==v;++E,_+=4)a.copy(u[E]).applyMatrix4(S,o),a.normal.toArray(g,_),g[_+3]=a.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,g}}const os=4,P0=[.125,.215,.35,.446,.526,.582],ws=20,u_=256,jr=new Hs,I0=new ct;let vl=null,Ml=0,xl=0,_l=!1;const d_=new C;class L0{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:o=d_}=r;vl=this._renderer.getRenderTarget(),Ml=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),_l=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=U0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=O0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(vl,Ml,xl),this._renderer.xr.enabled=_l,t.scissorTest=!1,dr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Os||t.mapping===Ir?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),vl=this._renderer.getRenderTarget(),Ml=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),_l=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:ye,minFilter:ye,generateMipmaps:!1,type:cn,format:vn,colorSpace:ac,depthBuffer:!1},i=N0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=N0(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=f_(r)),this._blurMaterial=m_(r,t,e),this._ggxMaterial=p_(r,t,e)}return i}_compileMaterial(t){const e=new qt(new we,t);this._renderer.compile(e,jr)}_sceneToCubeUV(t,e,n,i,r){const c=new En(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(I0),u.toneMapping=xi,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new qt(new Vn,new zi({name:"PMREM.Background",side:ze,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,g=v.material;let m=!1;const S=t.background;S?S.isColor&&(g.color.copy(S),t.background=null,m=!0):(g.color.copy(I0),m=!0);for(let E=0;E<6;E++){const _=E%3;_===0?(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[E],r.y,r.z)):_===1?(c.up.set(0,0,l[E]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[E],r.z)):(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[E]));const b=this._cubeSize;dr(i,_*b,E>2?b:0,b,b),u.setRenderTarget(i),m&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=S}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Os||t.mapping===Ir;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=U0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=O0());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;dr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,jr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[n],g=3*v*(n>p-os?n-p+os:0),m=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,dr(r,g,m,3*v,2*v),i.setRenderTarget(r),i.render(o,jr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-n,dr(t,g,m,3*v,2*v),i.setRenderTarget(t),i.render(o,jr)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&zt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ws-1),v=r/p,g=isFinite(r)?1+Math.floor(h*v):ws;g>ws&&wt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ws}`);const m=[];let S=0;for(let R=0;R<ws;++R){const M=R/v,A=Math.exp(-M*M/2);m.push(A),R===0?S+=A:R<g&&(S+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/S;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=m,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=p,d.mipInt.value=E-n;const _=this._sizeLods[i],b=3*_*(i>E-os?i-E+os:0),w=4*(this._cubeSize-_);dr(e,b,w,3*_,2*_),c.setRenderTarget(e),c.render(u,jr)}}function f_(s){const t=[],e=[],n=[];let i=s;const r=s-os+1+P0.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>s-os?c=P0[a-s+os-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,g=2,m=1,S=new Float32Array(v*p*f),E=new Float32Array(g*p*f),_=new Float32Array(m*p*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,M=w>2?0:-1,A=[R,M,0,R+2/3,M,0,R+2/3,M+1,0,R,M,0,R+2/3,M+1,0,R,M+1,0];S.set(A,v*p*w),E.set(d,g*p*w);const P=[w,w,w,w,w,w];_.set(P,m*p*w)}const b=new we;b.setAttribute("position",new de(S,v)),b.setAttribute("uv",new de(E,g)),b.setAttribute("faceIndex",new de(_,m)),n.push(new qt(b,null)),i>os&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function N0(s,t,e){const n=new wn(s,t,e);return n.texture.mapping=Ec,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function dr(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function p_(s,t,e){return new Ae({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:u_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Tc(),fragmentShader:`
4192
+ }`,Xt={alphahash_fragment:w2,alphahash_pars_fragment:A2,alphamap_fragment:T2,alphamap_pars_fragment:R2,alphatest_fragment:D2,alphatest_pars_fragment:C2,aomap_fragment:P2,aomap_pars_fragment:I2,batching_pars_vertex:L2,batching_vertex:N2,begin_vertex:O2,beginnormal_vertex:U2,bsdfs:F2,iridescence_fragment:z2,bumpmap_pars_fragment:k2,clipping_planes_fragment:B2,clipping_planes_pars_fragment:H2,clipping_planes_pars_vertex:G2,clipping_planes_vertex:V2,color_fragment:W2,color_pars_fragment:X2,color_pars_vertex:q2,color_vertex:Y2,common:K2,cube_uv_reflection_fragment:$2,defaultnormal_vertex:Z2,displacementmap_pars_vertex:J2,displacementmap_vertex:j2,emissivemap_fragment:Q2,emissivemap_pars_fragment:tM,colorspace_fragment:eM,colorspace_pars_fragment:nM,envmap_fragment:iM,envmap_common_pars_fragment:sM,envmap_pars_fragment:rM,envmap_pars_vertex:aM,envmap_physical_pars_fragment:vM,envmap_vertex:oM,fog_vertex:cM,fog_pars_vertex:lM,fog_fragment:hM,fog_pars_fragment:uM,gradientmap_pars_fragment:dM,lightmap_pars_fragment:fM,lights_lambert_fragment:pM,lights_lambert_pars_fragment:mM,lights_pars_begin:gM,lights_toon_fragment:MM,lights_toon_pars_fragment:xM,lights_phong_fragment:_M,lights_phong_pars_fragment:yM,lights_physical_fragment:SM,lights_physical_pars_fragment:bM,lights_fragment_begin:EM,lights_fragment_maps:wM,lights_fragment_end:AM,lightprobes_pars_fragment:TM,logdepthbuf_fragment:RM,logdepthbuf_pars_fragment:DM,logdepthbuf_pars_vertex:CM,logdepthbuf_vertex:PM,map_fragment:IM,map_pars_fragment:LM,map_particle_fragment:NM,map_particle_pars_fragment:OM,metalnessmap_fragment:UM,metalnessmap_pars_fragment:FM,morphinstance_vertex:zM,morphcolor_vertex:kM,morphnormal_vertex:BM,morphtarget_pars_vertex:HM,morphtarget_vertex:GM,normal_fragment_begin:VM,normal_fragment_maps:WM,normal_pars_fragment:XM,normal_pars_vertex:qM,normal_vertex:YM,normalmap_pars_fragment:KM,clearcoat_normal_fragment_begin:$M,clearcoat_normal_fragment_maps:ZM,clearcoat_pars_fragment:JM,iridescence_pars_fragment:jM,opaque_fragment:QM,packing:tx,premultiplied_alpha_fragment:ex,project_vertex:nx,dithering_fragment:ix,dithering_pars_fragment:sx,roughnessmap_fragment:rx,roughnessmap_pars_fragment:ax,shadowmap_pars_fragment:ox,shadowmap_pars_vertex:cx,shadowmap_vertex:lx,shadowmask_pars_fragment:hx,skinbase_vertex:ux,skinning_pars_vertex:dx,skinning_vertex:fx,skinnormal_vertex:px,specularmap_fragment:mx,specularmap_pars_fragment:gx,tonemapping_fragment:vx,tonemapping_pars_fragment:Mx,transmission_fragment:xx,transmission_pars_fragment:_x,uv_pars_fragment:yx,uv_pars_vertex:Sx,uv_vertex:bx,worldpos_vertex:Ex,background_vert:wx,background_frag:Ax,backgroundCube_vert:Tx,backgroundCube_frag:Rx,cube_vert:Dx,cube_frag:Cx,depth_vert:Px,depth_frag:Ix,distance_vert:Lx,distance_frag:Nx,equirect_vert:Ox,equirect_frag:Ux,linedashed_vert:Fx,linedashed_frag:zx,meshbasic_vert:kx,meshbasic_frag:Bx,meshlambert_vert:Hx,meshlambert_frag:Gx,meshmatcap_vert:Vx,meshmatcap_frag:Wx,meshnormal_vert:Xx,meshnormal_frag:qx,meshphong_vert:Yx,meshphong_frag:Kx,meshphysical_vert:$x,meshphysical_frag:Zx,meshtoon_vert:Jx,meshtoon_frag:jx,points_vert:Qx,points_frag:t_,shadow_vert:e_,shadow_frag:n_,sprite_vert:i_,sprite_frag:s_},pt={common:{diffuse:{value:new ct(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new kt}},envmap:{envMap:{value:null},envMapRotation:{value:new kt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new kt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new kt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new kt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new kt},normalScale:{value:new Pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new kt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new kt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new kt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new kt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new ct(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 C},probesMax:{value:new C},probesResolution:{value:new C}},points:{diffuse:{value:new ct(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0},uvTransform:{value:new kt}},sprite:{diffuse:{value:new ct(16777215)},opacity:{value:1},center:{value:new Pt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new kt},alphaMap:{value:null},alphaMapTransform:{value:new kt},alphaTest:{value:0}}},di={basic:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Xt.meshbasic_vert,fragmentShader:Xt.meshbasic_frag},lambert:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},envMapIntensity:{value:1}}]),vertexShader:Xt.meshlambert_vert,fragmentShader:Xt.meshlambert_frag},phong:{uniforms:un([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},specular:{value:new ct(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphong_vert,fragmentShader:Xt.meshphong_frag},standard:{uniforms:un([pt.common,pt.envmap,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.roughnessmap,pt.metalnessmap,pt.fog,pt.lights,{emissive:{value:new ct(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag},toon:{uniforms:un([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new ct(0)}}]),vertexShader:Xt.meshtoon_vert,fragmentShader:Xt.meshtoon_frag},matcap:{uniforms:un([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Xt.meshmatcap_vert,fragmentShader:Xt.meshmatcap_frag},points:{uniforms:un([pt.points,pt.fog]),vertexShader:Xt.points_vert,fragmentShader:Xt.points_frag},dashed:{uniforms:un([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Xt.linedashed_vert,fragmentShader:Xt.linedashed_frag},depth:{uniforms:un([pt.common,pt.displacementmap]),vertexShader:Xt.depth_vert,fragmentShader:Xt.depth_frag},normal:{uniforms:un([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Xt.meshnormal_vert,fragmentShader:Xt.meshnormal_frag},sprite:{uniforms:un([pt.sprite,pt.fog]),vertexShader:Xt.sprite_vert,fragmentShader:Xt.sprite_frag},background:{uniforms:{uvTransform:{value:new kt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Xt.background_vert,fragmentShader:Xt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new kt}},vertexShader:Xt.backgroundCube_vert,fragmentShader:Xt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Xt.cube_vert,fragmentShader:Xt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Xt.equirect_vert,fragmentShader:Xt.equirect_frag},distance:{uniforms:un([pt.common,pt.displacementmap,{referencePosition:{value:new C},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Xt.distance_vert,fragmentShader:Xt.distance_frag},shadow:{uniforms:un([pt.lights,pt.fog,{color:{value:new ct(0)},opacity:{value:1}}]),vertexShader:Xt.shadow_vert,fragmentShader:Xt.shadow_frag}};di.physical={uniforms:un([di.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new kt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new kt},clearcoatNormalScale:{value:new Pt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new kt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new kt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new kt},sheen:{value:0},sheenColor:{value:new ct(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new kt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new kt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new kt},transmissionSamplerSize:{value:new Pt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new kt},attenuationDistance:{value:0},attenuationColor:{value:new ct(0)},specularColor:{value:new ct(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new kt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new kt},anisotropyVector:{value:new Pt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new kt}}]),vertexShader:Xt.meshphysical_vert,fragmentShader:Xt.meshphysical_frag};const Eo={r:0,b:0,g:0},r_=new Wt,rm=new kt;rm.set(-1,0,0,0,1,0,0,0,1);function a_(s,t,e,n,i,r){const a=new ct(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(S){let E=S.isScene===!0?S.background:null;if(E&&E.isTexture){const _=S.backgroundBlurriness>0;E=t.get(E,_)}return E}function p(S){let E=!1;const _=f(S);_===null?g(a,o):_&&_.isColor&&(g(_,1),E=!0);const b=s.xr.getEnvironmentBlendMode();b==="additive"?e.buffers.color.setClear(0,0,0,1,r):b==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(s.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(S,E){const _=f(E);_&&(_.isCubeTexture||_.mapping===Ec)?(l===void 0&&(l=new qt(new Vn(1,1,1),new Ae({name:"BackgroundCubeMaterial",uniforms:Nr(di.backgroundCube.uniforms),vertexShader:di.backgroundCube.vertexShader,fragmentShader:di.backgroundCube.fragmentShader,side:ze,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(b,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=_,l.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(r_.makeRotationFromEuler(E.backgroundRotation)).transpose(),_.isCubeTexture&&_.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(rm),l.material.toneMapped=jt.getTransfer(_.colorSpace)!==se,(h!==_||u!==_.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=_,u=_.version,d=s.toneMapping),l.layers.enableAll(),S.unshift(l,l.geometry,l.material,0,0,null)):_&&_.isTexture&&(c===void 0&&(c=new qt(new Wi(2,2),new Ae({name:"BackgroundMaterial",uniforms:Nr(di.background.uniforms),vertexShader:di.background.vertexShader,fragmentShader:di.background.fragmentShader,side:us,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=_,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=jt.getTransfer(_.colorSpace)!==se,_.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(),S.unshift(c,c.geometry,c.material,0,0,null))}function g(S,E){S.getRGB(Eo,Qp(s)),e.buffers.color.setClear(Eo.r,Eo.g,Eo.b,E,r)}function m(){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(S,E=1){a.set(S),o=E,g(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(S){o=S,g(a,o)},render:p,addToRenderList:v,dispose:m}}function o_(s,t){const e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,I,F,H,O){let V=!1;const k=u(D,H,F,I);r!==k&&(r=k,l(r.object)),V=f(D,H,F,O),V&&p(D,H,F,O),O!==null&&t.update(O,s.ELEMENT_ARRAY_BUFFER),(V||a)&&(a=!1,_(D,I,F,H),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,I,F,H){const O=H.wireframe===!0;let V=n[I.id];V===void 0&&(V={},n[I.id]=V);const k=D.isInstancedMesh===!0?D.id:0;let Y=V[k];Y===void 0&&(Y={},V[k]=Y);let tt=Y[F.id];tt===void 0&&(tt={},Y[F.id]=tt);let J=tt[O];return J===void 0&&(J=d(c()),tt[O]=J),J}function d(D){const I=[],F=[],H=[];for(let O=0;O<e;O++)I[O]=0,F[O]=0,H[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:F,attributeDivisors:H,object:D,attributes:{},index:null}}function f(D,I,F,H){const O=r.attributes,V=I.attributes;let k=0;const Y=F.getAttributes();for(const tt in Y)if(Y[tt].location>=0){const nt=O[tt];let at=V[tt];if(at===void 0&&(tt==="instanceMatrix"&&D.instanceMatrix&&(at=D.instanceMatrix),tt==="instanceColor"&&D.instanceColor&&(at=D.instanceColor)),nt===void 0||nt.attribute!==at||at&&nt.data!==at.data)return!0;k++}return r.attributesNum!==k||r.index!==H}function p(D,I,F,H){const O={},V=I.attributes;let k=0;const Y=F.getAttributes();for(const tt in Y)if(Y[tt].location>=0){let nt=V[tt];nt===void 0&&(tt==="instanceMatrix"&&D.instanceMatrix&&(nt=D.instanceMatrix),tt==="instanceColor"&&D.instanceColor&&(nt=D.instanceColor));const at={};at.attribute=nt,nt&&nt.data&&(at.data=nt.data),O[tt]=at,k++}r.attributes=O,r.attributesNum=k,r.index=H}function v(){const D=r.newAttributes;for(let I=0,F=D.length;I<F;I++)D[I]=0}function g(D){m(D,0)}function m(D,I){const F=r.newAttributes,H=r.enabledAttributes,O=r.attributeDivisors;F[D]=1,H[D]===0&&(s.enableVertexAttribArray(D),H[D]=1),O[D]!==I&&(s.vertexAttribDivisor(D,I),O[D]=I)}function S(){const D=r.newAttributes,I=r.enabledAttributes;for(let F=0,H=I.length;F<H;F++)I[F]!==D[F]&&(s.disableVertexAttribArray(F),I[F]=0)}function E(D,I,F,H,O,V,k){k===!0?s.vertexAttribIPointer(D,I,F,O,V):s.vertexAttribPointer(D,I,F,H,O,V)}function _(D,I,F,H){v();const O=H.attributes,V=F.getAttributes(),k=I.defaultAttributeValues;for(const Y in V){const tt=V[Y];if(tt.location>=0){let J=O[Y];if(J===void 0&&(Y==="instanceMatrix"&&D.instanceMatrix&&(J=D.instanceMatrix),Y==="instanceColor"&&D.instanceColor&&(J=D.instanceColor)),J!==void 0){const nt=J.normalized,at=J.itemSize,Ht=t.get(J);if(Ht===void 0)continue;const $t=Ht.buffer,Bt=Ht.type,K=Ht.bytesPerElement,rt=Bt===s.INT||Bt===s.UNSIGNED_INT||J.gpuType===Ru;if(J.isInterleavedBufferAttribute){const it=J.data,B=it.stride,Et=J.offset;if(it.isInstancedInterleavedBuffer){for(let It=0;It<tt.locationSize;It++)m(tt.location+It,it.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=it.meshPerAttribute*it.count)}else for(let It=0;It<tt.locationSize;It++)g(tt.location+It);s.bindBuffer(s.ARRAY_BUFFER,$t);for(let It=0;It<tt.locationSize;It++)E(tt.location+It,at/tt.locationSize,Bt,nt,B*K,(Et+at/tt.locationSize*It)*K,rt)}else{if(J.isInstancedBufferAttribute){for(let it=0;it<tt.locationSize;it++)m(tt.location+it,J.meshPerAttribute);D.isInstancedMesh!==!0&&H._maxInstanceCount===void 0&&(H._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let it=0;it<tt.locationSize;it++)g(tt.location+it);s.bindBuffer(s.ARRAY_BUFFER,$t);for(let it=0;it<tt.locationSize;it++)E(tt.location+it,at/tt.locationSize,Bt,nt,at*K,at/tt.locationSize*it*K,rt)}}else if(k!==void 0){const nt=k[Y];if(nt!==void 0)switch(nt.length){case 2:s.vertexAttrib2fv(tt.location,nt);break;case 3:s.vertexAttrib3fv(tt.location,nt);break;case 4:s.vertexAttrib4fv(tt.location,nt);break;default:s.vertexAttrib1fv(tt.location,nt)}}}}S()}function b(){A();for(const D in n){const I=n[D];for(const F in I){const H=I[F];for(const O in H){const V=H[O];for(const k in V)h(V[k].object),delete V[k];delete H[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const F in I){const H=I[F];for(const O in H){const V=H[O];for(const k in V)h(V[k].object),delete V[k];delete H[O]}}delete n[D.id]}function R(D){for(const I in n){const F=n[I];for(const H in F){const O=F[H];if(O[D.id]===void 0)continue;const V=O[D.id];for(const k in V)h(V[k].object),delete V[k];delete O[D.id]}}}function M(D){for(const I in n){const F=n[I],H=D.isInstancedMesh===!0?D.id:0,O=F[H];if(O!==void 0){for(const V in O){const k=O[V];for(const Y in k)h(k[Y].object),delete k[Y];delete O[V]}delete F[H],Object.keys(F).length===0&&delete n[I]}}}function A(){P(),a=!0,r!==i&&(r=i,l(r.object))}function P(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:P,dispose:b,releaseStatesOfGeometry:w,releaseStatesOfObject:M,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:g,disableUnusedAttributes:S}}function c_(s,t,e){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function l_(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==vn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const M=R===cn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==In&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Gn&&!M)}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=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(wt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&wt("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),g=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),S=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),E=s.getParameter(s.MAX_VARYING_VECTORS),_=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),b=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:g,maxAttributes:m,maxVertexUniforms:S,maxVaryings:E,maxFragmentUniforms:_,maxSamples:b,samples:w}}function h_(s){const t=this;let e=null,n=0,i=!1,r=!1;const a=new Ss,o=new kt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,g=u.clipShadows,m=s.get(u);if(!i||p===null||p.length===0||r&&!g)r?h(null):l();else{const S=r?0:n,E=S*4;let _=m.clippingState||null;c.value=_,_=h(p,d,E,f);for(let b=0;b!==E;++b)_[b]=e[b];m.clippingState=_,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=S}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let g=null;if(v!==0){if(g=c.value,p!==!0||g===null){const m=f+v*4,S=d.matrixWorldInverse;o.getNormalMatrix(S),(g===null||g.length<m)&&(g=new Float32Array(m));for(let E=0,_=f;E!==v;++E,_+=4)a.copy(u[E]).applyMatrix4(S,o),a.normal.toArray(g,_),g[_+3]=a.constant}c.value=g,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,g}}const os=4,P0=[.125,.215,.35,.446,.526,.582],ws=20,u_=256,jr=new Hs,I0=new ct;let vl=null,Ml=0,xl=0,_l=!1;const d_=new C;class L0{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:o=d_}=r;vl=this._renderer.getRenderTarget(),Ml=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),_l=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=U0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=O0(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(t){this._lodMax=Math.floor(Math.log2(t)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let t=0;t<this._lodMeshes.length;t++)this._lodMeshes[t].geometry.dispose()}_cleanup(t){this._renderer.setRenderTarget(vl,Ml,xl),this._renderer.xr.enabled=_l,t.scissorTest=!1,dr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Os||t.mapping===Ir?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),vl=this._renderer.getRenderTarget(),Ml=this._renderer.getActiveCubeFace(),xl=this._renderer.getActiveMipmapLevel(),_l=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:ye,minFilter:ye,generateMipmaps:!1,type:cn,format:vn,colorSpace:ac,depthBuffer:!1},i=N0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=N0(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=f_(r)),this._blurMaterial=m_(r,t,e),this._ggxMaterial=p_(r,t,e)}return i}_compileMaterial(t){const e=new qt(new we,t);this._renderer.compile(e,jr)}_sceneToCubeUV(t,e,n,i,r){const c=new En(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(I0),u.toneMapping=_i,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new qt(new Vn,new zi({name:"PMREM.Background",side:ze,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,g=v.material;let m=!1;const S=t.background;S?S.isColor&&(g.color.copy(S),t.background=null,m=!0):(g.color.copy(I0),m=!0);for(let E=0;E<6;E++){const _=E%3;_===0?(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[E],r.y,r.z)):_===1?(c.up.set(0,0,l[E]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[E],r.z)):(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[E]));const b=this._cubeSize;dr(i,_*b,E>2?b:0,b,b),u.setRenderTarget(i),m&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=S}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Os||t.mapping===Ir;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=U0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=O0());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;dr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,jr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:p}=this,v=this._sizeLods[n],g=3*v*(n>p-os?n-p+os:0),m=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,dr(r,g,m,3*v,2*v),i.setRenderTarget(r),i.render(o,jr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=p-n,dr(t,g,m,3*v,2*v),i.setRenderTarget(t),i.render(o,jr)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&zt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*ws-1),v=r/p,g=isFinite(r)?1+Math.floor(h*v):ws;g>ws&&wt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${g} samples when the maximum is set to ${ws}`);const m=[];let S=0;for(let R=0;R<ws;++R){const M=R/v,A=Math.exp(-M*M/2);m.push(A),R===0?S+=A:R<g&&(S+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/S;d.envMap.value=t.texture,d.samples.value=g,d.weights.value=m,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=p,d.mipInt.value=E-n;const _=this._sizeLods[i],b=3*_*(i>E-os?i-E+os:0),w=4*(this._cubeSize-_);dr(e,b,w,3*_,2*_),c.setRenderTarget(e),c.render(u,jr)}}function f_(s){const t=[],e=[],n=[];let i=s;const r=s-os+1+P0.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>s-os?c=P0[a-s+os-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,p=6,v=3,g=2,m=1,S=new Float32Array(v*p*f),E=new Float32Array(g*p*f),_=new Float32Array(m*p*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,M=w>2?0:-1,A=[R,M,0,R+2/3,M,0,R+2/3,M+1,0,R,M,0,R+2/3,M+1,0,R,M+1,0];S.set(A,v*p*w),E.set(d,g*p*w);const P=[w,w,w,w,w,w];_.set(P,m*p*w)}const b=new we;b.setAttribute("position",new de(S,v)),b.setAttribute("uv",new de(E,g)),b.setAttribute("faceIndex",new de(_,m)),n.push(new qt(b,null)),i>os&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function N0(s,t,e){const n=new wn(s,t,e);return n.texture.mapping=Ec,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function dr(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function p_(s,t,e){return new Ae({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:u_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Tc(),fragmentShader:`
4193
4193
 
4194
4194
  precision highp float;
4195
4195
  precision highp int;
@@ -4293,7 +4293,7 @@ void main() {
4293
4293
 
4294
4294
  gl_FragColor = vec4(prefilteredColor, 1.0);
4295
4295
  }
4296
- `,blending:Mi,depthTest:!1,depthWrite:!1})}function m_(s,t,e){const n=new Float32Array(ws),i=new C(0,1,0);return new Ae({name:"SphericalGaussianBlur",defines:{n:ws,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Tc(),fragmentShader:`
4296
+ `,blending:xi,depthTest:!1,depthWrite:!1})}function m_(s,t,e){const n=new Float32Array(ws),i=new C(0,1,0);return new Ae({name:"SphericalGaussianBlur",defines:{n:ws,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:Tc(),fragmentShader:`
4297
4297
 
4298
4298
  precision mediump float;
4299
4299
  precision mediump int;
@@ -4353,7 +4353,7 @@ void main() {
4353
4353
  }
4354
4354
 
4355
4355
  }
4356
- `,blending:Mi,depthTest:!1,depthWrite:!1})}function O0(){return new Ae({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Tc(),fragmentShader:`
4356
+ `,blending:xi,depthTest:!1,depthWrite:!1})}function O0(){return new Ae({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:Tc(),fragmentShader:`
4357
4357
 
4358
4358
  precision mediump float;
4359
4359
  precision mediump int;
@@ -4372,7 +4372,7 @@ void main() {
4372
4372
  gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
4373
4373
 
4374
4374
  }
4375
- `,blending:Mi,depthTest:!1,depthWrite:!1})}function U0(){return new Ae({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Tc(),fragmentShader:`
4375
+ `,blending:xi,depthTest:!1,depthWrite:!1})}function U0(){return new Ae({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:Tc(),fragmentShader:`
4376
4376
 
4377
4377
  precision mediump float;
4378
4378
  precision mediump int;
@@ -4388,7 +4388,7 @@ void main() {
4388
4388
  gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
4389
4389
 
4390
4390
  }
4391
- `,blending:Mi,depthTest:!1,depthWrite:!1})}function Tc(){return`
4391
+ `,blending:xi,depthTest:!1,depthWrite:!1})}function Tc(){return`
4392
4392
 
4393
4393
  precision mediump float;
4394
4394
  precision mediump int;
@@ -4478,7 +4478,7 @@ void main() {
4478
4478
  gl_FragColor = texture2D( tEquirect, sampleUV );
4479
4479
 
4480
4480
  }
4481
- `},i=new Vn(5,5,5),r=new Ae({name:"CubemapFromEquirect",uniforms:Nr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ze,blending:Mi});r.uniforms.tEquirect.value=e;const a=new qt(i,r),o=e.minFilter;return e.minFilter===Ds&&(e.minFilter=ye),new d2(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}}function g_(s){let t=new WeakMap,e=new WeakMap,n=null;function i(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===zc||f===kc)if(t.has(d)){const p=t.get(d).texture;return o(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const v=new am(p.height);return v.fromEquirectangularTexture(s,d),t.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===zc||f===kc,v=f===Os||f===Ir;if(p||v){let g=e.get(d);const m=g!==void 0?g.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new L0(s)),g=p?n.fromEquirectangular(d,g):n.fromCubemap(d,g),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),g.texture;if(g!==void 0)return g.texture;{const S=d.image;return p&&S&&S.height>0||v&&S&&c(S)?(n===null&&(n=new L0(s)),g=p?n.fromEquirectangular(d):n.fromCubemap(d),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),d.addEventListener("dispose",h),g.texture):null}}}return d}function o(d,f){return f===zc?d.mapping=Os:f===kc&&(d.mapping=Ir),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=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:u}}function v_(s){const t={};function e(n){if(t[n]!==void 0)return t[n];const i=s.getExtension(n);return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const i=e(n);return i===null&&wr("WebGLRenderer: "+n+" extension not supported."),i}}}function M_(s,t,e,n){const i={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const p in d.attributes)t.remove(d.attributes[p]);d.removeEventListener("dispose",a),delete i[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.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 S=f.array;v=f.version;for(let E=0,_=S.length;E<_;E+=3){const b=S[E+0],w=S[E+1],R=S[E+2];d.push(b,w,w,R,R,b)}}else{const S=p.array;v=p.version;for(let E=0,_=S.length/3-1;E<_;E+=3){const b=E+0,w=E+1,R=E+2;d.push(b,w,w,R,R,b)}}const g=new(p.count>=65535?ku:qp)(d,1);g.version=v;const m=r.get(u);m&&t.remove(m),r.set(u,g)}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 x_(s,t,e){let n;function i(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){s.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,f){f!==0&&(s.drawElementsInstanced(n,d,r,u*a,f),e.update(d,n,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let v=0;for(let g=0;g<f;g++)v+=d[g];e.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function __(s){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case s.TRIANGLES:e.triangles+=o*(r/3);break;case s.LINES:e.lines+=o*(r/2);break;case s.LINE_STRIP:e.lines+=o*(r-1);break;case s.LINE_LOOP:e.lines+=o*r;break;case s.POINTS:e.points+=o*r;break;default:zt("WebGLInfo: Unknown draw mode:",a);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function y_(s,t,e){const n=new WeakMap,i=new le;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let A=function(){R.dispose(),n.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,g=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let E=0;f===!0&&(E=1),p===!0&&(E=2),v===!0&&(E=3);let _=o.attributes.position.count*E,b=1;_>t.maxTextureSize&&(b=Math.ceil(_/t.maxTextureSize),_=t.maxTextureSize);const w=new Float32Array(_*b*4*u),R=new Vp(w,_,b,u);R.type=Gn,R.needsUpdate=!0;const M=E*4;for(let P=0;P<u;P++){const D=g[P],I=m[P],F=S[P],H=_*b*4*P;for(let O=0;O<D.count;O++){const V=O*M;f===!0&&(i.fromBufferAttribute(D,O),w[H+V+0]=i.x,w[H+V+1]=i.y,w[H+V+2]=i.z,w[H+V+3]=0),p===!0&&(i.fromBufferAttribute(I,O),w[H+V+4]=i.x,w[H+V+5]=i.y,w[H+V+6]=i.z,w[H+V+7]=0),v===!0&&(i.fromBufferAttribute(F,O),w[H+V+8]=i.x,w[H+V+9]=i.y,w[H+V+10]=i.z,w[H+V+11]=F.itemSize===4?i.w:1)}}d={count:u,texture:R,size:new Pt(_,b)},n.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",a.morphTexture,e);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,e),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function S_(s,t,e,n,i){let r=new WeakMap;function a(l){const h=i.render.frame,u=l.geometry,d=t.get(l,u);if(r.get(d)!==h&&(t.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(e.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&e.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),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const b_={[Rp]:"LINEAR_TONE_MAPPING",[Dp]:"REINHARD_TONE_MAPPING",[Cp]:"CINEON_TONE_MAPPING",[Pp]:"ACES_FILMIC_TONE_MAPPING",[Lp]:"AGX_TONE_MAPPING",[Np]:"NEUTRAL_TONE_MAPPING",[Ip]:"CUSTOM_TONE_MAPPING"};function E_(s,t,e,n,i,r){const a=new wn(t,e,{type:s,depthBuffer:i,stencilBuffer:r,samples:n?4:0,depthTexture:i?new Fs(t,e):void 0}),o=new wn(t,e,{type:cn,depthBuffer:!1,stencilBuffer:!1}),c=new we;c.setAttribute("position",new Ee([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Ee([0,2,0,0,2,0],2));const l=new Vv({uniforms:{tDiffuse:{value:null}},vertexShader:`
4481
+ `},i=new Vn(5,5,5),r=new Ae({name:"CubemapFromEquirect",uniforms:Nr(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:ze,blending:xi});r.uniforms.tEquirect.value=e;const a=new qt(i,r),o=e.minFilter;return e.minFilter===Ds&&(e.minFilter=ye),new d2(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}}function g_(s){let t=new WeakMap,e=new WeakMap,n=null;function i(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===zc||f===kc)if(t.has(d)){const p=t.get(d).texture;return o(p,d.mapping)}else{const p=d.image;if(p&&p.height>0){const v=new am(p.height);return v.fromEquirectangularTexture(s,d),t.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===zc||f===kc,v=f===Os||f===Ir;if(p||v){let g=e.get(d);const m=g!==void 0?g.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new L0(s)),g=p?n.fromEquirectangular(d,g):n.fromCubemap(d,g),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),g.texture;if(g!==void 0)return g.texture;{const S=d.image;return p&&S&&S.height>0||v&&S&&c(S)?(n===null&&(n=new L0(s)),g=p?n.fromEquirectangular(d):n.fromCubemap(d),g.texture.pmremVersion=d.pmremVersion,e.set(d,g),d.addEventListener("dispose",h),g.texture):null}}}return d}function o(d,f){return f===zc?d.mapping=Os:f===kc&&(d.mapping=Ir),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=t.get(f);p!==void 0&&(t.delete(f),p.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const p=e.get(f);p!==void 0&&(e.delete(f),p.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:u}}function v_(s){const t={};function e(n){if(t[n]!==void 0)return t[n];const i=s.getExtension(n);return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const i=e(n);return i===null&&wr("WebGLRenderer: "+n+" extension not supported."),i}}}function M_(s,t,e,n){const i={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const p in d.attributes)t.remove(d.attributes[p]);d.removeEventListener("dispose",a),delete i[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.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 S=f.array;v=f.version;for(let E=0,_=S.length;E<_;E+=3){const b=S[E+0],w=S[E+1],R=S[E+2];d.push(b,w,w,R,R,b)}}else{const S=p.array;v=p.version;for(let E=0,_=S.length/3-1;E<_;E+=3){const b=E+0,w=E+1,R=E+2;d.push(b,w,w,R,R,b)}}const g=new(p.count>=65535?ku:qp)(d,1);g.version=v;const m=r.get(u);m&&t.remove(m),r.set(u,g)}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 x_(s,t,e){let n;function i(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){s.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,f){f!==0&&(s.drawElementsInstanced(n,d,r,u*a,f),e.update(d,n,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let v=0;for(let g=0;g<f;g++)v+=d[g];e.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function __(s){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case s.TRIANGLES:e.triangles+=o*(r/3);break;case s.LINES:e.lines+=o*(r/2);break;case s.LINE_STRIP:e.lines+=o*(r-1);break;case s.LINE_LOOP:e.lines+=o*r;break;case s.POINTS:e.points+=o*r;break;default:zt("WebGLInfo: Unknown draw mode:",a);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function y_(s,t,e){const n=new WeakMap,i=new le;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let A=function(){R.dispose(),n.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,g=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],S=o.morphAttributes.color||[];let E=0;f===!0&&(E=1),p===!0&&(E=2),v===!0&&(E=3);let _=o.attributes.position.count*E,b=1;_>t.maxTextureSize&&(b=Math.ceil(_/t.maxTextureSize),_=t.maxTextureSize);const w=new Float32Array(_*b*4*u),R=new Vp(w,_,b,u);R.type=Gn,R.needsUpdate=!0;const M=E*4;for(let P=0;P<u;P++){const D=g[P],I=m[P],F=S[P],H=_*b*4*P;for(let O=0;O<D.count;O++){const V=O*M;f===!0&&(i.fromBufferAttribute(D,O),w[H+V+0]=i.x,w[H+V+1]=i.y,w[H+V+2]=i.z,w[H+V+3]=0),p===!0&&(i.fromBufferAttribute(I,O),w[H+V+4]=i.x,w[H+V+5]=i.y,w[H+V+6]=i.z,w[H+V+7]=0),v===!0&&(i.fromBufferAttribute(F,O),w[H+V+8]=i.x,w[H+V+9]=i.y,w[H+V+10]=i.z,w[H+V+11]=F.itemSize===4?i.w:1)}}d={count:u,texture:R,size:new Pt(_,b)},n.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",a.morphTexture,e);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,e),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function S_(s,t,e,n,i){let r=new WeakMap;function a(l){const h=i.render.frame,u=l.geometry,d=t.get(l,u);if(r.get(d)!==h&&(t.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(e.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&e.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),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const b_={[Rp]:"LINEAR_TONE_MAPPING",[Dp]:"REINHARD_TONE_MAPPING",[Cp]:"CINEON_TONE_MAPPING",[Pp]:"ACES_FILMIC_TONE_MAPPING",[Lp]:"AGX_TONE_MAPPING",[Np]:"NEUTRAL_TONE_MAPPING",[Ip]:"CUSTOM_TONE_MAPPING"};function E_(s,t,e,n,i,r){const a=new wn(t,e,{type:s,depthBuffer:i,stencilBuffer:r,samples:n?4:0,depthTexture:i?new Fs(t,e):void 0}),o=new wn(t,e,{type:cn,depthBuffer:!1,stencilBuffer:!1}),c=new we;c.setAttribute("position",new Ee([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Ee([0,2,0,0,2,0],2));const l=new Vv({uniforms:{tDiffuse:{value:null}},vertexShader:`
4482
4482
  precision highp float;
4483
4483
 
4484
4484
  uniform mat4 modelViewMatrix;
@@ -4524,7 +4524,7 @@ void main() {
4524
4524
  #ifdef SRGB_TRANSFER
4525
4525
  gl_FragColor = sRGBTransferOETF( gl_FragColor );
4526
4526
  #endif
4527
- }`,depthTest:!1,depthWrite:!1}),h=new qt(c,l),u=new Hs(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,g=null,m=[],S=!1;this.setSize=function(E,_){a.setSize(E,_),o.setSize(E,_);for(let b=0;b<m.length;b++){const w=m[b];w.setSize&&w.setSize(E,_)}},this.setEffects=function(E){m=E,S=m.length>0&&m[0].isRenderPass===!0;const _=a.width,b=a.height;for(let w=0;w<m.length;w++){const R=m[w];R.setSize&&R.setSize(_,b)}},this.begin=function(E,_){if(p||E.toneMapping===xi&&m.length===0)return!1;if(g=_,_!==null){const b=_.width,w=_.height;(a.width!==b||a.height!==w)&&this.setSize(b,w)}return S===!1&&E.setRenderTarget(a),v=E.toneMapping,E.toneMapping=xi,!0},this.hasRenderPass=function(){return S},this.end=function(E,_){E.toneMapping=v,p=!0;let b=a,w=o;for(let R=0;R<m.length;R++){const M=m[R];if(M.enabled!==!1&&(M.render(E,w,b,_),M.needsSwap!==!1)){const A=b;b=w,w=A}}if(d!==E.outputColorSpace||f!==E.toneMapping){d=E.outputColorSpace,f=E.toneMapping,l.defines={},jt.getTransfer(d)===se&&(l.defines.SRGB_TRANSFER="");const R=b_[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=b.texture,E.setRenderTarget(g),E.render(h,u),g=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 om=new en,qh=new Fs(1,1),cm=new Vp,lm=new Wp,hm=new Jp,F0=[],z0=[],k0=new Float32Array(16),B0=new Float32Array(9),H0=new Float32Array(4);function kr(s,t,e){const n=s[0];if(n<=0||n>0)return s;const i=t*e;let r=F0[i];if(r===void 0&&(r=new Float32Array(i),F0[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function Xe(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function qe(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function Rc(s,t){let e=z0[t];e===void 0&&(e=new Int32Array(t),z0[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function w_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function A_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2fv(this.addr,t),qe(e,t)}}function T_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Xe(e,t))return;s.uniform3fv(this.addr,t),qe(e,t)}}function R_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4fv(this.addr,t),qe(e,t)}}function D_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;H0.set(n),s.uniformMatrix2fv(this.addr,!1,H0),qe(e,n)}}function C_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;B0.set(n),s.uniformMatrix3fv(this.addr,!1,B0),qe(e,n)}}function P_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;k0.set(n),s.uniformMatrix4fv(this.addr,!1,k0),qe(e,n)}}function I_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function L_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2iv(this.addr,t),qe(e,t)}}function N_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Xe(e,t))return;s.uniform3iv(this.addr,t),qe(e,t)}}function O_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4iv(this.addr,t),qe(e,t)}}function U_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function F_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2uiv(this.addr,t),qe(e,t)}}function z_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Xe(e,t))return;s.uniform3uiv(this.addr,t),qe(e,t)}}function k_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4uiv(this.addr,t),qe(e,t)}}function B_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(qh.compareFunction=e.isReversedDepthBuffer()?Ou:Nu,r=qh):r=om,e.setTexture2D(t||r,i)}function H_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||lm,i)}function G_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||hm,i)}function V_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||cm,i)}function W_(s){switch(s){case 5126:return w_;case 35664:return A_;case 35665:return T_;case 35666:return R_;case 35674:return D_;case 35675:return C_;case 35676:return P_;case 5124:case 35670:return I_;case 35667:case 35671:return L_;case 35668:case 35672:return N_;case 35669:case 35673:return O_;case 5125:return U_;case 36294:return F_;case 36295:return z_;case 36296:return k_;case 35678:case 36198:case 36298:case 36306:case 35682:return B_;case 35679:case 36299:case 36307:return H_;case 35680:case 36300:case 36308:case 36293:return G_;case 36289:case 36303:case 36311:case 36292:return V_}}function X_(s,t){s.uniform1fv(this.addr,t)}function q_(s,t){const e=kr(t,this.size,2);s.uniform2fv(this.addr,e)}function Y_(s,t){const e=kr(t,this.size,3);s.uniform3fv(this.addr,e)}function K_(s,t){const e=kr(t,this.size,4);s.uniform4fv(this.addr,e)}function $_(s,t){const e=kr(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function Z_(s,t){const e=kr(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function J_(s,t){const e=kr(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function j_(s,t){s.uniform1iv(this.addr,t)}function Q_(s,t){s.uniform2iv(this.addr,t)}function ty(s,t){s.uniform3iv(this.addr,t)}function ey(s,t){s.uniform4iv(this.addr,t)}function ny(s,t){s.uniform1uiv(this.addr,t)}function iy(s,t){s.uniform2uiv(this.addr,t)}function sy(s,t){s.uniform3uiv(this.addr,t)}function ry(s,t){s.uniform4uiv(this.addr,t)}function ay(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=qh:a=om;for(let o=0;o!==i;++o)e.setTexture2D(t[o]||a,r[o])}function oy(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTexture3D(t[a]||lm,r[a])}function cy(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTextureCube(t[a]||hm,r[a])}function ly(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTexture2DArray(t[a]||cm,r[a])}function hy(s){switch(s){case 5126:return X_;case 35664:return q_;case 35665:return Y_;case 35666:return K_;case 35674:return $_;case 35675:return Z_;case 35676:return J_;case 5124:case 35670:return j_;case 35667:case 35671:return Q_;case 35668:case 35672:return ty;case 35669:case 35673:return ey;case 5125:return ny;case 36294:return iy;case 36295:return sy;case 36296:return ry;case 35678:case 36198:case 36298:case 36306:case 35682:return ay;case 35679:case 36299:case 36307:return oy;case 35680:case 36300:case 36308:case 36293:return cy;case 36289:case 36303:case 36311:case 36292:return ly}}class uy{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=W_(e.type)}}class dy{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=hy(e.type)}}class fy{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(t,e[o.id],n)}}}const yl=/(\w+)(\])?(\[|\.)?/g;function G0(s,t){s.seq.push(t),s.map[t.id]=t}function py(s,t,e){const n=s.name,i=n.length;for(yl.lastIndex=0;;){const r=yl.exec(n),a=yl.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===i){G0(e,l===void 0?new uy(o,s,t):new dy(o,s,t));break}else{let u=e.map[o];u===void 0&&(u=new fy(o),G0(e,u)),e=u}}}class $o{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);py(o,c,this)}const i=[],r=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){const o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const a=t[i];a.id in e&&n.push(a)}return n}}function V0(s,t,e){const n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}const my=37297;let gy=0;function vy(s,t){const e=s.split(`
4527
+ }`,depthTest:!1,depthWrite:!1}),h=new qt(c,l),u=new Hs(-1,1,1,-1,0,1);let d=null,f=null,p=!1,v,g=null,m=[],S=!1;this.setSize=function(E,_){a.setSize(E,_),o.setSize(E,_);for(let b=0;b<m.length;b++){const w=m[b];w.setSize&&w.setSize(E,_)}},this.setEffects=function(E){m=E,S=m.length>0&&m[0].isRenderPass===!0;const _=a.width,b=a.height;for(let w=0;w<m.length;w++){const R=m[w];R.setSize&&R.setSize(_,b)}},this.begin=function(E,_){if(p||E.toneMapping===_i&&m.length===0)return!1;if(g=_,_!==null){const b=_.width,w=_.height;(a.width!==b||a.height!==w)&&this.setSize(b,w)}return S===!1&&E.setRenderTarget(a),v=E.toneMapping,E.toneMapping=_i,!0},this.hasRenderPass=function(){return S},this.end=function(E,_){E.toneMapping=v,p=!0;let b=a,w=o;for(let R=0;R<m.length;R++){const M=m[R];if(M.enabled!==!1&&(M.render(E,w,b,_),M.needsSwap!==!1)){const A=b;b=w,w=A}}if(d!==E.outputColorSpace||f!==E.toneMapping){d=E.outputColorSpace,f=E.toneMapping,l.defines={},jt.getTransfer(d)===se&&(l.defines.SRGB_TRANSFER="");const R=b_[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=b.texture,E.setRenderTarget(g),E.render(h,u),g=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 om=new en,qh=new Fs(1,1),cm=new Vp,lm=new Wp,hm=new Jp,F0=[],z0=[],k0=new Float32Array(16),B0=new Float32Array(9),H0=new Float32Array(4);function kr(s,t,e){const n=s[0];if(n<=0||n>0)return s;const i=t*e;let r=F0[i];if(r===void 0&&(r=new Float32Array(i),F0[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function Xe(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function qe(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function Rc(s,t){let e=z0[t];e===void 0&&(e=new Int32Array(t),z0[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function w_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function A_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2fv(this.addr,t),qe(e,t)}}function T_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Xe(e,t))return;s.uniform3fv(this.addr,t),qe(e,t)}}function R_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4fv(this.addr,t),qe(e,t)}}function D_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;H0.set(n),s.uniformMatrix2fv(this.addr,!1,H0),qe(e,n)}}function C_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;B0.set(n),s.uniformMatrix3fv(this.addr,!1,B0),qe(e,n)}}function P_(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(Xe(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),qe(e,t)}else{if(Xe(e,n))return;k0.set(n),s.uniformMatrix4fv(this.addr,!1,k0),qe(e,n)}}function I_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function L_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2iv(this.addr,t),qe(e,t)}}function N_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Xe(e,t))return;s.uniform3iv(this.addr,t),qe(e,t)}}function O_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4iv(this.addr,t),qe(e,t)}}function U_(s,t){const e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function F_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Xe(e,t))return;s.uniform2uiv(this.addr,t),qe(e,t)}}function z_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Xe(e,t))return;s.uniform3uiv(this.addr,t),qe(e,t)}}function k_(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(Xe(e,t))return;s.uniform4uiv(this.addr,t),qe(e,t)}}function B_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(qh.compareFunction=e.isReversedDepthBuffer()?Ou:Nu,r=qh):r=om,e.setTexture2D(t||r,i)}function H_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||lm,i)}function G_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||hm,i)}function V_(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||cm,i)}function W_(s){switch(s){case 5126:return w_;case 35664:return A_;case 35665:return T_;case 35666:return R_;case 35674:return D_;case 35675:return C_;case 35676:return P_;case 5124:case 35670:return I_;case 35667:case 35671:return L_;case 35668:case 35672:return N_;case 35669:case 35673:return O_;case 5125:return U_;case 36294:return F_;case 36295:return z_;case 36296:return k_;case 35678:case 36198:case 36298:case 36306:case 35682:return B_;case 35679:case 36299:case 36307:return H_;case 35680:case 36300:case 36308:case 36293:return G_;case 36289:case 36303:case 36311:case 36292:return V_}}function X_(s,t){s.uniform1fv(this.addr,t)}function q_(s,t){const e=kr(t,this.size,2);s.uniform2fv(this.addr,e)}function Y_(s,t){const e=kr(t,this.size,3);s.uniform3fv(this.addr,e)}function K_(s,t){const e=kr(t,this.size,4);s.uniform4fv(this.addr,e)}function $_(s,t){const e=kr(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function Z_(s,t){const e=kr(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function J_(s,t){const e=kr(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function j_(s,t){s.uniform1iv(this.addr,t)}function Q_(s,t){s.uniform2iv(this.addr,t)}function ty(s,t){s.uniform3iv(this.addr,t)}function ey(s,t){s.uniform4iv(this.addr,t)}function ny(s,t){s.uniform1uiv(this.addr,t)}function iy(s,t){s.uniform2uiv(this.addr,t)}function sy(s,t){s.uniform3uiv(this.addr,t)}function ry(s,t){s.uniform4uiv(this.addr,t)}function ay(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=qh:a=om;for(let o=0;o!==i;++o)e.setTexture2D(t[o]||a,r[o])}function oy(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTexture3D(t[a]||lm,r[a])}function cy(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTextureCube(t[a]||hm,r[a])}function ly(s,t,e){const n=this.cache,i=t.length,r=Rc(e,i);Xe(n,r)||(s.uniform1iv(this.addr,r),qe(n,r));for(let a=0;a!==i;++a)e.setTexture2DArray(t[a]||cm,r[a])}function hy(s){switch(s){case 5126:return X_;case 35664:return q_;case 35665:return Y_;case 35666:return K_;case 35674:return $_;case 35675:return Z_;case 35676:return J_;case 5124:case 35670:return j_;case 35667:case 35671:return Q_;case 35668:case 35672:return ty;case 35669:case 35673:return ey;case 5125:return ny;case 36294:return iy;case 36295:return sy;case 36296:return ry;case 35678:case 36198:case 36298:case 36306:case 35682:return ay;case 35679:case 36299:case 36307:return oy;case 35680:case 36300:case 36308:case 36293:return cy;case 36289:case 36303:case 36311:case 36292:return ly}}class uy{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=W_(e.type)}}class dy{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=hy(e.type)}}class fy{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(t,e[o.id],n)}}}const yl=/(\w+)(\])?(\[|\.)?/g;function G0(s,t){s.seq.push(t),s.map[t.id]=t}function py(s,t,e){const n=s.name,i=n.length;for(yl.lastIndex=0;;){const r=yl.exec(n),a=yl.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===i){G0(e,l===void 0?new uy(o,s,t):new dy(o,s,t));break}else{let u=e.map[o];u===void 0&&(u=new fy(o),G0(e,u)),e=u}}}class $o{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);py(o,c,this)}const i=[],r=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){const o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const a=t[i];a.id in e&&n.push(a)}return n}}function V0(s,t,e){const n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}const my=37297;let gy=0;function vy(s,t){const e=s.split(`
4528
4528
  `),n=[],i=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
4529
4529
  `)}const W0=new kt;function My(s){jt._getMatrix(W0,jt.workingColorSpace,s);const t=`mat3( ${W0.elements.map(e=>e.toFixed(4))} )`;switch(jt.getTransfer(s)){case oc:return[t,"LinearTransferOETF"];case se:return[t,"sRGBTransferOETF"];default:return wt("WebGLProgram: Unsupported color space: ",s),[t,"LinearTransferOETF"]}}function X0(s,t,e){const n=s.getShaderParameter(t,s.COMPILE_STATUS),r=(s.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
4530
4530
 
@@ -4561,7 +4561,7 @@ void main() {
4561
4561
  `),m.length>0&&(m+=`
4562
4562
  `)):(g=[$0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
4563
4563
  `].filter(ca).join(`
4564
- `),m=[$0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==xi?"#define TONE_MAPPING":"",e.toneMapping!==xi?Xt.tonemapping_pars_fragment:"",e.toneMapping!==xi?yy("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Xt.colorspace_pars_fragment,xy("linearToOutputTexel",e.outputColorSpace),Sy(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
4564
+ `),m=[$0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,p,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==_i?"#define TONE_MAPPING":"",e.toneMapping!==_i?Xt.tonemapping_pars_fragment:"",e.toneMapping!==_i?yy("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Xt.colorspace_pars_fragment,xy("linearToOutputTexel",e.outputColorSpace),Sy(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
4565
4565
  `].filter(ca).join(`
4566
4566
  `)),a=Yh(a),a=q0(a,e),a=Y0(a,e),o=Yh(o),o=q0(o,e),o=Y0(o,e),a=K0(a),o=K0(o),e.isRawShaderMaterial!==!0&&(S=`#version 300 es
4567
4567
  `,g=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
@@ -4575,7 +4575,7 @@ Material Type: `+D.type+`
4575
4575
 
4576
4576
  Program Info Log: `+O+`
4577
4577
  `+J+`
4578
- `+nt)}else O!==""?wt("WebGLProgram: Program Info Log:",O):(V===""||k==="")&&(tt=!1);tt&&(D.diagnostics={runnable:Y,programLog:O,vertexShader:{log:V,prefix:g},fragmentShader:{log:k,prefix:m}})}i.deleteShader(b),i.deleteShader(w),M=new $o(i,v),A=wy(i,v)}let M;this.getUniforms=function(){return M===void 0&&R(this),M};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let P=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,my)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=gy++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=w,this}let Hy=0;class Gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const i=this._getShaderCacheForMaterial(t);return i.has(e)===!1&&(i.add(e),e.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Vy(t),e.set(t,n)),n}}class Vy{constructor(t){this.id=Hy++,this.code=t,this.usedTimes=0}}function Wy(s){return s===Us||s===nc||s===ic}function Xy(s,t,e,n,i,r){const a=new zu,o=new Gy,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return c.add(M),M===0?"uv":`uv${M}`}function v(M,A,P,D,I,F){const H=D.fog,O=I.geometry,V=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?D.environment:null,k=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,Y=t.get(M.envMap||V,k),tt=Y&&Y.mapping===Ec?Y.image.height:null,J=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&wt("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const nt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,at=nt!==void 0?nt.length:0;let Ht=0;O.morphAttributes.position!==void 0&&(Ht=1),O.morphAttributes.normal!==void 0&&(Ht=2),O.morphAttributes.color!==void 0&&(Ht=3);let $t,Bt,K,rt;if(J){const yt=ui[J];$t=yt.vertexShader,Bt=yt.fragmentShader}else{$t=M.vertexShader,Bt=M.fragmentShader;const yt=o.getVertexShaderStage(M),De=o.getFragmentShaderStage(M);o.update(M,yt,De),K=yt.id,rt=De.id}const it=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),Et=I.isInstancedMesh===!0,It=I.isBatchedMesh===!0,Tt=!!M.map,xt=!!M.matcap,Nt=!!Y,Ot=!!M.aoMap,Ut=!!M.lightMap,ee=!!M.bumpMap&&M.wireframe===!1,ne=!!M.normalMap,Te=!!M.displacementMap,ve=!!M.emissiveMap,Re=!!M.metalnessMap,Be=!!M.roughnessMap,N=M.anisotropy>0,xn=M.clearcoat>0,ie=M.dispersion>0,T=M.iridescence>0,x=M.sheen>0,z=M.transmission>0,X=N&&!!M.anisotropyMap,$=xn&&!!M.clearcoatMap,st=xn&&!!M.clearcoatNormalMap,lt=xn&&!!M.clearcoatRoughnessMap,Z=T&&!!M.iridescenceMap,Q=T&&!!M.iridescenceThicknessMap,ht=x&&!!M.sheenColorMap,Rt=x&&!!M.sheenRoughnessMap,ft=!!M.specularMap,ut=!!M.specularColorMap,Lt=!!M.specularIntensityMap,Ft=z&&!!M.transmissionMap,Gt=z&&!!M.thicknessMap,L=!!M.gradientMap,ot=!!M.alphaMap,j=M.alphaTest>0,dt=!!M.alphaHash,vt=!!M.extensions;let et=xi;M.toneMapped&&(it===null||it.isXRRenderTarget===!0)&&(et=s.toneMapping);const At={shaderID:J,shaderType:M.type,shaderName:M.name,vertexShader:$t,fragmentShader:Bt,defines:M.defines,customVertexShaderID:K,customFragmentShaderID:rt,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:It,batchingColor:It&&I._colorsTexture!==null,instancing:Et,instancingColor:Et&&I.instanceColor!==null,instancingMorph:Et&&I.morphTexture!==null,outputColorSpace:it===null?s.outputColorSpace:it.isXRRenderTarget===!0?it.texture.colorSpace:jt.workingColorSpace,alphaToCoverage:!!M.alphaToCoverage,map:Tt,matcap:xt,envMap:Nt,envMapMode:Nt&&Y.mapping,envMapCubeUVHeight:tt,aoMap:Ot,lightMap:Ut,bumpMap:ee,normalMap:ne,displacementMap:Te,emissiveMap:ve,normalMapObjectSpace:ne&&M.normalMapType===O1,normalMapTangentSpace:ne&&M.normalMapType===rc,packedNormalMap:ne&&M.normalMapType===rc&&Wy(M.normalMap.format),metalnessMap:Re,roughnessMap:Be,anisotropy:N,anisotropyMap:X,clearcoat:xn,clearcoatMap:$,clearcoatNormalMap:st,clearcoatRoughnessMap:lt,dispersion:ie,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:ht,sheenRoughnessMap:Rt,specularMap:ft,specularColorMap:ut,specularIntensityMap:Lt,transmission:z,transmissionMap:Ft,thicknessMap:Gt,gradientMap:L,opaque:M.transparent===!1&&M.blending===Er&&M.alphaToCoverage===!1,alphaMap:ot,alphaTest:j,alphaHash:dt,combine:M.combine,mapUv:Tt&&p(M.map.channel),aoMapUv:Ot&&p(M.aoMap.channel),lightMapUv:Ut&&p(M.lightMap.channel),bumpMapUv:ee&&p(M.bumpMap.channel),normalMapUv:ne&&p(M.normalMap.channel),displacementMapUv:Te&&p(M.displacementMap.channel),emissiveMapUv:ve&&p(M.emissiveMap.channel),metalnessMapUv:Re&&p(M.metalnessMap.channel),roughnessMapUv:Be&&p(M.roughnessMap.channel),anisotropyMapUv:X&&p(M.anisotropyMap.channel),clearcoatMapUv:$&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:st&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:Rt&&p(M.sheenRoughnessMap.channel),specularMapUv:ft&&p(M.specularMap.channel),specularColorMapUv:ut&&p(M.specularColorMap.channel),specularIntensityMapUv:Lt&&p(M.specularIntensityMap.channel),transmissionMapUv:Ft&&p(M.transmissionMap.channel),thicknessMapUv:Gt&&p(M.thicknessMap.channel),alphaMapUv:ot&&p(M.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ne||N),vertexNormals:!!O.attributes.normal,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(Tt||ot),fog:!!H,useFog:M.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||O.attributes.normal===void 0&&ne===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:Ht,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:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:et,decodeVideoTexture:Tt&&M.map.isVideoTexture===!0&&jt.getTransfer(M.map.colorSpace)===se,decodeVideoTextureEmissive:ve&&M.emissiveMap.isVideoTexture===!0&&jt.getTransfer(M.emissiveMap.colorSpace)===se,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===$n,flipSided:M.side===ze,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:vt&&M.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&M.extensions.multiDraw===!0||It)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function g(M){const A=[];if(M.shaderID?A.push(M.shaderID):(A.push(M.customVertexShaderID),A.push(M.customFragmentShaderID)),M.defines!==void 0)for(const P in M.defines)A.push(P),A.push(M.defines[P]);return M.isRawShaderMaterial===!1&&(m(A,M),S(A,M),A.push(s.outputColorSpace)),A.push(M.customProgramCacheKey),A.join()}function m(M,A){M.push(A.precision),M.push(A.outputColorSpace),M.push(A.envMapMode),M.push(A.envMapCubeUVHeight),M.push(A.mapUv),M.push(A.alphaMapUv),M.push(A.lightMapUv),M.push(A.aoMapUv),M.push(A.bumpMapUv),M.push(A.normalMapUv),M.push(A.displacementMapUv),M.push(A.emissiveMapUv),M.push(A.metalnessMapUv),M.push(A.roughnessMapUv),M.push(A.anisotropyMapUv),M.push(A.clearcoatMapUv),M.push(A.clearcoatNormalMapUv),M.push(A.clearcoatRoughnessMapUv),M.push(A.iridescenceMapUv),M.push(A.iridescenceThicknessMapUv),M.push(A.sheenColorMapUv),M.push(A.sheenRoughnessMapUv),M.push(A.specularMapUv),M.push(A.specularColorMapUv),M.push(A.specularIntensityMapUv),M.push(A.transmissionMapUv),M.push(A.thicknessMapUv),M.push(A.combine),M.push(A.fogExp2),M.push(A.sizeAttenuation),M.push(A.morphTargetsCount),M.push(A.morphAttributeCount),M.push(A.numDirLights),M.push(A.numPointLights),M.push(A.numSpotLights),M.push(A.numSpotLightMaps),M.push(A.numHemiLights),M.push(A.numRectAreaLights),M.push(A.numDirLightShadows),M.push(A.numPointLightShadows),M.push(A.numSpotLightShadows),M.push(A.numSpotLightShadowsWithMaps),M.push(A.numLightProbes),M.push(A.shadowMapType),M.push(A.toneMapping),M.push(A.numClippingPlanes),M.push(A.numClipIntersection),M.push(A.depthPacking)}function S(M,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),M.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),M.push(a.mask)}function E(M){const A=f[M.type];let P;if(A){const D=ui[A];P=Bv.clone(D.uniforms)}else P=M.uniforms;return P}function _(M,A){let P=h.get(A);return P!==void 0?++P.usedTimes:(P=new By(s,A,M,i),l.push(P),h.set(A,P)),P}function b(M){if(--M.usedTimes===0){const A=l.indexOf(M);l[A]=l[l.length-1],l.pop(),h.delete(M.cacheKey),M.destroy()}}function w(M){o.remove(M)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:g,getUniforms:E,acquireProgram:_,releaseProgram:b,releaseShaderCache:w,programs:l,dispose:R}}function qy(){let s=new WeakMap;function t(a){return s.has(a)}function e(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function Yy(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.materialVariant!==t.materialVariant?s.materialVariant-t.materialVariant:s.z!==t.z?s.z-t.z:s.id-t.id}function Z0(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function J0(){const s=[];let t=0;const e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,g,m){let S=s[t];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:g,group:m},s[t]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=g,S.group=m),t++,S}function c(d,f,p,v,g,m){const S=o(d,f,p,v,g,m);p.transmission>0?n.push(S):p.transparent===!0?i.push(S):e.push(S)}function l(d,f,p,v,g,m){const S=o(d,f,p,v,g,m);p.transmission>0?n.unshift(S):p.transparent===!0?i.unshift(S):e.unshift(S)}function h(d,f,p){e.length>1&&e.sort(d||Yy),n.length>1&&n.sort(f||Z0),i.length>1&&i.sort(f||Z0),p&&(e.reverse(),n.reverse(),i.reverse())}function u(){for(let d=t,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:e,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function Ky(){let s=new WeakMap;function t(n,i){const r=s.get(n);let a;return r===void 0?(a=new J0,s.set(n,[a])):i>=r.length?(a=new J0,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function $y(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new C,color:new ct};break;case"SpotLight":e={position:new C,direction:new C,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new ct,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":e={color:new ct,position:new C,halfWidth:new C,halfHeight:new C};break}return s[t.id]=e,e}}}function Zy(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}let Jy=0;function jy(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function Qy(s){const t=new $y,e=Zy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new C);const i=new C,r=new Wt,a=new Wt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,p=0,v=0,g=0,m=0,S=0,E=0,_=0,b=0,w=0,R=0;l.sort(jy);for(let A=0,P=l.length;A<P;A++){const D=l[A],I=D.color,F=D.intensity,H=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Us?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*F,u+=I.g*F,d+=I.b*F;else if(D.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(D.sh.coefficients[V],F);R++}else if(D.isDirectionalLight){const V=t.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const k=D.shadow,Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,n.directionalShadow[f]=Y,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=V,f++}else if(D.isSpotLight){const V=t.get(D);V.position.setFromMatrixPosition(D.matrixWorld),V.color.copy(I).multiplyScalar(F),V.distance=H,V.coneCos=Math.cos(D.angle),V.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),V.decay=D.decay,n.spot[v]=V;const k=D.shadow;if(D.map&&(n.spotLightMap[b]=D.map,b++,k.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=k.matrix,D.castShadow){const Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,n.spotShadow[v]=Y,n.spotShadowMap[v]=O,_++}v++}else if(D.isRectAreaLight){const V=t.get(D);V.color.copy(I).multiplyScalar(F),V.halfWidth.set(D.width*.5,0,0),V.halfHeight.set(0,D.height*.5,0),n.rectArea[g]=V,g++}else if(D.isPointLight){const V=t.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),V.distance=D.distance,V.decay=D.decay,D.castShadow){const k=D.shadow,Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,Y.shadowCameraNear=k.camera.near,Y.shadowCameraFar=k.camera.far,n.pointShadow[p]=Y,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=D.shadow.matrix,E++}n.point[p]=V,p++}else if(D.isHemisphereLight){const V=t.get(D);V.skyColor.copy(D.color).multiplyScalar(F),V.groundColor.copy(D.groundColor).multiplyScalar(F),n.hemi[m]=V,m++}}g>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pt.LTC_FLOAT_1,n.rectAreaLTC2=pt.LTC_FLOAT_2):(n.rectAreaLTC1=pt.LTC_HALF_1,n.rectAreaLTC2=pt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==v||M.rectAreaLength!==g||M.hemiLength!==m||M.numDirectionalShadows!==S||M.numPointShadows!==E||M.numSpotShadows!==_||M.numSpotMaps!==b||M.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=_+b-w,n.spotLightMap.length=b,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,M.directionalLength=f,M.pointLength=p,M.spotLength=v,M.rectAreaLength=g,M.hemiLength=m,M.numDirectionalShadows=S,M.numPointShadows=E,M.numSpotShadows=_,M.numSpotMaps=b,M.numLightProbes=R,n.version=Jy++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const g=h.matrixWorldInverse;for(let m=0,S=l.length;m<S;m++){const E=l[m];if(E.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),u++}else if(E.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),_.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),f++}else if(E.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),a.identity(),r.copy(E.matrixWorld),r.premultiply(g),a.extractRotation(r),_.halfWidth.set(E.width*.5,0,0),_.halfHeight.set(0,E.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(E.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),d++}else if(E.isHemisphereLight){const _=n.hemi[v];_.direction.setFromMatrixPosition(E.matrixWorld),_.direction.transformDirection(g),v++}}}return{setup:o,setupView:c,state:n}}function j0(s){const t=new Qy(s),e=[],n=[],i=[];function r(d){u.camera=d,e.length=0,n.length=0,i.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function t3(s){let t=new WeakMap;function e(i,r=0){const a=t.get(i);let o;return a===void 0?(o=new j0(s),t.set(i,[o])):r>=a.length?(o=new j0(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const e3=`void main() {
4578
+ `+nt)}else O!==""?wt("WebGLProgram: Program Info Log:",O):(V===""||k==="")&&(tt=!1);tt&&(D.diagnostics={runnable:Y,programLog:O,vertexShader:{log:V,prefix:g},fragmentShader:{log:k,prefix:m}})}i.deleteShader(b),i.deleteShader(w),M=new $o(i,v),A=wy(i,v)}let M;this.getUniforms=function(){return M===void 0&&R(this),M};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let P=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return P===!1&&(P=i.getProgramParameter(v,my)),P},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=gy++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=b,this.fragmentShader=w,this}let Hy=0;class Gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const i=this._getShaderCacheForMaterial(t);return i.has(e)===!1&&(i.add(e),e.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new Vy(t),e.set(t,n)),n}}class Vy{constructor(t){this.id=Hy++,this.code=t,this.usedTimes=0}}function Wy(s){return s===Us||s===nc||s===ic}function Xy(s,t,e,n,i,r){const a=new zu,o=new Gy,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(M){return c.add(M),M===0?"uv":`uv${M}`}function v(M,A,P,D,I,F){const H=D.fog,O=I.geometry,V=M.isMeshStandardMaterial||M.isMeshLambertMaterial||M.isMeshPhongMaterial?D.environment:null,k=M.isMeshStandardMaterial||M.isMeshLambertMaterial&&!M.envMap||M.isMeshPhongMaterial&&!M.envMap,Y=t.get(M.envMap||V,k),tt=Y&&Y.mapping===Ec?Y.image.height:null,J=f[M.type];M.precision!==null&&(d=n.getMaxPrecision(M.precision),d!==M.precision&&wt("WebGLProgram.getParameters:",M.precision,"not supported, using",d,"instead."));const nt=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,at=nt!==void 0?nt.length:0;let Ht=0;O.morphAttributes.position!==void 0&&(Ht=1),O.morphAttributes.normal!==void 0&&(Ht=2),O.morphAttributes.color!==void 0&&(Ht=3);let $t,Bt,K,rt;if(J){const yt=di[J];$t=yt.vertexShader,Bt=yt.fragmentShader}else{$t=M.vertexShader,Bt=M.fragmentShader;const yt=o.getVertexShaderStage(M),De=o.getFragmentShaderStage(M);o.update(M,yt,De),K=yt.id,rt=De.id}const it=s.getRenderTarget(),B=s.state.buffers.depth.getReversed(),Et=I.isInstancedMesh===!0,It=I.isBatchedMesh===!0,Tt=!!M.map,xt=!!M.matcap,Nt=!!Y,Ot=!!M.aoMap,Ut=!!M.lightMap,ee=!!M.bumpMap&&M.wireframe===!1,ne=!!M.normalMap,Te=!!M.displacementMap,ve=!!M.emissiveMap,Re=!!M.metalnessMap,Be=!!M.roughnessMap,N=M.anisotropy>0,xn=M.clearcoat>0,ie=M.dispersion>0,T=M.iridescence>0,x=M.sheen>0,z=M.transmission>0,X=N&&!!M.anisotropyMap,$=xn&&!!M.clearcoatMap,st=xn&&!!M.clearcoatNormalMap,lt=xn&&!!M.clearcoatRoughnessMap,Z=T&&!!M.iridescenceMap,Q=T&&!!M.iridescenceThicknessMap,ht=x&&!!M.sheenColorMap,Rt=x&&!!M.sheenRoughnessMap,ft=!!M.specularMap,ut=!!M.specularColorMap,Lt=!!M.specularIntensityMap,Ft=z&&!!M.transmissionMap,Gt=z&&!!M.thicknessMap,L=!!M.gradientMap,ot=!!M.alphaMap,j=M.alphaTest>0,dt=!!M.alphaHash,vt=!!M.extensions;let et=_i;M.toneMapped&&(it===null||it.isXRRenderTarget===!0)&&(et=s.toneMapping);const At={shaderID:J,shaderType:M.type,shaderName:M.name,vertexShader:$t,fragmentShader:Bt,defines:M.defines,customVertexShaderID:K,customFragmentShaderID:rt,isRawShaderMaterial:M.isRawShaderMaterial===!0,glslVersion:M.glslVersion,precision:d,batching:It,batchingColor:It&&I._colorsTexture!==null,instancing:Et,instancingColor:Et&&I.instanceColor!==null,instancingMorph:Et&&I.morphTexture!==null,outputColorSpace:it===null?s.outputColorSpace:it.isXRRenderTarget===!0?it.texture.colorSpace:jt.workingColorSpace,alphaToCoverage:!!M.alphaToCoverage,map:Tt,matcap:xt,envMap:Nt,envMapMode:Nt&&Y.mapping,envMapCubeUVHeight:tt,aoMap:Ot,lightMap:Ut,bumpMap:ee,normalMap:ne,displacementMap:Te,emissiveMap:ve,normalMapObjectSpace:ne&&M.normalMapType===O1,normalMapTangentSpace:ne&&M.normalMapType===rc,packedNormalMap:ne&&M.normalMapType===rc&&Wy(M.normalMap.format),metalnessMap:Re,roughnessMap:Be,anisotropy:N,anisotropyMap:X,clearcoat:xn,clearcoatMap:$,clearcoatNormalMap:st,clearcoatRoughnessMap:lt,dispersion:ie,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:ht,sheenRoughnessMap:Rt,specularMap:ft,specularColorMap:ut,specularIntensityMap:Lt,transmission:z,transmissionMap:Ft,thicknessMap:Gt,gradientMap:L,opaque:M.transparent===!1&&M.blending===Er&&M.alphaToCoverage===!1,alphaMap:ot,alphaTest:j,alphaHash:dt,combine:M.combine,mapUv:Tt&&p(M.map.channel),aoMapUv:Ot&&p(M.aoMap.channel),lightMapUv:Ut&&p(M.lightMap.channel),bumpMapUv:ee&&p(M.bumpMap.channel),normalMapUv:ne&&p(M.normalMap.channel),displacementMapUv:Te&&p(M.displacementMap.channel),emissiveMapUv:ve&&p(M.emissiveMap.channel),metalnessMapUv:Re&&p(M.metalnessMap.channel),roughnessMapUv:Be&&p(M.roughnessMap.channel),anisotropyMapUv:X&&p(M.anisotropyMap.channel),clearcoatMapUv:$&&p(M.clearcoatMap.channel),clearcoatNormalMapUv:st&&p(M.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(M.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(M.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(M.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(M.sheenColorMap.channel),sheenRoughnessMapUv:Rt&&p(M.sheenRoughnessMap.channel),specularMapUv:ft&&p(M.specularMap.channel),specularColorMapUv:ut&&p(M.specularColorMap.channel),specularIntensityMapUv:Lt&&p(M.specularIntensityMap.channel),transmissionMapUv:Ft&&p(M.transmissionMap.channel),thicknessMapUv:Gt&&p(M.thicknessMap.channel),alphaMapUv:ot&&p(M.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ne||N),vertexNormals:!!O.attributes.normal,vertexColors:M.vertexColors,vertexAlphas:M.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(Tt||ot),fog:!!H,useFog:M.fog===!0,fogExp2:!!H&&H.isFogExp2,flatShading:M.wireframe===!1&&(M.flatShading===!0||O.attributes.normal===void 0&&ne===!1&&(M.isMeshLambertMaterial||M.isMeshPhongMaterial||M.isMeshStandardMaterial||M.isMeshPhysicalMaterial)),sizeAttenuation:M.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:at,morphTextureStride:Ht,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:F.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:M.dithering,shadowMapEnabled:s.shadowMap.enabled&&P.length>0,shadowMapType:s.shadowMap.type,toneMapping:et,decodeVideoTexture:Tt&&M.map.isVideoTexture===!0&&jt.getTransfer(M.map.colorSpace)===se,decodeVideoTextureEmissive:ve&&M.emissiveMap.isVideoTexture===!0&&jt.getTransfer(M.emissiveMap.colorSpace)===se,premultipliedAlpha:M.premultipliedAlpha,doubleSided:M.side===Zn,flipSided:M.side===ze,useDepthPacking:M.depthPacking>=0,depthPacking:M.depthPacking||0,index0AttributeName:M.index0AttributeName,extensionClipCullDistance:vt&&M.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&M.extensions.multiDraw===!0||It)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:M.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function g(M){const A=[];if(M.shaderID?A.push(M.shaderID):(A.push(M.customVertexShaderID),A.push(M.customFragmentShaderID)),M.defines!==void 0)for(const P in M.defines)A.push(P),A.push(M.defines[P]);return M.isRawShaderMaterial===!1&&(m(A,M),S(A,M),A.push(s.outputColorSpace)),A.push(M.customProgramCacheKey),A.join()}function m(M,A){M.push(A.precision),M.push(A.outputColorSpace),M.push(A.envMapMode),M.push(A.envMapCubeUVHeight),M.push(A.mapUv),M.push(A.alphaMapUv),M.push(A.lightMapUv),M.push(A.aoMapUv),M.push(A.bumpMapUv),M.push(A.normalMapUv),M.push(A.displacementMapUv),M.push(A.emissiveMapUv),M.push(A.metalnessMapUv),M.push(A.roughnessMapUv),M.push(A.anisotropyMapUv),M.push(A.clearcoatMapUv),M.push(A.clearcoatNormalMapUv),M.push(A.clearcoatRoughnessMapUv),M.push(A.iridescenceMapUv),M.push(A.iridescenceThicknessMapUv),M.push(A.sheenColorMapUv),M.push(A.sheenRoughnessMapUv),M.push(A.specularMapUv),M.push(A.specularColorMapUv),M.push(A.specularIntensityMapUv),M.push(A.transmissionMapUv),M.push(A.thicknessMapUv),M.push(A.combine),M.push(A.fogExp2),M.push(A.sizeAttenuation),M.push(A.morphTargetsCount),M.push(A.morphAttributeCount),M.push(A.numDirLights),M.push(A.numPointLights),M.push(A.numSpotLights),M.push(A.numSpotLightMaps),M.push(A.numHemiLights),M.push(A.numRectAreaLights),M.push(A.numDirLightShadows),M.push(A.numPointLightShadows),M.push(A.numSpotLightShadows),M.push(A.numSpotLightShadowsWithMaps),M.push(A.numLightProbes),M.push(A.shadowMapType),M.push(A.toneMapping),M.push(A.numClippingPlanes),M.push(A.numClipIntersection),M.push(A.depthPacking)}function S(M,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),M.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),M.push(a.mask)}function E(M){const A=f[M.type];let P;if(A){const D=di[A];P=Bv.clone(D.uniforms)}else P=M.uniforms;return P}function _(M,A){let P=h.get(A);return P!==void 0?++P.usedTimes:(P=new By(s,A,M,i),l.push(P),h.set(A,P)),P}function b(M){if(--M.usedTimes===0){const A=l.indexOf(M);l[A]=l[l.length-1],l.pop(),h.delete(M.cacheKey),M.destroy()}}function w(M){o.remove(M)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:g,getUniforms:E,acquireProgram:_,releaseProgram:b,releaseShaderCache:w,programs:l,dispose:R}}function qy(){let s=new WeakMap;function t(a){return s.has(a)}function e(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function Yy(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.materialVariant!==t.materialVariant?s.materialVariant-t.materialVariant:s.z!==t.z?s.z-t.z:s.id-t.id}function Z0(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function J0(){const s=[];let t=0;const e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,g,m){let S=s[t];return S===void 0?(S={id:d.id,object:d,geometry:f,material:p,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:g,group:m},s[t]=S):(S.id=d.id,S.object=d,S.geometry=f,S.material=p,S.materialVariant=a(d),S.groupOrder=v,S.renderOrder=d.renderOrder,S.z=g,S.group=m),t++,S}function c(d,f,p,v,g,m){const S=o(d,f,p,v,g,m);p.transmission>0?n.push(S):p.transparent===!0?i.push(S):e.push(S)}function l(d,f,p,v,g,m){const S=o(d,f,p,v,g,m);p.transmission>0?n.unshift(S):p.transparent===!0?i.unshift(S):e.unshift(S)}function h(d,f,p){e.length>1&&e.sort(d||Yy),n.length>1&&n.sort(f||Z0),i.length>1&&i.sort(f||Z0),p&&(e.reverse(),n.reverse(),i.reverse())}function u(){for(let d=t,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:e,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function Ky(){let s=new WeakMap;function t(n,i){const r=s.get(n);let a;return r===void 0?(a=new J0,s.set(n,[a])):i>=r.length?(a=new J0,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function $y(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new C,color:new ct};break;case"SpotLight":e={position:new C,direction:new C,color:new ct,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new C,color:new ct,distance:0,decay:0};break;case"HemisphereLight":e={direction:new C,skyColor:new ct,groundColor:new ct};break;case"RectAreaLight":e={color:new ct,position:new C,halfWidth:new C,halfHeight:new C};break}return s[t.id]=e,e}}}function Zy(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}let Jy=0;function jy(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function Qy(s){const t=new $y,e=Zy(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new C);const i=new C,r=new Wt,a=new Wt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,p=0,v=0,g=0,m=0,S=0,E=0,_=0,b=0,w=0,R=0;l.sort(jy);for(let A=0,P=l.length;A<P;A++){const D=l[A],I=D.color,F=D.intensity,H=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Us?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*F,u+=I.g*F,d+=I.b*F;else if(D.isLightProbe){for(let V=0;V<9;V++)n.probe[V].addScaledVector(D.sh.coefficients[V],F);R++}else if(D.isDirectionalLight){const V=t.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const k=D.shadow,Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,n.directionalShadow[f]=Y,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,S++}n.directional[f]=V,f++}else if(D.isSpotLight){const V=t.get(D);V.position.setFromMatrixPosition(D.matrixWorld),V.color.copy(I).multiplyScalar(F),V.distance=H,V.coneCos=Math.cos(D.angle),V.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),V.decay=D.decay,n.spot[v]=V;const k=D.shadow;if(D.map&&(n.spotLightMap[b]=D.map,b++,k.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=k.matrix,D.castShadow){const Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,n.spotShadow[v]=Y,n.spotShadowMap[v]=O,_++}v++}else if(D.isRectAreaLight){const V=t.get(D);V.color.copy(I).multiplyScalar(F),V.halfWidth.set(D.width*.5,0,0),V.halfHeight.set(0,D.height*.5,0),n.rectArea[g]=V,g++}else if(D.isPointLight){const V=t.get(D);if(V.color.copy(D.color).multiplyScalar(D.intensity),V.distance=D.distance,V.decay=D.decay,D.castShadow){const k=D.shadow,Y=e.get(D);Y.shadowIntensity=k.intensity,Y.shadowBias=k.bias,Y.shadowNormalBias=k.normalBias,Y.shadowRadius=k.radius,Y.shadowMapSize=k.mapSize,Y.shadowCameraNear=k.camera.near,Y.shadowCameraFar=k.camera.far,n.pointShadow[p]=Y,n.pointShadowMap[p]=O,n.pointShadowMatrix[p]=D.shadow.matrix,E++}n.point[p]=V,p++}else if(D.isHemisphereLight){const V=t.get(D);V.skyColor.copy(D.color).multiplyScalar(F),V.groundColor.copy(D.groundColor).multiplyScalar(F),n.hemi[m]=V,m++}}g>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=pt.LTC_FLOAT_1,n.rectAreaLTC2=pt.LTC_FLOAT_2):(n.rectAreaLTC1=pt.LTC_HALF_1,n.rectAreaLTC2=pt.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const M=n.hash;(M.directionalLength!==f||M.pointLength!==p||M.spotLength!==v||M.rectAreaLength!==g||M.hemiLength!==m||M.numDirectionalShadows!==S||M.numPointShadows!==E||M.numSpotShadows!==_||M.numSpotMaps!==b||M.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=g,n.point.length=p,n.hemi.length=m,n.directionalShadow.length=S,n.directionalShadowMap.length=S,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=_,n.spotShadowMap.length=_,n.directionalShadowMatrix.length=S,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=_+b-w,n.spotLightMap.length=b,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,M.directionalLength=f,M.pointLength=p,M.spotLength=v,M.rectAreaLength=g,M.hemiLength=m,M.numDirectionalShadows=S,M.numPointShadows=E,M.numSpotShadows=_,M.numSpotMaps=b,M.numLightProbes=R,n.version=Jy++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const g=h.matrixWorldInverse;for(let m=0,S=l.length;m<S;m++){const E=l[m];if(E.isDirectionalLight){const _=n.directional[u];_.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),u++}else if(E.isSpotLight){const _=n.spot[f];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),_.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),_.direction.sub(i),_.direction.transformDirection(g),f++}else if(E.isRectAreaLight){const _=n.rectArea[p];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),a.identity(),r.copy(E.matrixWorld),r.premultiply(g),a.extractRotation(r),_.halfWidth.set(E.width*.5,0,0),_.halfHeight.set(0,E.height*.5,0),_.halfWidth.applyMatrix4(a),_.halfHeight.applyMatrix4(a),p++}else if(E.isPointLight){const _=n.point[d];_.position.setFromMatrixPosition(E.matrixWorld),_.position.applyMatrix4(g),d++}else if(E.isHemisphereLight){const _=n.hemi[v];_.direction.setFromMatrixPosition(E.matrixWorld),_.direction.transformDirection(g),v++}}}return{setup:o,setupView:c,state:n}}function j0(s){const t=new Qy(s),e=[],n=[],i=[];function r(d){u.camera=d,e.length=0,n.length=0,i.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function t3(s){let t=new WeakMap;function e(i,r=0){const a=t.get(i);let o;return a===void 0?(o=new j0(s),t.set(i,[o])):r>=a.length?(o=new j0(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const e3=`void main() {
4579
4579
  gl_Position = vec4( position, 1.0 );
4580
4580
  }`,n3=`uniform sampler2D shadow_pass;
4581
4581
  uniform vec2 resolution;
@@ -4602,7 +4602,7 @@ void main() {
4602
4602
  squared_mean = squared_mean / samples;
4603
4603
  float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
4604
4604
  gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
4605
- }`,i3=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],s3=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],Q0=new Wt,Qr=new C,Sl=new C;function r3(s,t,e){let n=new Bu;const i=new Pt,r=new Pt,a=new le,o=new Xv,c=new qv,l={},h=e.maxTextureSize,u={[us]:ze,[ze]:us,[$n]:$n},d=new Ae({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pt},radius:{value:4}},vertexShader:e3,fragmentShader:n3}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new we;p.setAttribute("position",new de(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new qt(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=da;let m=this.type;this.render=function(w,R,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;this.type===h1&&(wt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=da);const A=s.getRenderTarget(),P=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),I=s.state;I.setBlending(Mi),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const F=m!==this.type;F&&R.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(O=>O.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,O=w.length;H<O;H++){const V=w[H],k=V.shadow;if(k===void 0){wt("WebGLShadowMap:",V,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;i.copy(k.mapSize);const Y=k.getFrameExtents();i.multiply(Y),r.copy(k.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,k.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,k.mapSize.y=r.y));const tt=s.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||F===!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){wt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new wn(i.x,i.y,{format:Us,type:cn,minFilter:ye,magFilter:ye,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Fs(i.x,i.y,Gn),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=ki,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=We,k.map.depthTexture.magFilter=We}else V.isPointLight?(k.map=new am(i.x),k.map.depthTexture=new zv(i.x,ti)):(k.map=new wn(i.x,i.y),k.map.depthTexture=new Fs(i.x,i.y,ti)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=ki,this.type===da?(k.map.depthTexture.compareFunction=tt?Ou:Nu,k.map.depthTexture.minFilter=ye,k.map.depthTexture.magFilter=ye):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=We,k.map.depthTexture.magFilter=We);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let nt=0;nt<J;nt++){if(k.map.isWebGLCubeRenderTarget)s.setRenderTarget(k.map,nt),s.clear();else{nt===0&&(s.setRenderTarget(k.map),s.clear());const at=k.getViewport(nt);a.set(r.x*at.x,r.y*at.y,r.x*at.z,r.y*at.w),I.viewport(a)}if(V.isPointLight){const at=k.camera,Ht=k.matrix,$t=V.distance||at.far;$t!==at.far&&(at.far=$t,at.updateProjectionMatrix()),Qr.setFromMatrixPosition(V.matrixWorld),at.position.copy(Qr),Sl.copy(at.position),Sl.add(i3[nt]),at.up.copy(s3[nt]),at.lookAt(Sl),at.updateMatrixWorld(),Ht.makeTranslation(-Qr.x,-Qr.y,-Qr.z),Q0.multiplyMatrices(at.projectionMatrix,at.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Q0,at.coordinateSystem,at.reversedDepth)}else k.updateMatrices(V);n=k.getFrustum(),_(R,M,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===aa&&S(k,M),k.needsUpdate=!1}m=this.type,g.needsUpdate=!1,s.setRenderTarget(A,P,D)};function S(w,R){const M=t.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 wn(i.x,i.y,{format:Us,type:cn})),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,M,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,M,f,v,null)}function E(w,R,M,A){let P=null;const D=M.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)P=D;else if(P=M.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 I=P.uuid,F=R.uuid;let H=l[I];H===void 0&&(H={},l[I]=H);let O=H[F];O===void 0&&(O=P.clone(),H[F]=O,R.addEventListener("dispose",b)),P=O}if(P.visible=R.visible,P.wireframe=R.wireframe,A===aa?P.side=R.shadowSide!==null?R.shadowSide:R.side:P.side=R.shadowSide!==null?R.shadowSide:u[R.side],P.alphaMap=R.alphaMap,P.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,P.map=R.map,P.clipShadows=R.clipShadows,P.clippingPlanes=R.clippingPlanes,P.clipIntersection=R.clipIntersection,P.displacementMap=R.displacementMap,P.displacementScale=R.displacementScale,P.displacementBias=R.displacementBias,P.wireframeLinewidth=R.wireframeLinewidth,P.linewidth=R.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const I=s.properties.get(P);I.light=M}return P}function _(w,R,M,A,P){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&P===aa)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);const F=t.update(w),H=w.material;if(Array.isArray(H)){const O=F.groups;for(let V=0,k=O.length;V<k;V++){const Y=O[V],tt=H[Y.materialIndex];if(tt&&tt.visible){const J=E(w,tt,A,P);w.onBeforeShadow(s,w,R,M,F,J,Y),s.renderBufferDirect(M,null,F,J,w,Y),w.onAfterShadow(s,w,R,M,F,J,Y)}}}else if(H.visible){const O=E(w,H,A,P);w.onBeforeShadow(s,w,R,M,F,O,null),s.renderBufferDirect(M,null,F,O,w,null),w.onAfterShadow(s,w,R,M,F,O,null)}}const I=w.children;for(let F=0,H=I.length;F<H;F++)_(I[F],R,M,A,P)}function b(w){w.target.removeEventListener("dispose",b);for(const M in l){const A=l[M],P=w.target.uuid;P in A&&(A[P].dispose(),delete A[P])}}}function a3(s,t){function e(){let L=!1;const ot=new le;let j=null;const dt=new le(0,0,0,0);return{setMask:function(vt){j!==vt&&!L&&(s.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){L=vt},setClear:function(vt,et,At,yt,De){De===!0&&(vt*=yt,et*=yt,At*=yt),ot.set(vt,et,At,yt),dt.equals(ot)===!1&&(s.clearColor(vt,et,At,yt),dt.copy(ot))},reset:function(){L=!1,j=null,dt.set(-1,0,0,0)}}}function n(){let L=!1,ot=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ot!==et){const At=t.get("EXT_clip_control");et?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),ot=et;const yt=vt;vt=null,this.setClear(yt)}},getReversed:function(){return ot},setTest:function(et){et?it(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(et){j!==et&&!L&&(s.depthMask(et),j=et)},setFunc:function(et){if(ot&&(et=q1[et]),dt!==et){switch(et){case sh:s.depthFunc(s.NEVER);break;case rh:s.depthFunc(s.ALWAYS);break;case ah:s.depthFunc(s.LESS);break;case Pr:s.depthFunc(s.LEQUAL);break;case oh:s.depthFunc(s.EQUAL);break;case ch:s.depthFunc(s.GEQUAL);break;case lh:s.depthFunc(s.GREATER);break;case hh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}dt=et}},setLocked:function(et){L=et},setClear:function(et){vt!==et&&(vt=et,ot&&(et=1-et),s.clearDepth(et))},reset:function(){L=!1,j=null,dt=null,vt=null,ot=!1}}}function i(){let L=!1,ot=null,j=null,dt=null,vt=null,et=null,At=null,yt=null,De=null;return{setTest:function(fe){L||(fe?it(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(fe){ot!==fe&&!L&&(s.stencilMask(fe),ot=fe)},setFunc:function(fe,ii,si){(j!==fe||dt!==ii||vt!==si)&&(s.stencilFunc(fe,ii,si),j=fe,dt=ii,vt=si)},setOp:function(fe,ii,si){(et!==fe||At!==ii||yt!==si)&&(s.stencilOp(fe,ii,si),et=fe,At=ii,yt=si)},setLocked:function(fe){L=fe},setClear:function(fe){De!==fe&&(s.clearStencil(fe),De=fe)},reset:function(){L=!1,ot=null,j=null,dt=null,vt=null,et=null,At=null,yt=null,De=null}}}const r=new e,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,g=!1,m=null,S=null,E=null,_=null,b=null,w=null,R=null,M=new ct(0,0,0),A=0,P=!1,D=null,I=null,F=null,H=null,O=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,Y=0;const tt=s.getParameter(s.VERSION);tt.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=Y>=1):tt.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=Y>=2);let J=null,nt={};const at=s.getParameter(s.SCISSOR_BOX),Ht=s.getParameter(s.VIEWPORT),$t=new le().fromArray(at),Bt=new le().fromArray(Ht);function K(L,ot,j,dt){const vt=new Uint8Array(4),et=s.createTexture();s.bindTexture(L,et),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let At=0;At<j;At++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ot,0,s.RGBA,1,1,dt,0,s.RGBA,s.UNSIGNED_BYTE,vt):s.texImage2D(ot+At,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,vt);return et}const rt={};rt[s.TEXTURE_2D]=K(s.TEXTURE_2D,s.TEXTURE_2D,1),rt[s.TEXTURE_CUBE_MAP]=K(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[s.TEXTURE_2D_ARRAY]=K(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),rt[s.TEXTURE_3D]=K(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),it(s.DEPTH_TEST),a.setFunc(Pr),ee(!1),ne(Ld),it(s.CULL_FACE),Ot(Mi);function it(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Et(L,ot){return d[L]!==ot?(s.bindFramebuffer(L,ot),d[L]=ot,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ot),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ot),!0):!1}function It(L,ot){let j=p,dt=!1;if(L){j=f.get(ot),j===void 0&&(j=[],f.set(ot,j));const vt=L.textures;if(j.length!==vt.length||j[0]!==s.COLOR_ATTACHMENT0){for(let et=0,At=vt.length;et<At;et++)j[et]=s.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,dt=!0);dt&&s.drawBuffers(j)}function Tt(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xt={[Es]:s.FUNC_ADD,[d1]:s.FUNC_SUBTRACT,[f1]:s.FUNC_REVERSE_SUBTRACT};xt[p1]=s.MIN,xt[m1]=s.MAX;const Nt={[g1]:s.ZERO,[v1]:s.ONE,[M1]:s.SRC_COLOR,[nh]:s.SRC_ALPHA,[E1]:s.SRC_ALPHA_SATURATE,[S1]:s.DST_COLOR,[_1]:s.DST_ALPHA,[x1]:s.ONE_MINUS_SRC_COLOR,[ih]:s.ONE_MINUS_SRC_ALPHA,[b1]:s.ONE_MINUS_DST_COLOR,[y1]:s.ONE_MINUS_DST_ALPHA,[w1]:s.CONSTANT_COLOR,[A1]:s.ONE_MINUS_CONSTANT_COLOR,[T1]:s.CONSTANT_ALPHA,[R1]:s.ONE_MINUS_CONSTANT_ALPHA};function Ot(L,ot,j,dt,vt,et,At,yt,De,fe){if(L===Mi){g===!0&&(B(s.BLEND),g=!1);return}if(g===!1&&(it(s.BLEND),g=!0),L!==u1){if(L!==m||fe!==P){if((S!==Es||b!==Es)&&(s.blendEquation(s.FUNC_ADD),S=Es,b=Es),fe)switch(L){case Er:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Qn:s.blendFunc(s.ONE,s.ONE);break;case Nd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Od:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:zt("WebGLState: Invalid blending: ",L);break}else switch(L){case Er:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Qn:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Nd:zt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Od:zt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zt("WebGLState: Invalid blending: ",L);break}E=null,_=null,w=null,R=null,M.set(0,0,0),A=0,m=L,P=fe}return}vt=vt||ot,et=et||j,At=At||dt,(ot!==S||vt!==b)&&(s.blendEquationSeparate(xt[ot],xt[vt]),S=ot,b=vt),(j!==E||dt!==_||et!==w||At!==R)&&(s.blendFuncSeparate(Nt[j],Nt[dt],Nt[et],Nt[At]),E=j,_=dt,w=et,R=At),(yt.equals(M)===!1||De!==A)&&(s.blendColor(yt.r,yt.g,yt.b,De),M.copy(yt),A=De),m=L,P=!1}function Ut(L,ot){L.side===$n?B(s.CULL_FACE):it(s.CULL_FACE);let j=L.side===ze;ot&&(j=!j),ee(j),L.blending===Er&&L.transparent===!1?Ot(Mi):Ot(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 dt=L.stencilWrite;o.setTest(dt),dt&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ve(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?it(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ne(L){L!==c1?(it(s.CULL_FACE),L!==I&&(L===Ld?s.cullFace(s.BACK):L===l1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),I=L}function Te(L){L!==F&&(k&&s.lineWidth(L),F=L)}function ve(L,ot,j){L?(it(s.POLYGON_OFFSET_FILL),(H!==ot||O!==j)&&(H=ot,O=j,a.getReversed()&&(ot=-ot),s.polygonOffset(ot,j))):B(s.POLYGON_OFFSET_FILL)}function Re(L){L?it(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Be(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function N(L,ot,j){j===void 0&&(J===null?j=s.TEXTURE0+V-1:j=J);let dt=nt[j];dt===void 0&&(dt={type:void 0,texture:void 0},nt[j]=dt),(dt.type!==L||dt.texture!==ot)&&(J!==j&&(s.activeTexture(j),J=j),s.bindTexture(L,ot||rt[L]),dt.type=L,dt.texture=ot)}function xn(){const L=nt[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ie(){try{s.compressedTexImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function z(){try{s.texSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function st(){try{s.texStorage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function lt(){try{s.texStorage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function ht(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function Rt(L,ot){u[L]!==ot&&(s.pixelStorei(L,ot),u[L]=ot)}function ft(L){$t.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),$t.copy(L))}function ut(L){Bt.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),Bt.copy(L))}function Lt(L,ot){let j=l.get(ot);j===void 0&&(j=new WeakMap,l.set(ot,j));let dt=j.get(L);dt===void 0&&(dt=s.getUniformBlockIndex(ot,L.name),j.set(L,dt))}function Ft(L,ot){const dt=l.get(ot).get(L);c.get(ot)!==dt&&(s.uniformBlockBinding(ot,dt,L.__bindingPointIndex),c.set(ot,dt))}function Gt(){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,nt={},d={},f=new WeakMap,p=[],v=null,g=!1,m=null,S=null,E=null,_=null,b=null,w=null,R=null,M=new ct(0,0,0),A=0,P=!1,D=null,I=null,F=null,H=null,O=null,$t.set(0,0,s.canvas.width,s.canvas.height),Bt.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:it,disable:B,bindFramebuffer:Et,drawBuffers:It,useProgram:Tt,setBlending:Ot,setMaterial:Ut,setFlipSided:ee,setCullFace:ne,setLineWidth:Te,setPolygonOffset:ve,setScissorTest:Re,activeTexture:Be,bindTexture:N,unbindTexture:xn,compressedTexImage2D:ie,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:Rt,getParameter:ht,updateUBOMapping:Lt,uniformBlockBinding:Ft,texStorage2D:st,texStorage3D:lt,texSubImage2D:x,texSubImage3D:z,compressedTexSubImage2D:X,compressedTexSubImage3D:$,scissor:ft,viewport:ut,reset:Gt}}function o3(s,t,e,n,i,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Pt,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,x){return p?new OffscreenCanvas(T,x):Ra("canvas")}function g(T,x,z){let X=1;const $=ie(T);if(($.width>z||$.height>z)&&(X=z/Math.max($.width,$.height)),X<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 st=Math.floor(X*$.width),lt=Math.floor(X*$.height);d===void 0&&(d=v(st,lt));const Z=x?v(st,lt):d;return Z.width=st,Z.height=lt,Z.getContext("2d").drawImage(T,0,0,st,lt),wt("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+st+"x"+lt+")."),Z}else return"data"in T&&wt("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function m(T){return T.generateMipmaps}function S(T){s.generateMipmap(T)}function E(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,x,z,X,$,st=!1){if(T!==null){if(s[T]!==void 0)return s[T];wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let lt;X&&(lt=t.get("EXT_texture_norm16"),lt||wt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=x;if(x===s.RED&&(z===s.FLOAT&&(Z=s.R32F),z===s.HALF_FLOAT&&(Z=s.R16F),z===s.UNSIGNED_BYTE&&(Z=s.R8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.R16_EXT),z===s.SHORT&&lt&&(Z=lt.R16_SNORM_EXT)),x===s.RED_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.R8UI),z===s.UNSIGNED_SHORT&&(Z=s.R16UI),z===s.UNSIGNED_INT&&(Z=s.R32UI),z===s.BYTE&&(Z=s.R8I),z===s.SHORT&&(Z=s.R16I),z===s.INT&&(Z=s.R32I)),x===s.RG&&(z===s.FLOAT&&(Z=s.RG32F),z===s.HALF_FLOAT&&(Z=s.RG16F),z===s.UNSIGNED_BYTE&&(Z=s.RG8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RG16_EXT),z===s.SHORT&&lt&&(Z=lt.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RG8UI),z===s.UNSIGNED_SHORT&&(Z=s.RG16UI),z===s.UNSIGNED_INT&&(Z=s.RG32UI),z===s.BYTE&&(Z=s.RG8I),z===s.SHORT&&(Z=s.RG16I),z===s.INT&&(Z=s.RG32I)),x===s.RGB_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),z===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),z===s.UNSIGNED_INT&&(Z=s.RGB32UI),z===s.BYTE&&(Z=s.RGB8I),z===s.SHORT&&(Z=s.RGB16I),z===s.INT&&(Z=s.RGB32I)),x===s.RGBA_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),z===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),z===s.UNSIGNED_INT&&(Z=s.RGBA32UI),z===s.BYTE&&(Z=s.RGBA8I),z===s.SHORT&&(Z=s.RGBA16I),z===s.INT&&(Z=s.RGBA32I)),x===s.RGB&&(z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RGB16_EXT),z===s.SHORT&&lt&&(Z=lt.RGB16_SNORM_EXT),z===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),z===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),x===s.RGBA){const Q=st?oc:jt.getTransfer($);z===s.FLOAT&&(Z=s.RGBA32F),z===s.HALF_FLOAT&&(Z=s.RGBA16F),z===s.UNSIGNED_BYTE&&(Z=Q===se?s.SRGB8_ALPHA8:s.RGBA8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RGBA16_EXT),z===s.SHORT&&lt&&(Z=lt.RGBA16_SNORM_EXT),z===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),z===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)&&t.get("EXT_color_buffer_float"),Z}function b(T,x){let z;return T?x===null||x===ti||x===Aa?z=s.DEPTH24_STENCIL8:x===Gn?z=s.DEPTH32F_STENCIL8:x===wa&&(z=s.DEPTH24_STENCIL8,wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ti||x===Aa?z=s.DEPTH_COMPONENT24:x===Gn?z=s.DEPTH_COMPONENT32F:x===wa&&(z=s.DEPTH_COMPONENT16),z}function w(T,x){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==We&&T.minFilter!==ye?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function M(T){const x=T.target;x.removeEventListener("dispose",M),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const z=T.source,X=f.get(z);if(X){const $=X[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&P(T),Object.keys(X).length===0&&f.delete(z)}n.remove(T)}function P(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const z=T.source,X=f.get(z);delete X[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let $=0;$<x.__webglFramebuffer[X].length;$++)s.deleteFramebuffer(x.__webglFramebuffer[X][$]);else s.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)s.deleteFramebuffer(x.__webglFramebuffer[X]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const z=T.textures;for(let X=0,$=z.length;X<$;X++){const st=n.get(z[X]);st.__webglTexture&&(s.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(z[X])}n.remove(T)}let I=0;function F(){I=0}function H(){return I}function O(T){I=T}function V(){const T=I;return T>=i.maxTextures&&wt("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),I+=1,T}function k(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Y(T,x){const z=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&z.__version!==T.version){const X=T.image;if(X===null)wt("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)wt("WebGLRenderer: Texture marked for update but image is incomplete");else{B(z,T,x);return}}else T.isExternalTexture&&(z.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,z.__webglTexture,s.TEXTURE0+x)}function tt(T,x){const z=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&z.__version!==T.version){B(z,T,x);return}else T.isExternalTexture&&(z.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D_ARRAY,z.__webglTexture,s.TEXTURE0+x)}function J(T,x){const z=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&z.__version!==T.version){B(z,T,x);return}e.bindTexture(s.TEXTURE_3D,z.__webglTexture,s.TEXTURE0+x)}function nt(T,x){const z=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&z.__version!==T.version){Et(z,T,x);return}e.bindTexture(s.TEXTURE_CUBE_MAP,z.__webglTexture,s.TEXTURE0+x)}const at={[Ea]:s.REPEAT,[gn]:s.CLAMP_TO_EDGE,[uh]:s.MIRRORED_REPEAT},Ht={[We]:s.NEAREST,[I1]:s.NEAREST_MIPMAP_NEAREST,[Ya]:s.NEAREST_MIPMAP_LINEAR,[ye]:s.LINEAR,[Bc]:s.LINEAR_MIPMAP_NEAREST,[Ds]:s.LINEAR_MIPMAP_LINEAR},$t={[U1]:s.NEVER,[H1]:s.ALWAYS,[F1]:s.LESS,[Nu]:s.LEQUAL,[z1]:s.EQUAL,[Ou]:s.GEQUAL,[k1]:s.GREATER,[B1]:s.NOTEQUAL};function Bt(T,x){if(x.type===Gn&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===ye||x.magFilter===Bc||x.magFilter===Ya||x.magFilter===Ds||x.minFilter===ye||x.minFilter===Bc||x.minFilter===Ya||x.minFilter===Ds)&&wt("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,at[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,at[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,at[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ht[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ht[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,$t[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===We||x.minFilter!==Ya&&x.minFilter!==Ds||x.type===Gn&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const z=t.get("EXT_texture_filter_anisotropic");s.texParameterf(T,z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function K(T,x){let z=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const X=x.source;let $=f.get(X);$===void 0&&($={},f.set(X,$));const st=k(x);if(st!==T.__cacheKey){$[st]===void 0&&($[st]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,z=!0),$[st].usedTimes++;const lt=$[T.__cacheKey];lt!==void 0&&($[T.__cacheKey].usedTimes--,lt.usedTimes===0&&P(x)),T.__cacheKey=st,T.__webglTexture=$[st].texture}return z}function rt(T,x,z){return Math.floor(Math.floor(T/z)/x)}function it(T,x,z,X){const st=T.updateRanges;if(st.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,z,X,x.data);else{st.sort((Rt,ft)=>Rt.start-ft.start);let lt=0;for(let Rt=1;Rt<st.length;Rt++){const ft=st[lt],ut=st[Rt],Lt=ft.start+ft.count,Ft=rt(ut.start,x.width,4),Gt=rt(ft.start,x.width,4);ut.start<=Lt+1&&Ft===Gt&&rt(ut.start+ut.count-1,x.width,4)===Ft?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,st[lt]=ut)}st.length=lt+1;const Z=e.getParameter(s.UNPACK_ROW_LENGTH),Q=e.getParameter(s.UNPACK_SKIP_PIXELS),ht=e.getParameter(s.UNPACK_SKIP_ROWS);e.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let Rt=0,ft=st.length;Rt<ft;Rt++){const ut=st[Rt],Lt=Math.floor(ut.start/4),Ft=Math.ceil(ut.count/4),Gt=Lt%x.width,L=Math.floor(Lt/x.width),ot=Ft,j=1;e.pixelStorei(s.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(s.UNPACK_SKIP_ROWS,L),e.texSubImage2D(s.TEXTURE_2D,0,Gt,L,ot,j,z,X,x.data)}T.clearUpdateRanges(),e.pixelStorei(s.UNPACK_ROW_LENGTH,Z),e.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(s.UNPACK_SKIP_ROWS,ht)}}function B(T,x,z){let X=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=s.TEXTURE_3D);const $=K(T,x),st=x.source;e.bindTexture(X,T.__webglTexture,s.TEXTURE0+z);const lt=n.get(st);if(st.version!==lt.__version||$===!0){if(e.activeTexture(s.TEXTURE0+z),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const j=jt.getPrimaries(jt.workingColorSpace),dt=x.colorSpace===as?null:jt.getPrimaries(x.colorSpace),vt=x.colorSpace===as||j===dt?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=g(x.image,!1,i.maxTextureSize);Q=xn(x,Q);const ht=r.convert(x.format,x.colorSpace),Rt=r.convert(x.type);let ft=_(x.internalFormat,ht,Rt,x.normalized,x.colorSpace,x.isVideoTexture);Bt(X,x);let ut;const Lt=x.mipmaps,Ft=x.isVideoTexture!==!0,Gt=lt.__version===void 0||$===!0,L=st.dataReady,ot=w(x,Q);if(x.isDepthTexture)ft=b(x.format===Cs,x.type),Gt&&(Ft?e.texStorage2D(s.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(s.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Rt,null));else if(x.isDataTexture)if(Lt.length>0){Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Lt[0].width,Lt[0].height);for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Rt,ut.data):e.texImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Rt,ut.data);x.generateMipmaps=!1}else Ft?(Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Q.width,Q.height),L&&it(x,Q,ht,Rt)):e.texImage2D(s.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Rt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Ft&&Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,ot,ft,Lt[0].width,Lt[0].height,Q.depth);for(let j=0,dt=Lt.length;j<dt;j++)if(ut=Lt[j],x.format!==vn)if(ht!==null)if(Ft){if(L)if(x.layerUpdates.size>0){const vt=C0(ut.width,ut.height,x.format,x.type);for(const et of x.layerUpdates){const At=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,At)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ft?L&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,Rt,ut.data):e.texImage3D(s.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,Rt,ut.data)}else{Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Lt[0].width,Lt[0].height);for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],x.format!==vn?ht!==null?Ft?L&&e.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Rt,ut.data):e.texImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Rt,ut.data)}else if(x.isDataArrayTexture)if(Ft){if(Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,ot,ft,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const j=C0(Q.width,Q.height,x.format,x.type);for(const dt of x.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,Rt,vt)}x.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,Rt,Q.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,Rt,Q.data);else if(x.isData3DTexture)Ft?(Gt&&e.texStorage3D(s.TEXTURE_3D,ot,ft,Q.width,Q.height,Q.depth),L&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,Rt,Q.data)):e.texImage3D(s.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,Rt,Q.data);else if(x.isFramebufferTexture){if(Gt)if(Ft)e.texStorage2D(s.TEXTURE_2D,ot,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ot;vt++)e.texImage2D(s.TEXTURE_2D,vt,ft,j,dt,0,ht,Rt,null),j>>=1,dt>>=1}}else if(x.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(x),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const vt=s.RGBA,et=s.RGBA,At=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,vt,et,At,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(Lt.length>0){if(Ft&&Gt){const j=ie(Lt[0]);e.texStorage2D(s.TEXTURE_2D,ot,ft,j.width,j.height)}for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ht,Rt,ut):e.texImage2D(s.TEXTURE_2D,j,ft,ht,Rt,ut);x.generateMipmaps=!1}else if(Ft){if(Gt){const j=ie(Q);e.texStorage2D(s.TEXTURE_2D,ot,ft,j.width,j.height)}L&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,ht,Rt,Q)}else e.texImage2D(s.TEXTURE_2D,0,ft,ht,Rt,Q);m(x)&&S(X),lt.__version=st.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Et(T,x,z){if(x.image.length!==6)return;const X=K(T,x),$=x.source;e.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+z);const st=n.get($);if($.version!==st.__version||X===!0){e.activeTexture(s.TEXTURE0+z);const lt=jt.getPrimaries(jt.workingColorSpace),Z=x.colorSpace===as?null:jt.getPrimaries(x.colorSpace),Q=x.colorSpace===as||lt===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=x.isCompressedTexture||x.image[0].isCompressedTexture,Rt=x.image[0]&&x.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!Rt?ft[et]=g(x.image[et],!0,i.maxCubemapSize):ft[et]=Rt?x.image[et].image:x.image[et],ft[et]=xn(x,ft[et]);const ut=ft[0],Lt=r.convert(x.format,x.colorSpace),Ft=r.convert(x.type),Gt=_(x.internalFormat,Lt,Ft,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,ot=st.__version===void 0||X===!0,j=$.dataReady;let dt=w(x,ut);Bt(s.TEXTURE_CUBE_MAP,x);let vt;if(ht){L&&ot&&e.texStorage2D(s.TEXTURE_CUBE_MAP,dt,Gt,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let At=0;At<vt.length;At++){const yt=vt[At];x.format!==vn?Lt!==null?L?j&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,0,0,yt.width,yt.height,Lt,yt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,Gt,yt.width,yt.height,0,yt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,0,0,yt.width,yt.height,Lt,Ft,yt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,Gt,yt.width,yt.height,0,Lt,Ft,yt.data)}}}else{if(vt=x.mipmaps,L&&ot){vt.length>0&&dt++;const et=ie(ft[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,dt,Gt,et.width,et.height)}for(let et=0;et<6;et++)if(Rt){L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Lt,Ft,ft[et].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Gt,ft[et].width,ft[et].height,0,Lt,Ft,ft[et].data);for(let At=0;At<vt.length;At++){const De=vt[At].image[et].image;L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,0,0,De.width,De.height,Lt,Ft,De.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,Gt,De.width,De.height,0,Lt,Ft,De.data)}}else{L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Lt,Ft,ft[et]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Gt,Lt,Ft,ft[et]);for(let At=0;At<vt.length;At++){const yt=vt[At];L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,0,0,Lt,Ft,yt.image[et]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,Gt,Lt,Ft,yt.image[et])}}}m(x)&&S(s.TEXTURE_CUBE_MAP),st.__version=$.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function It(T,x,z,X,$,st){const lt=r.convert(z.format,z.colorSpace),Z=r.convert(z.type),Q=_(z.internalFormat,lt,Z,z.normalized,z.colorSpace),ht=n.get(x),Rt=n.get(z);if(Rt.__renderTarget=x,!ht.__hasExternalTextures){const ft=Math.max(1,x.width>>st),ut=Math.max(1,x.height>>st);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?e.texImage3D($,st,Q,ft,ut,x.depth,0,lt,Z,null):e.texImage2D($,st,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(s.FRAMEBUFFER,T),Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,$,Rt.__webglTexture,0,Re(x)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,$,Rt.__webglTexture,st),e.bindFramebuffer(s.FRAMEBUFFER,null)}function Tt(T,x,z){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const X=x.depthTexture,$=X&&X.isDepthTexture?X.type:null,st=b(x.stencilBuffer,$),lt=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Be(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Re(x),st,x.width,x.height):z?s.renderbufferStorageMultisample(s.RENDERBUFFER,Re(x),st,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,st,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,lt,s.RENDERBUFFER,T)}else{const X=x.textures;for(let $=0;$<X.length;$++){const st=X[$],lt=r.convert(st.format,st.colorSpace),Z=r.convert(st.type),Q=_(st.internalFormat,lt,Z,st.normalized,st.colorSpace);Be(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Re(x),Q,x.width,x.height):z?s.renderbufferStorageMultisample(s.RENDERBUFFER,Re(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xt(T,x,z){const X=x.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=n.get(x.depthTexture);if($.__renderTarget=x,(!$.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X){if($.__webglInit===void 0&&($.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),e.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Bt(s.TEXTURE_CUBE_MAP,x.depthTexture);const ht=r.convert(x.depthTexture.format),Rt=r.convert(x.depthTexture.type);let ft;x.depthTexture.format===ki?ft=s.DEPTH_COMPONENT24:x.depthTexture.format===Cs&&(ft=s.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,x.width,x.height,0,ht,Rt,null)}}else Y(x.depthTexture,0);const st=$.__webglTexture,lt=Re(x),Z=X?s.TEXTURE_CUBE_MAP_POSITIVE_X+z:s.TEXTURE_2D,Q=x.depthTexture.format===Cs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===ki)Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,st,0,lt):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,st,0);else if(x.depthTexture.format===Cs)Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,st,0,lt):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Nt(T){const x=n.get(T),z=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const X=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",$)};X.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=X}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(z)for(let X=0;X<6;X++)xt(x.__webglFramebuffer[X],T,X);else{const X=T.texture.mipmaps;X&&X.length>0?xt(x.__webglFramebuffer[0],T,0):xt(x.__webglFramebuffer,T,0)}else if(z){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=s.createRenderbuffer(),Tt(x.__webglDepthbuffer[X],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,st)}}else{const X=T.texture.mipmaps;if(X&&X.length>0?e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Tt(x.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,st)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Ot(T,x,z){const X=n.get(T);x!==void 0&&It(X.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),z!==void 0&&Nt(T)}function Ut(T){const x=T.texture,z=n.get(T),X=n.get(x);T.addEventListener("dispose",M);const $=T.textures,st=T.isWebGLCubeRenderTarget===!0,lt=$.length>1;if(lt||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=x.version,a.memory.textures++),st){z.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0){z.__webglFramebuffer[Z]=[];for(let Q=0;Q<x.mipmaps.length;Q++)z.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else z.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){z.__webglFramebuffer=[];for(let Z=0;Z<x.mipmaps.length;Z++)z.__webglFramebuffer[Z]=s.createFramebuffer()}else z.__webglFramebuffer=s.createFramebuffer();if(lt)for(let Z=0,Q=$.length;Z<Q;Z++){const ht=n.get($[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Be(T)===!1){z.__webglMultisampledFramebuffer=s.createFramebuffer(),z.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,z.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];z.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,z.__webglColorRenderbuffer[Z]);const ht=r.convert(Q.format,Q.colorSpace),Rt=r.convert(Q.type),ft=_(Q.internalFormat,ht,Rt,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ut=Re(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ut,ft,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,z.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(z.__webglDepthRenderbuffer=s.createRenderbuffer(),Tt(z.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(st){e.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture),Bt(s.TEXTURE_CUBE_MAP,x);for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(z.__webglFramebuffer[Z][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else It(z.__webglFramebuffer[Z],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);m(x)&&S(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=$.length;Z<Q;Z++){const ht=$[Z],Rt=n.get(ht);let ft=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ft=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(ft,Rt.__webglTexture),Bt(ft,ht),It(z.__webglFramebuffer,T,ht,s.COLOR_ATTACHMENT0+Z,ft,0),m(ht)&&S(ft)}e.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(Z,X.__webglTexture),Bt(Z,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(z.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,Z,Q);else It(z.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,Z,0);m(x)&&S(Z),e.unbindTexture()}T.depthBuffer&&Nt(T)}function ee(T){const x=T.textures;for(let z=0,X=x.length;z<X;z++){const $=x[z];if(m($)){const st=E(T),lt=n.get($).__webglTexture;e.bindTexture(st,lt),S(st),e.unbindTexture()}}}const ne=[],Te=[];function ve(T){if(T.samples>0){if(Be(T)===!1){const x=T.textures,z=T.width,X=T.height;let $=s.COLOR_BUFFER_BIT;const st=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,lt=n.get(T),Z=x.length>1;if(Z)for(let ht=0;ht<x.length;ht++)e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<x.length;ht++){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,lt.__webglColorRenderbuffer[ht]);const Rt=n.get(x[ht]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Rt,0)}s.blitFramebuffer(0,0,z,X,0,0,z,X,$,s.NEAREST),c===!0&&(ne.length=0,Te.length=0,ne.push(s.COLOR_ATTACHMENT0+ht),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ne.push(st),Te.push(st),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Te)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ne))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<x.length;ht++){e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Rt=n.get(x[ht]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.TEXTURE_2D,Rt,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function Re(T){return Math.min(i.maxSamples,T.samples)}function Be(T){const x=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function xn(T,x){const z=T.colorSpace,X=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||z!==ac&&z!==as&&(jt.getTransfer(z)===se?(X!==vn||$!==In)&&wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zt("WebGLTextures: Unsupported texture color space:",z)),x}function ie(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=F,this.getTextureUnits=H,this.setTextureUnits=O,this.setTexture2D=Y,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=nt,this.rebindTextures=Ot,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ve,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=It,this.useMultisampledRTT=Be,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function c3(s,t){function e(n,i=as){let r;const a=jt.getTransfer(i);if(n===In)return s.UNSIGNED_BYTE;if(n===Du)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Cu)return s.UNSIGNED_SHORT_5_5_5_1;if(n===zp)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===kp)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Up)return s.BYTE;if(n===Fp)return s.SHORT;if(n===wa)return s.UNSIGNED_SHORT;if(n===Ru)return s.INT;if(n===ti)return s.UNSIGNED_INT;if(n===Gn)return s.FLOAT;if(n===cn)return s.HALF_FLOAT;if(n===Bp)return s.ALPHA;if(n===Hp)return s.RGB;if(n===vn)return s.RGBA;if(n===ki)return s.DEPTH_COMPONENT;if(n===Cs)return s.DEPTH_STENCIL;if(n===wc)return s.RED;if(n===Pu)return s.RED_INTEGER;if(n===Us)return s.RG;if(n===Iu)return s.RG_INTEGER;if(n===Lu)return s.RGBA_INTEGER;if(n===Wo||n===Xo||n===qo||n===Yo)if(a===se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Wo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===qo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Yo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Wo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Yo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===dh||n===fh||n===ph||n===mh)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===dh)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===fh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ph)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===mh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===gh||n===vh||n===Mh||n===xh||n===_h||n===nc||n===yh)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===gh||n===vh)return a===se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Mh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===xh)return r.COMPRESSED_R11_EAC;if(n===_h)return r.COMPRESSED_SIGNED_R11_EAC;if(n===nc)return r.COMPRESSED_RG11_EAC;if(n===yh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Sh||n===bh||n===Eh||n===wh||n===Ah||n===Th||n===Rh||n===Dh||n===Ch||n===Ph||n===Ih||n===Lh||n===Nh||n===Oh)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Sh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===bh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Eh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===wh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ah)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Th)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Rh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Dh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ch)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ph)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ih)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Lh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Nh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Oh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Uh||n===Fh||n===zh)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Uh)return a===se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Fh)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===zh)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===kh||n===Bh||n===ic||n===Hh)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===kh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Bh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ic)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Hh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Aa?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}const l3=`
4605
+ }`,i3=[new C(1,0,0),new C(-1,0,0),new C(0,1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1)],s3=[new C(0,-1,0),new C(0,-1,0),new C(0,0,1),new C(0,0,-1),new C(0,-1,0),new C(0,-1,0)],Q0=new Wt,Qr=new C,Sl=new C;function r3(s,t,e){let n=new Bu;const i=new Pt,r=new Pt,a=new le,o=new Xv,c=new qv,l={},h=e.maxTextureSize,u={[us]:ze,[ze]:us,[Zn]:Zn},d=new Ae({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pt},radius:{value:4}},vertexShader:e3,fragmentShader:n3}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new we;p.setAttribute("position",new de(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new qt(p,d),g=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=da;let m=this.type;this.render=function(w,R,M){if(g.enabled===!1||g.autoUpdate===!1&&g.needsUpdate===!1||w.length===0)return;this.type===h1&&(wt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=da);const A=s.getRenderTarget(),P=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),I=s.state;I.setBlending(xi),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const F=m!==this.type;F&&R.traverse(function(H){H.material&&(Array.isArray(H.material)?H.material.forEach(O=>O.needsUpdate=!0):H.material.needsUpdate=!0)});for(let H=0,O=w.length;H<O;H++){const V=w[H],k=V.shadow;if(k===void 0){wt("WebGLShadowMap:",V,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;i.copy(k.mapSize);const Y=k.getFrameExtents();i.multiply(Y),r.copy(k.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Y.x),i.x=r.x*Y.x,k.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Y.y),i.y=r.y*Y.y,k.mapSize.y=r.y));const tt=s.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||F===!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){wt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new wn(i.x,i.y,{format:Us,type:cn,minFilter:ye,magFilter:ye,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Fs(i.x,i.y,Gn),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=ki,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=We,k.map.depthTexture.magFilter=We}else V.isPointLight?(k.map=new am(i.x),k.map.depthTexture=new zv(i.x,ei)):(k.map=new wn(i.x,i.y),k.map.depthTexture=new Fs(i.x,i.y,ei)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=ki,this.type===da?(k.map.depthTexture.compareFunction=tt?Ou:Nu,k.map.depthTexture.minFilter=ye,k.map.depthTexture.magFilter=ye):(k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=We,k.map.depthTexture.magFilter=We);k.camera.updateProjectionMatrix()}const J=k.map.isWebGLCubeRenderTarget?6:1;for(let nt=0;nt<J;nt++){if(k.map.isWebGLCubeRenderTarget)s.setRenderTarget(k.map,nt),s.clear();else{nt===0&&(s.setRenderTarget(k.map),s.clear());const at=k.getViewport(nt);a.set(r.x*at.x,r.y*at.y,r.x*at.z,r.y*at.w),I.viewport(a)}if(V.isPointLight){const at=k.camera,Ht=k.matrix,$t=V.distance||at.far;$t!==at.far&&(at.far=$t,at.updateProjectionMatrix()),Qr.setFromMatrixPosition(V.matrixWorld),at.position.copy(Qr),Sl.copy(at.position),Sl.add(i3[nt]),at.up.copy(s3[nt]),at.lookAt(Sl),at.updateMatrixWorld(),Ht.makeTranslation(-Qr.x,-Qr.y,-Qr.z),Q0.multiplyMatrices(at.projectionMatrix,at.matrixWorldInverse),k._frustum.setFromProjectionMatrix(Q0,at.coordinateSystem,at.reversedDepth)}else k.updateMatrices(V);n=k.getFrustum(),_(R,M,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===aa&&S(k,M),k.needsUpdate=!1}m=this.type,g.needsUpdate=!1,s.setRenderTarget(A,P,D)};function S(w,R){const M=t.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 wn(i.x,i.y,{format:Us,type:cn})),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,M,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,M,f,v,null)}function E(w,R,M,A){let P=null;const D=M.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)P=D;else if(P=M.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 I=P.uuid,F=R.uuid;let H=l[I];H===void 0&&(H={},l[I]=H);let O=H[F];O===void 0&&(O=P.clone(),H[F]=O,R.addEventListener("dispose",b)),P=O}if(P.visible=R.visible,P.wireframe=R.wireframe,A===aa?P.side=R.shadowSide!==null?R.shadowSide:R.side:P.side=R.shadowSide!==null?R.shadowSide:u[R.side],P.alphaMap=R.alphaMap,P.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,P.map=R.map,P.clipShadows=R.clipShadows,P.clippingPlanes=R.clippingPlanes,P.clipIntersection=R.clipIntersection,P.displacementMap=R.displacementMap,P.displacementScale=R.displacementScale,P.displacementBias=R.displacementBias,P.wireframeLinewidth=R.wireframeLinewidth,P.linewidth=R.linewidth,M.isPointLight===!0&&P.isMeshDistanceMaterial===!0){const I=s.properties.get(P);I.light=M}return P}function _(w,R,M,A,P){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&P===aa)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(M.matrixWorldInverse,w.matrixWorld);const F=t.update(w),H=w.material;if(Array.isArray(H)){const O=F.groups;for(let V=0,k=O.length;V<k;V++){const Y=O[V],tt=H[Y.materialIndex];if(tt&&tt.visible){const J=E(w,tt,A,P);w.onBeforeShadow(s,w,R,M,F,J,Y),s.renderBufferDirect(M,null,F,J,w,Y),w.onAfterShadow(s,w,R,M,F,J,Y)}}}else if(H.visible){const O=E(w,H,A,P);w.onBeforeShadow(s,w,R,M,F,O,null),s.renderBufferDirect(M,null,F,O,w,null),w.onAfterShadow(s,w,R,M,F,O,null)}}const I=w.children;for(let F=0,H=I.length;F<H;F++)_(I[F],R,M,A,P)}function b(w){w.target.removeEventListener("dispose",b);for(const M in l){const A=l[M],P=w.target.uuid;P in A&&(A[P].dispose(),delete A[P])}}}function a3(s,t){function e(){let L=!1;const ot=new le;let j=null;const dt=new le(0,0,0,0);return{setMask:function(vt){j!==vt&&!L&&(s.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){L=vt},setClear:function(vt,et,At,yt,De){De===!0&&(vt*=yt,et*=yt,At*=yt),ot.set(vt,et,At,yt),dt.equals(ot)===!1&&(s.clearColor(vt,et,At,yt),dt.copy(ot))},reset:function(){L=!1,j=null,dt.set(-1,0,0,0)}}}function n(){let L=!1,ot=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ot!==et){const At=t.get("EXT_clip_control");et?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),ot=et;const yt=vt;vt=null,this.setClear(yt)}},getReversed:function(){return ot},setTest:function(et){et?it(s.DEPTH_TEST):B(s.DEPTH_TEST)},setMask:function(et){j!==et&&!L&&(s.depthMask(et),j=et)},setFunc:function(et){if(ot&&(et=q1[et]),dt!==et){switch(et){case sh:s.depthFunc(s.NEVER);break;case rh:s.depthFunc(s.ALWAYS);break;case ah:s.depthFunc(s.LESS);break;case Pr:s.depthFunc(s.LEQUAL);break;case oh:s.depthFunc(s.EQUAL);break;case ch:s.depthFunc(s.GEQUAL);break;case lh:s.depthFunc(s.GREATER);break;case hh:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}dt=et}},setLocked:function(et){L=et},setClear:function(et){vt!==et&&(vt=et,ot&&(et=1-et),s.clearDepth(et))},reset:function(){L=!1,j=null,dt=null,vt=null,ot=!1}}}function i(){let L=!1,ot=null,j=null,dt=null,vt=null,et=null,At=null,yt=null,De=null;return{setTest:function(fe){L||(fe?it(s.STENCIL_TEST):B(s.STENCIL_TEST))},setMask:function(fe){ot!==fe&&!L&&(s.stencilMask(fe),ot=fe)},setFunc:function(fe,si,ri){(j!==fe||dt!==si||vt!==ri)&&(s.stencilFunc(fe,si,ri),j=fe,dt=si,vt=ri)},setOp:function(fe,si,ri){(et!==fe||At!==si||yt!==ri)&&(s.stencilOp(fe,si,ri),et=fe,At=si,yt=ri)},setLocked:function(fe){L=fe},setClear:function(fe){De!==fe&&(s.clearStencil(fe),De=fe)},reset:function(){L=!1,ot=null,j=null,dt=null,vt=null,et=null,At=null,yt=null,De=null}}}const r=new e,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,g=!1,m=null,S=null,E=null,_=null,b=null,w=null,R=null,M=new ct(0,0,0),A=0,P=!1,D=null,I=null,F=null,H=null,O=null;const V=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,Y=0;const tt=s.getParameter(s.VERSION);tt.indexOf("WebGL")!==-1?(Y=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=Y>=1):tt.indexOf("OpenGL ES")!==-1&&(Y=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=Y>=2);let J=null,nt={};const at=s.getParameter(s.SCISSOR_BOX),Ht=s.getParameter(s.VIEWPORT),$t=new le().fromArray(at),Bt=new le().fromArray(Ht);function K(L,ot,j,dt){const vt=new Uint8Array(4),et=s.createTexture();s.bindTexture(L,et),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let At=0;At<j;At++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(ot,0,s.RGBA,1,1,dt,0,s.RGBA,s.UNSIGNED_BYTE,vt):s.texImage2D(ot+At,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,vt);return et}const rt={};rt[s.TEXTURE_2D]=K(s.TEXTURE_2D,s.TEXTURE_2D,1),rt[s.TEXTURE_CUBE_MAP]=K(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[s.TEXTURE_2D_ARRAY]=K(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),rt[s.TEXTURE_3D]=K(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),it(s.DEPTH_TEST),a.setFunc(Pr),ee(!1),ne(Ld),it(s.CULL_FACE),Ot(xi);function it(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Et(L,ot){return d[L]!==ot?(s.bindFramebuffer(L,ot),d[L]=ot,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=ot),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=ot),!0):!1}function It(L,ot){let j=p,dt=!1;if(L){j=f.get(ot),j===void 0&&(j=[],f.set(ot,j));const vt=L.textures;if(j.length!==vt.length||j[0]!==s.COLOR_ATTACHMENT0){for(let et=0,At=vt.length;et<At;et++)j[et]=s.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==s.BACK&&(j[0]=s.BACK,dt=!0);dt&&s.drawBuffers(j)}function Tt(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const xt={[Es]:s.FUNC_ADD,[d1]:s.FUNC_SUBTRACT,[f1]:s.FUNC_REVERSE_SUBTRACT};xt[p1]=s.MIN,xt[m1]=s.MAX;const Nt={[g1]:s.ZERO,[v1]:s.ONE,[M1]:s.SRC_COLOR,[nh]:s.SRC_ALPHA,[E1]:s.SRC_ALPHA_SATURATE,[S1]:s.DST_COLOR,[_1]:s.DST_ALPHA,[x1]:s.ONE_MINUS_SRC_COLOR,[ih]:s.ONE_MINUS_SRC_ALPHA,[b1]:s.ONE_MINUS_DST_COLOR,[y1]:s.ONE_MINUS_DST_ALPHA,[w1]:s.CONSTANT_COLOR,[A1]:s.ONE_MINUS_CONSTANT_COLOR,[T1]:s.CONSTANT_ALPHA,[R1]:s.ONE_MINUS_CONSTANT_ALPHA};function Ot(L,ot,j,dt,vt,et,At,yt,De,fe){if(L===xi){g===!0&&(B(s.BLEND),g=!1);return}if(g===!1&&(it(s.BLEND),g=!0),L!==u1){if(L!==m||fe!==P){if((S!==Es||b!==Es)&&(s.blendEquation(s.FUNC_ADD),S=Es,b=Es),fe)switch(L){case Er:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ti:s.blendFunc(s.ONE,s.ONE);break;case Nd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case Od:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:zt("WebGLState: Invalid blending: ",L);break}else switch(L){case Er:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case ti:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case Nd:zt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Od:zt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zt("WebGLState: Invalid blending: ",L);break}E=null,_=null,w=null,R=null,M.set(0,0,0),A=0,m=L,P=fe}return}vt=vt||ot,et=et||j,At=At||dt,(ot!==S||vt!==b)&&(s.blendEquationSeparate(xt[ot],xt[vt]),S=ot,b=vt),(j!==E||dt!==_||et!==w||At!==R)&&(s.blendFuncSeparate(Nt[j],Nt[dt],Nt[et],Nt[At]),E=j,_=dt,w=et,R=At),(yt.equals(M)===!1||De!==A)&&(s.blendColor(yt.r,yt.g,yt.b,De),M.copy(yt),A=De),m=L,P=!1}function Ut(L,ot){L.side===Zn?B(s.CULL_FACE):it(s.CULL_FACE);let j=L.side===ze;ot&&(j=!j),ee(j),L.blending===Er&&L.transparent===!1?Ot(xi):Ot(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 dt=L.stencilWrite;o.setTest(dt),dt&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ve(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?it(s.SAMPLE_ALPHA_TO_COVERAGE):B(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ne(L){L!==c1?(it(s.CULL_FACE),L!==I&&(L===Ld?s.cullFace(s.BACK):L===l1?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):B(s.CULL_FACE),I=L}function Te(L){L!==F&&(k&&s.lineWidth(L),F=L)}function ve(L,ot,j){L?(it(s.POLYGON_OFFSET_FILL),(H!==ot||O!==j)&&(H=ot,O=j,a.getReversed()&&(ot=-ot),s.polygonOffset(ot,j))):B(s.POLYGON_OFFSET_FILL)}function Re(L){L?it(s.SCISSOR_TEST):B(s.SCISSOR_TEST)}function Be(L){L===void 0&&(L=s.TEXTURE0+V-1),J!==L&&(s.activeTexture(L),J=L)}function N(L,ot,j){j===void 0&&(J===null?j=s.TEXTURE0+V-1:j=J);let dt=nt[j];dt===void 0&&(dt={type:void 0,texture:void 0},nt[j]=dt),(dt.type!==L||dt.texture!==ot)&&(J!==j&&(s.activeTexture(j),J=j),s.bindTexture(L,ot||rt[L]),dt.type=L,dt.texture=ot)}function xn(){const L=nt[J];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ie(){try{s.compressedTexImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function z(){try{s.texSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function X(){try{s.compressedTexSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function $(){try{s.compressedTexSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function st(){try{s.texStorage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function lt(){try{s.texStorage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function Z(){try{s.texImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function ht(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function Rt(L,ot){u[L]!==ot&&(s.pixelStorei(L,ot),u[L]=ot)}function ft(L){$t.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),$t.copy(L))}function ut(L){Bt.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),Bt.copy(L))}function Lt(L,ot){let j=l.get(ot);j===void 0&&(j=new WeakMap,l.set(ot,j));let dt=j.get(L);dt===void 0&&(dt=s.getUniformBlockIndex(ot,L.name),j.set(L,dt))}function Ft(L,ot){const dt=l.get(ot).get(L);c.get(ot)!==dt&&(s.uniformBlockBinding(ot,dt,L.__bindingPointIndex),c.set(ot,dt))}function Gt(){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,nt={},d={},f=new WeakMap,p=[],v=null,g=!1,m=null,S=null,E=null,_=null,b=null,w=null,R=null,M=new ct(0,0,0),A=0,P=!1,D=null,I=null,F=null,H=null,O=null,$t.set(0,0,s.canvas.width,s.canvas.height),Bt.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:it,disable:B,bindFramebuffer:Et,drawBuffers:It,useProgram:Tt,setBlending:Ot,setMaterial:Ut,setFlipSided:ee,setCullFace:ne,setLineWidth:Te,setPolygonOffset:ve,setScissorTest:Re,activeTexture:Be,bindTexture:N,unbindTexture:xn,compressedTexImage2D:ie,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:Rt,getParameter:ht,updateUBOMapping:Lt,uniformBlockBinding:Ft,texStorage2D:st,texStorage3D:lt,texSubImage2D:x,texSubImage3D:z,compressedTexSubImage2D:X,compressedTexSubImage3D:$,scissor:ft,viewport:ut,reset:Gt}}function o3(s,t,e,n,i,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Pt,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,x){return p?new OffscreenCanvas(T,x):Ra("canvas")}function g(T,x,z){let X=1;const $=ie(T);if(($.width>z||$.height>z)&&(X=z/Math.max($.width,$.height)),X<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 st=Math.floor(X*$.width),lt=Math.floor(X*$.height);d===void 0&&(d=v(st,lt));const Z=x?v(st,lt):d;return Z.width=st,Z.height=lt,Z.getContext("2d").drawImage(T,0,0,st,lt),wt("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+st+"x"+lt+")."),Z}else return"data"in T&&wt("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),T;return T}function m(T){return T.generateMipmaps}function S(T){s.generateMipmap(T)}function E(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,x,z,X,$,st=!1){if(T!==null){if(s[T]!==void 0)return s[T];wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let lt;X&&(lt=t.get("EXT_texture_norm16"),lt||wt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=x;if(x===s.RED&&(z===s.FLOAT&&(Z=s.R32F),z===s.HALF_FLOAT&&(Z=s.R16F),z===s.UNSIGNED_BYTE&&(Z=s.R8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.R16_EXT),z===s.SHORT&&lt&&(Z=lt.R16_SNORM_EXT)),x===s.RED_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.R8UI),z===s.UNSIGNED_SHORT&&(Z=s.R16UI),z===s.UNSIGNED_INT&&(Z=s.R32UI),z===s.BYTE&&(Z=s.R8I),z===s.SHORT&&(Z=s.R16I),z===s.INT&&(Z=s.R32I)),x===s.RG&&(z===s.FLOAT&&(Z=s.RG32F),z===s.HALF_FLOAT&&(Z=s.RG16F),z===s.UNSIGNED_BYTE&&(Z=s.RG8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RG16_EXT),z===s.SHORT&&lt&&(Z=lt.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RG8UI),z===s.UNSIGNED_SHORT&&(Z=s.RG16UI),z===s.UNSIGNED_INT&&(Z=s.RG32UI),z===s.BYTE&&(Z=s.RG8I),z===s.SHORT&&(Z=s.RG16I),z===s.INT&&(Z=s.RG32I)),x===s.RGB_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RGB8UI),z===s.UNSIGNED_SHORT&&(Z=s.RGB16UI),z===s.UNSIGNED_INT&&(Z=s.RGB32UI),z===s.BYTE&&(Z=s.RGB8I),z===s.SHORT&&(Z=s.RGB16I),z===s.INT&&(Z=s.RGB32I)),x===s.RGBA_INTEGER&&(z===s.UNSIGNED_BYTE&&(Z=s.RGBA8UI),z===s.UNSIGNED_SHORT&&(Z=s.RGBA16UI),z===s.UNSIGNED_INT&&(Z=s.RGBA32UI),z===s.BYTE&&(Z=s.RGBA8I),z===s.SHORT&&(Z=s.RGBA16I),z===s.INT&&(Z=s.RGBA32I)),x===s.RGB&&(z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RGB16_EXT),z===s.SHORT&&lt&&(Z=lt.RGB16_SNORM_EXT),z===s.UNSIGNED_INT_5_9_9_9_REV&&(Z=s.RGB9_E5),z===s.UNSIGNED_INT_10F_11F_11F_REV&&(Z=s.R11F_G11F_B10F)),x===s.RGBA){const Q=st?oc:jt.getTransfer($);z===s.FLOAT&&(Z=s.RGBA32F),z===s.HALF_FLOAT&&(Z=s.RGBA16F),z===s.UNSIGNED_BYTE&&(Z=Q===se?s.SRGB8_ALPHA8:s.RGBA8),z===s.UNSIGNED_SHORT&&lt&&(Z=lt.RGBA16_EXT),z===s.SHORT&&lt&&(Z=lt.RGBA16_SNORM_EXT),z===s.UNSIGNED_SHORT_4_4_4_4&&(Z=s.RGBA4),z===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)&&t.get("EXT_color_buffer_float"),Z}function b(T,x){let z;return T?x===null||x===ei||x===Aa?z=s.DEPTH24_STENCIL8:x===Gn?z=s.DEPTH32F_STENCIL8:x===wa&&(z=s.DEPTH24_STENCIL8,wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Aa?z=s.DEPTH_COMPONENT24:x===Gn?z=s.DEPTH_COMPONENT32F:x===wa&&(z=s.DEPTH_COMPONENT16),z}function w(T,x){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==We&&T.minFilter!==ye?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function M(T){const x=T.target;x.removeEventListener("dispose",M),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const z=T.source,X=f.get(z);if(X){const $=X[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&P(T),Object.keys(X).length===0&&f.delete(z)}n.remove(T)}function P(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const z=T.source,X=f.get(z);delete X[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let X=0;X<6;X++){if(Array.isArray(x.__webglFramebuffer[X]))for(let $=0;$<x.__webglFramebuffer[X].length;$++)s.deleteFramebuffer(x.__webglFramebuffer[X][$]);else s.deleteFramebuffer(x.__webglFramebuffer[X]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[X])}else{if(Array.isArray(x.__webglFramebuffer))for(let X=0;X<x.__webglFramebuffer.length;X++)s.deleteFramebuffer(x.__webglFramebuffer[X]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let X=0;X<x.__webglColorRenderbuffer.length;X++)x.__webglColorRenderbuffer[X]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[X]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const z=T.textures;for(let X=0,$=z.length;X<$;X++){const st=n.get(z[X]);st.__webglTexture&&(s.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(z[X])}n.remove(T)}let I=0;function F(){I=0}function H(){return I}function O(T){I=T}function V(){const T=I;return T>=i.maxTextures&&wt("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),I+=1,T}function k(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Y(T,x){const z=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&z.__version!==T.version){const X=T.image;if(X===null)wt("WebGLRenderer: Texture marked for update but no image data found.");else if(X.complete===!1)wt("WebGLRenderer: Texture marked for update but image is incomplete");else{B(z,T,x);return}}else T.isExternalTexture&&(z.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,z.__webglTexture,s.TEXTURE0+x)}function tt(T,x){const z=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&z.__version!==T.version){B(z,T,x);return}else T.isExternalTexture&&(z.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D_ARRAY,z.__webglTexture,s.TEXTURE0+x)}function J(T,x){const z=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&z.__version!==T.version){B(z,T,x);return}e.bindTexture(s.TEXTURE_3D,z.__webglTexture,s.TEXTURE0+x)}function nt(T,x){const z=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&z.__version!==T.version){Et(z,T,x);return}e.bindTexture(s.TEXTURE_CUBE_MAP,z.__webglTexture,s.TEXTURE0+x)}const at={[Ea]:s.REPEAT,[gn]:s.CLAMP_TO_EDGE,[uh]:s.MIRRORED_REPEAT},Ht={[We]:s.NEAREST,[I1]:s.NEAREST_MIPMAP_NEAREST,[Ya]:s.NEAREST_MIPMAP_LINEAR,[ye]:s.LINEAR,[Bc]:s.LINEAR_MIPMAP_NEAREST,[Ds]:s.LINEAR_MIPMAP_LINEAR},$t={[U1]:s.NEVER,[H1]:s.ALWAYS,[F1]:s.LESS,[Nu]:s.LEQUAL,[z1]:s.EQUAL,[Ou]:s.GEQUAL,[k1]:s.GREATER,[B1]:s.NOTEQUAL};function Bt(T,x){if(x.type===Gn&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===ye||x.magFilter===Bc||x.magFilter===Ya||x.magFilter===Ds||x.minFilter===ye||x.minFilter===Bc||x.minFilter===Ya||x.minFilter===Ds)&&wt("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,at[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,at[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,at[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ht[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ht[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,$t[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===We||x.minFilter!==Ya&&x.minFilter!==Ds||x.type===Gn&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const z=t.get("EXT_texture_filter_anisotropic");s.texParameterf(T,z.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function K(T,x){let z=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const X=x.source;let $=f.get(X);$===void 0&&($={},f.set(X,$));const st=k(x);if(st!==T.__cacheKey){$[st]===void 0&&($[st]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,z=!0),$[st].usedTimes++;const lt=$[T.__cacheKey];lt!==void 0&&($[T.__cacheKey].usedTimes--,lt.usedTimes===0&&P(x)),T.__cacheKey=st,T.__webglTexture=$[st].texture}return z}function rt(T,x,z){return Math.floor(Math.floor(T/z)/x)}function it(T,x,z,X){const st=T.updateRanges;if(st.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,z,X,x.data);else{st.sort((Rt,ft)=>Rt.start-ft.start);let lt=0;for(let Rt=1;Rt<st.length;Rt++){const ft=st[lt],ut=st[Rt],Lt=ft.start+ft.count,Ft=rt(ut.start,x.width,4),Gt=rt(ft.start,x.width,4);ut.start<=Lt+1&&Ft===Gt&&rt(ut.start+ut.count-1,x.width,4)===Ft?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,st[lt]=ut)}st.length=lt+1;const Z=e.getParameter(s.UNPACK_ROW_LENGTH),Q=e.getParameter(s.UNPACK_SKIP_PIXELS),ht=e.getParameter(s.UNPACK_SKIP_ROWS);e.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let Rt=0,ft=st.length;Rt<ft;Rt++){const ut=st[Rt],Lt=Math.floor(ut.start/4),Ft=Math.ceil(ut.count/4),Gt=Lt%x.width,L=Math.floor(Lt/x.width),ot=Ft,j=1;e.pixelStorei(s.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(s.UNPACK_SKIP_ROWS,L),e.texSubImage2D(s.TEXTURE_2D,0,Gt,L,ot,j,z,X,x.data)}T.clearUpdateRanges(),e.pixelStorei(s.UNPACK_ROW_LENGTH,Z),e.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(s.UNPACK_SKIP_ROWS,ht)}}function B(T,x,z){let X=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(X=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(X=s.TEXTURE_3D);const $=K(T,x),st=x.source;e.bindTexture(X,T.__webglTexture,s.TEXTURE0+z);const lt=n.get(st);if(st.version!==lt.__version||$===!0){if(e.activeTexture(s.TEXTURE0+z),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const j=jt.getPrimaries(jt.workingColorSpace),dt=x.colorSpace===as?null:jt.getPrimaries(x.colorSpace),vt=x.colorSpace===as||j===dt?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=g(x.image,!1,i.maxTextureSize);Q=xn(x,Q);const ht=r.convert(x.format,x.colorSpace),Rt=r.convert(x.type);let ft=_(x.internalFormat,ht,Rt,x.normalized,x.colorSpace,x.isVideoTexture);Bt(X,x);let ut;const Lt=x.mipmaps,Ft=x.isVideoTexture!==!0,Gt=lt.__version===void 0||$===!0,L=st.dataReady,ot=w(x,Q);if(x.isDepthTexture)ft=b(x.format===Cs,x.type),Gt&&(Ft?e.texStorage2D(s.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(s.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Rt,null));else if(x.isDataTexture)if(Lt.length>0){Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Lt[0].width,Lt[0].height);for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Rt,ut.data):e.texImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Rt,ut.data);x.generateMipmaps=!1}else Ft?(Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Q.width,Q.height),L&&it(x,Q,ht,Rt)):e.texImage2D(s.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,Rt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Ft&&Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,ot,ft,Lt[0].width,Lt[0].height,Q.depth);for(let j=0,dt=Lt.length;j<dt;j++)if(ut=Lt[j],x.format!==vn)if(ht!==null)if(Ft){if(L)if(x.layerUpdates.size>0){const vt=C0(ut.width,ut.height,x.format,x.type);for(const et of x.layerUpdates){const At=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,At)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ft?L&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,Rt,ut.data):e.texImage3D(s.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,Rt,ut.data)}else{Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,ot,ft,Lt[0].width,Lt[0].height);for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],x.format!==vn?ht!==null?Ft?L&&e.compressedTexSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,Rt,ut.data):e.texImage2D(s.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,Rt,ut.data)}else if(x.isDataArrayTexture)if(Ft){if(Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,ot,ft,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const j=C0(Q.width,Q.height,x.format,x.type);for(const dt of x.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,Rt,vt)}x.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,Rt,Q.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,Rt,Q.data);else if(x.isData3DTexture)Ft?(Gt&&e.texStorage3D(s.TEXTURE_3D,ot,ft,Q.width,Q.height,Q.depth),L&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,Rt,Q.data)):e.texImage3D(s.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,Rt,Q.data);else if(x.isFramebufferTexture){if(Gt)if(Ft)e.texStorage2D(s.TEXTURE_2D,ot,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ot;vt++)e.texImage2D(s.TEXTURE_2D,vt,ft,j,dt,0,ht,Rt,null),j>>=1,dt>>=1}}else if(x.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(x),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const vt=s.RGBA,et=s.RGBA,At=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,vt,et,At,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(Lt.length>0){if(Ft&&Gt){const j=ie(Lt[0]);e.texStorage2D(s.TEXTURE_2D,ot,ft,j.width,j.height)}for(let j=0,dt=Lt.length;j<dt;j++)ut=Lt[j],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,j,0,0,ht,Rt,ut):e.texImage2D(s.TEXTURE_2D,j,ft,ht,Rt,ut);x.generateMipmaps=!1}else if(Ft){if(Gt){const j=ie(Q);e.texStorage2D(s.TEXTURE_2D,ot,ft,j.width,j.height)}L&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,ht,Rt,Q)}else e.texImage2D(s.TEXTURE_2D,0,ft,ht,Rt,Q);m(x)&&S(X),lt.__version=st.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Et(T,x,z){if(x.image.length!==6)return;const X=K(T,x),$=x.source;e.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+z);const st=n.get($);if($.version!==st.__version||X===!0){e.activeTexture(s.TEXTURE0+z);const lt=jt.getPrimaries(jt.workingColorSpace),Z=x.colorSpace===as?null:jt.getPrimaries(x.colorSpace),Q=x.colorSpace===as||lt===Z?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=x.isCompressedTexture||x.image[0].isCompressedTexture,Rt=x.image[0]&&x.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!Rt?ft[et]=g(x.image[et],!0,i.maxCubemapSize):ft[et]=Rt?x.image[et].image:x.image[et],ft[et]=xn(x,ft[et]);const ut=ft[0],Lt=r.convert(x.format,x.colorSpace),Ft=r.convert(x.type),Gt=_(x.internalFormat,Lt,Ft,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,ot=st.__version===void 0||X===!0,j=$.dataReady;let dt=w(x,ut);Bt(s.TEXTURE_CUBE_MAP,x);let vt;if(ht){L&&ot&&e.texStorage2D(s.TEXTURE_CUBE_MAP,dt,Gt,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let At=0;At<vt.length;At++){const yt=vt[At];x.format!==vn?Lt!==null?L?j&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,0,0,yt.width,yt.height,Lt,yt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,Gt,yt.width,yt.height,0,yt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,0,0,yt.width,yt.height,Lt,Ft,yt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At,Gt,yt.width,yt.height,0,Lt,Ft,yt.data)}}}else{if(vt=x.mipmaps,L&&ot){vt.length>0&&dt++;const et=ie(ft[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,dt,Gt,et.width,et.height)}for(let et=0;et<6;et++)if(Rt){L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Lt,Ft,ft[et].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Gt,ft[et].width,ft[et].height,0,Lt,Ft,ft[et].data);for(let At=0;At<vt.length;At++){const De=vt[At].image[et].image;L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,0,0,De.width,De.height,Lt,Ft,De.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,Gt,De.width,De.height,0,Lt,Ft,De.data)}}else{L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Lt,Ft,ft[et]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Gt,Lt,Ft,ft[et]);for(let At=0;At<vt.length;At++){const yt=vt[At];L?j&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,0,0,Lt,Ft,yt.image[et]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+et,At+1,Gt,Lt,Ft,yt.image[et])}}}m(x)&&S(s.TEXTURE_CUBE_MAP),st.__version=$.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function It(T,x,z,X,$,st){const lt=r.convert(z.format,z.colorSpace),Z=r.convert(z.type),Q=_(z.internalFormat,lt,Z,z.normalized,z.colorSpace),ht=n.get(x),Rt=n.get(z);if(Rt.__renderTarget=x,!ht.__hasExternalTextures){const ft=Math.max(1,x.width>>st),ut=Math.max(1,x.height>>st);$===s.TEXTURE_3D||$===s.TEXTURE_2D_ARRAY?e.texImage3D($,st,Q,ft,ut,x.depth,0,lt,Z,null):e.texImage2D($,st,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(s.FRAMEBUFFER,T),Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,X,$,Rt.__webglTexture,0,Re(x)):($===s.TEXTURE_2D||$>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,X,$,Rt.__webglTexture,st),e.bindFramebuffer(s.FRAMEBUFFER,null)}function Tt(T,x,z){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const X=x.depthTexture,$=X&&X.isDepthTexture?X.type:null,st=b(x.stencilBuffer,$),lt=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Be(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Re(x),st,x.width,x.height):z?s.renderbufferStorageMultisample(s.RENDERBUFFER,Re(x),st,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,st,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,lt,s.RENDERBUFFER,T)}else{const X=x.textures;for(let $=0;$<X.length;$++){const st=X[$],lt=r.convert(st.format,st.colorSpace),Z=r.convert(st.type),Q=_(st.internalFormat,lt,Z,st.normalized,st.colorSpace);Be(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,Re(x),Q,x.width,x.height):z?s.renderbufferStorageMultisample(s.RENDERBUFFER,Re(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function xt(T,x,z){const X=x.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=n.get(x.depthTexture);if($.__renderTarget=x,(!$.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),X){if($.__webglInit===void 0&&($.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),$.__webglTexture===void 0){$.__webglTexture=s.createTexture(),e.bindTexture(s.TEXTURE_CUBE_MAP,$.__webglTexture),Bt(s.TEXTURE_CUBE_MAP,x.depthTexture);const ht=r.convert(x.depthTexture.format),Rt=r.convert(x.depthTexture.type);let ft;x.depthTexture.format===ki?ft=s.DEPTH_COMPONENT24:x.depthTexture.format===Cs&&(ft=s.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,x.width,x.height,0,ht,Rt,null)}}else Y(x.depthTexture,0);const st=$.__webglTexture,lt=Re(x),Z=X?s.TEXTURE_CUBE_MAP_POSITIVE_X+z:s.TEXTURE_2D,Q=x.depthTexture.format===Cs?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===ki)Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,st,0,lt):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,st,0);else if(x.depthTexture.format===Cs)Be(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,Z,st,0,lt):s.framebufferTexture2D(s.FRAMEBUFFER,Q,Z,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Nt(T){const x=n.get(T),z=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const X=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),X){const $=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,X.removeEventListener("dispose",$)};X.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=X}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(z)for(let X=0;X<6;X++)xt(x.__webglFramebuffer[X],T,X);else{const X=T.texture.mipmaps;X&&X.length>0?xt(x.__webglFramebuffer[0],T,0):xt(x.__webglFramebuffer,T,0)}else if(z){x.__webglDepthbuffer=[];for(let X=0;X<6;X++)if(e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[X]),x.__webglDepthbuffer[X]===void 0)x.__webglDepthbuffer[X]=s.createRenderbuffer(),Tt(x.__webglDepthbuffer[X],T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer[X];s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,st)}}else{const X=T.texture.mipmaps;if(X&&X.length>0?e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Tt(x.__webglDepthbuffer,T,!1);else{const $=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,$,s.RENDERBUFFER,st)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Ot(T,x,z){const X=n.get(T);x!==void 0&&It(X.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),z!==void 0&&Nt(T)}function Ut(T){const x=T.texture,z=n.get(T),X=n.get(x);T.addEventListener("dispose",M);const $=T.textures,st=T.isWebGLCubeRenderTarget===!0,lt=$.length>1;if(lt||(X.__webglTexture===void 0&&(X.__webglTexture=s.createTexture()),X.__version=x.version,a.memory.textures++),st){z.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0){z.__webglFramebuffer[Z]=[];for(let Q=0;Q<x.mipmaps.length;Q++)z.__webglFramebuffer[Z][Q]=s.createFramebuffer()}else z.__webglFramebuffer[Z]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){z.__webglFramebuffer=[];for(let Z=0;Z<x.mipmaps.length;Z++)z.__webglFramebuffer[Z]=s.createFramebuffer()}else z.__webglFramebuffer=s.createFramebuffer();if(lt)for(let Z=0,Q=$.length;Z<Q;Z++){const ht=n.get($[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Be(T)===!1){z.__webglMultisampledFramebuffer=s.createFramebuffer(),z.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,z.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];z.__webglColorRenderbuffer[Z]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,z.__webglColorRenderbuffer[Z]);const ht=r.convert(Q.format,Q.colorSpace),Rt=r.convert(Q.type),ft=_(Q.internalFormat,ht,Rt,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),ut=Re(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,ut,ft,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+Z,s.RENDERBUFFER,z.__webglColorRenderbuffer[Z])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(z.__webglDepthRenderbuffer=s.createRenderbuffer(),Tt(z.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(st){e.bindTexture(s.TEXTURE_CUBE_MAP,X.__webglTexture),Bt(s.TEXTURE_CUBE_MAP,x);for(let Z=0;Z<6;Z++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(z.__webglFramebuffer[Z][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else It(z.__webglFramebuffer[Z],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);m(x)&&S(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=$.length;Z<Q;Z++){const ht=$[Z],Rt=n.get(ht);let ft=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(ft=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(ft,Rt.__webglTexture),Bt(ft,ht),It(z.__webglFramebuffer,T,ht,s.COLOR_ATTACHMENT0+Z,ft,0),m(ht)&&S(ft)}e.unbindTexture()}else{let Z=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(Z,X.__webglTexture),Bt(Z,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(z.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,Z,Q);else It(z.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,Z,0);m(x)&&S(Z),e.unbindTexture()}T.depthBuffer&&Nt(T)}function ee(T){const x=T.textures;for(let z=0,X=x.length;z<X;z++){const $=x[z];if(m($)){const st=E(T),lt=n.get($).__webglTexture;e.bindTexture(st,lt),S(st),e.unbindTexture()}}}const ne=[],Te=[];function ve(T){if(T.samples>0){if(Be(T)===!1){const x=T.textures,z=T.width,X=T.height;let $=s.COLOR_BUFFER_BIT;const st=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,lt=n.get(T),Z=x.length>1;if(Z)for(let ht=0;ht<x.length;ht++)e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<x.length;ht++){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,lt.__webglColorRenderbuffer[ht]);const Rt=n.get(x[ht]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Rt,0)}s.blitFramebuffer(0,0,z,X,0,0,z,X,$,s.NEAREST),c===!0&&(ne.length=0,Te.length=0,ne.push(s.COLOR_ATTACHMENT0+ht),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ne.push(st),Te.push(st),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Te)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ne))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<x.length;ht++){e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const Rt=n.get(x[ht]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,lt.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ht,s.TEXTURE_2D,Rt,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function Re(T){return Math.min(i.maxSamples,T.samples)}function Be(T){const x=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function xn(T,x){const z=T.colorSpace,X=T.format,$=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||z!==ac&&z!==as&&(jt.getTransfer(z)===se?(X!==vn||$!==In)&&wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zt("WebGLTextures: Unsupported texture color space:",z)),x}function ie(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=F,this.getTextureUnits=H,this.setTextureUnits=O,this.setTexture2D=Y,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=nt,this.rebindTextures=Ot,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ve,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=It,this.useMultisampledRTT=Be,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function c3(s,t){function e(n,i=as){let r;const a=jt.getTransfer(i);if(n===In)return s.UNSIGNED_BYTE;if(n===Du)return s.UNSIGNED_SHORT_4_4_4_4;if(n===Cu)return s.UNSIGNED_SHORT_5_5_5_1;if(n===zp)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===kp)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===Up)return s.BYTE;if(n===Fp)return s.SHORT;if(n===wa)return s.UNSIGNED_SHORT;if(n===Ru)return s.INT;if(n===ei)return s.UNSIGNED_INT;if(n===Gn)return s.FLOAT;if(n===cn)return s.HALF_FLOAT;if(n===Bp)return s.ALPHA;if(n===Hp)return s.RGB;if(n===vn)return s.RGBA;if(n===ki)return s.DEPTH_COMPONENT;if(n===Cs)return s.DEPTH_STENCIL;if(n===wc)return s.RED;if(n===Pu)return s.RED_INTEGER;if(n===Us)return s.RG;if(n===Iu)return s.RG_INTEGER;if(n===Lu)return s.RGBA_INTEGER;if(n===Wo||n===Xo||n===qo||n===Yo)if(a===se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Wo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Xo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===qo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Yo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Wo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Xo)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===qo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Yo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===dh||n===fh||n===ph||n===mh)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===dh)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===fh)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===ph)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===mh)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===gh||n===vh||n===Mh||n===xh||n===_h||n===nc||n===yh)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===gh||n===vh)return a===se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Mh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===xh)return r.COMPRESSED_R11_EAC;if(n===_h)return r.COMPRESSED_SIGNED_R11_EAC;if(n===nc)return r.COMPRESSED_RG11_EAC;if(n===yh)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Sh||n===bh||n===Eh||n===wh||n===Ah||n===Th||n===Rh||n===Dh||n===Ch||n===Ph||n===Ih||n===Lh||n===Nh||n===Oh)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Sh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===bh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Eh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===wh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Ah)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Th)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Rh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Dh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Ch)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ph)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Ih)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Lh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Nh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Oh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===Uh||n===Fh||n===zh)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===Uh)return a===se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Fh)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===zh)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===kh||n===Bh||n===ic||n===Hh)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===kh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Bh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===ic)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Hh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Aa?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}const l3=`
4606
4606
  void main() {
4607
4607
 
4608
4608
  gl_Position = vec4( position, 1.0 );
@@ -4626,7 +4626,7 @@ void main() {
4626
4626
 
4627
4627
  }
4628
4628
 
4629
- }`;class u3{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new jp(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Ae({vertexShader:l3,fragmentShader:h3,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new qt(new Wi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class d3 extends Bs{constructor(t,e){super();const n=this;let i=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",g=new u3,m={},S=e.getContextAttributes();let E=null,_=null;const b=[],w=[],R=new Pt;let M=null;const A=new En;A.viewport=new le;const P=new En;P.viewport=new le;const D=[A,P],I=new f2;let F=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getGripSpace()},this.getHand=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getHandSpace()};function O(K){const rt=w.indexOf(K.inputSource);if(rt===-1)return;const it=b[rt];it!==void 0&&(it.update(K.inputSource,K.frame,l||a),it.dispatchEvent({type:K.type,data:K.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",k);for(let K=0;K<b.length;K++){const rt=w[K];rt!==null&&(w[K]=null,b[K].disconnect(rt))}F=null,H=null,g.reset();for(const K in m)delete m[K];t.setRenderTarget(E),f=null,d=null,u=null,i=null,_=null,Bt.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&wt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&wt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(E=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",V),i.addEventListener("inputsourceschange",k),S.xrCompatible!==!0&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let it=null,B=null,Et=null;S.depth&&(Et=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,it=S.stencil?Cs:ki,B=S.stencil?Aa:ti);const It={colorFormat:e.RGBA8,depthFormat:Et,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(It),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new wn(d.textureWidth,d.textureHeight,{format:vn,type:In,depthTexture:new Fs(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,it),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const it={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,e,it),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new wn(f.framebufferWidth,f.framebufferHeight,{format:vn,type:In,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),Bt.setContext(i),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function k(K){for(let rt=0;rt<K.removed.length;rt++){const it=K.removed[rt],B=w.indexOf(it);B>=0&&(w[B]=null,b[B].disconnect(it))}for(let rt=0;rt<K.added.length;rt++){const it=K.added[rt];let B=w.indexOf(it);if(B===-1){for(let It=0;It<b.length;It++)if(It>=w.length){w.push(it),B=It;break}else if(w[It]===null){w[It]=it,B=It;break}if(B===-1)break}const Et=b[B];Et&&Et.connect(it)}}const Y=new C,tt=new C;function J(K,rt,it){Y.setFromMatrixPosition(rt.matrixWorld),tt.setFromMatrixPosition(it.matrixWorld);const B=Y.distanceTo(tt),Et=rt.projectionMatrix.elements,It=it.projectionMatrix.elements,Tt=Et[14]/(Et[10]-1),xt=Et[14]/(Et[10]+1),Nt=(Et[9]+1)/Et[5],Ot=(Et[9]-1)/Et[5],Ut=(Et[8]-1)/Et[0],ee=(It[8]+1)/It[0],ne=Tt*Ut,Te=Tt*ee,ve=B/(-Ut+ee),Re=ve*-Ut;if(rt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Re),K.translateZ(ve),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Et[10]===-1)K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Be=Tt+ve,N=xt+ve,xn=ne-Re,ie=Te+(B-Re),T=Nt*xt/N*Be,x=Ot*xt/N*Be;K.projectionMatrix.makePerspective(xn,ie,T,x,Be,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function nt(K,rt){rt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(rt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let rt=K.near,it=K.far;g.texture!==null&&(g.depthNear>0&&(rt=g.depthNear),g.depthFar>0&&(it=g.depthFar)),I.near=P.near=A.near=rt,I.far=P.far=A.far=it,(F!==I.near||H!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),F=I.near,H=I.far),I.layers.mask=K.layers.mask|6,A.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;const B=K.parent,Et=I.cameras;nt(I,B);for(let It=0;It<Et.length;It++)nt(Et[It],B);Et.length===2?J(I,A,P):I.projectionMatrix.copy(A.projectionMatrix),at(K,I,B)};function at(K,rt,it){it===null?K.matrix.copy(rt.matrixWorld):(K.matrix.copy(it.matrixWorld),K.matrix.invert(),K.matrix.multiply(rt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Lr*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(K){return m[K]};let Ht=null;function $t(K,rt){if(h=rt.getViewerPose(l||a),p=rt,h!==null){const it=h.views;f!==null&&(t.setRenderTargetFramebuffer(_,f.framebuffer),t.setRenderTarget(_));let B=!1;it.length!==I.cameras.length&&(I.cameras.length=0,B=!0);for(let xt=0;xt<it.length;xt++){const Nt=it[xt];let Ot=null;if(f!==null)Ot=f.getViewport(Nt);else{const ee=u.getViewSubImage(d,Nt);Ot=ee.viewport,xt===0&&(t.setRenderTargetTextures(_,ee.colorTexture,ee.depthStencilTexture),t.setRenderTarget(_))}let Ut=D[xt];Ut===void 0&&(Ut=new En,Ut.layers.enable(xt),Ut.viewport=new le,D[xt]=Ut),Ut.matrix.fromArray(Nt.transform.matrix),Ut.matrix.decompose(Ut.position,Ut.quaternion,Ut.scale),Ut.projectionMatrix.fromArray(Nt.projectionMatrix),Ut.projectionMatrixInverse.copy(Ut.projectionMatrix).invert(),Ut.viewport.set(Ot.x,Ot.y,Ot.width,Ot.height),xt===0&&(I.matrix.copy(Ut.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),B===!0&&I.cameras.push(Ut)}const Et=i.enabledFeatures;if(Et&&Et.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const xt=u.getDepthInformation(it[0]);xt&&xt.isValid&&xt.texture&&g.init(xt,i.renderState)}if(Et&&Et.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let xt=0;xt<it.length;xt++){const Nt=it[xt].camera;if(Nt){let Ot=m[Nt];Ot||(Ot=new jp,m[Nt]=Ot);const Ut=u.getCameraImage(Nt);Ot.sourceTexture=Ut}}}}for(let it=0;it<b.length;it++){const B=w[it],Et=b[it];B!==null&&Et!==void 0&&Et.update(B,rt,l||a)}Ht&&Ht(K,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),p=null}const Bt=new sm;Bt.setAnimationLoop($t),this.setAnimationLoop=function(K){Ht=K},this.dispose=function(){}}}const f3=new Wt,um=new kt;um.set(-1,0,0,0,1,0,0,0,1);function p3(s,t){function e(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Qp(s)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,S,E,_){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?r(g,m):m.isMeshLambertMaterial?(r(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(r(g,m),u(g,m)):m.isMeshPhongMaterial?(r(g,m),h(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(r(g,m),d(g,m),m.isMeshPhysicalMaterial&&f(g,m,_)):m.isMeshMatcapMaterial?(r(g,m),p(g,m)):m.isMeshDepthMaterial?r(g,m):m.isMeshDistanceMaterial?(r(g,m),v(g,m)):m.isMeshNormalMaterial?r(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?c(g,m,S,E):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,e(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===ze&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,e(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===ze&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,e(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,e(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const S=t.get(m),E=S.envMap,_=S.envMapRotation;E&&(g.envMap.value=E,g.envMapRotation.value.setFromMatrix4(f3.makeRotationFromEuler(_)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(um),g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,S,E){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*S,g.scale.value=E*.5,m.map&&(g.map.value=m.map,e(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,S){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ze&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=S.texture,g.transmissionSamplerSize.value.set(S.width,S.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function v(g,m){const S=t.get(m).light;g.referencePosition.value.setFromMatrixPosition(S.matrixWorld),g.nearDistance.value=S.shadow.camera.near,g.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function m3(s,t,e,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,b){const w=b.program;n.uniformBlockBinding(_,w)}function l(_,b){let w=i[_.id];w===void 0&&(g(_),w=h(_),i[_.id]=w,_.addEventListener("dispose",S));const R=b.program;n.updateUBOMapping(_,R);const M=t.render.frame;r[_.id]!==M&&(d(_),r[_.id]=M)}function h(_){const b=u();_.__bindingPointIndex=b;const w=s.createBuffer(),R=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,b,w),w}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return zt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const b=i[_.id],w=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,b);for(let M=0,A=w.length;M<A;M++){const P=w[M];if(Array.isArray(P))for(let D=0,I=P.length;D<I;D++)f(P[D],M,D,R);else f(P,M,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,b,w,R){if(v(_,b,w,R)===!0){const M=_.__offset,A=_.value;if(Array.isArray(A)){let P=0;for(let D=0;D<A.length;D++){const I=A[D],F=m(I);p(I,_.__data,P),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(P+=F.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,M,_.__data)}}function p(_,b,w){typeof _=="number"||typeof _=="boolean"?b[0]=_:_.isMatrix3?(b[0]=_.elements[0],b[1]=_.elements[1],b[2]=_.elements[2],b[3]=0,b[4]=_.elements[3],b[5]=_.elements[4],b[6]=_.elements[5],b[7]=0,b[8]=_.elements[6],b[9]=_.elements[7],b[10]=_.elements[8],b[11]=0):ArrayBuffer.isView(_)?b.set(new _.constructor(_.buffer,_.byteOffset,b.length)):_.toArray(b,w)}function v(_,b,w,R){const M=_.value,A=b+"_"+w;if(R[A]===void 0)return typeof M=="number"||typeof M=="boolean"?R[A]=M:ArrayBuffer.isView(M)?R[A]=M.slice():R[A]=M.clone(),!0;{const P=R[A];if(typeof M=="number"||typeof M=="boolean"){if(P!==M)return R[A]=M,!0}else{if(ArrayBuffer.isView(M))return!0;if(P.equals(M)===!1)return P.copy(M),!0}}return!1}function g(_){const b=_.uniforms;let w=0;const R=16;for(let A=0,P=b.length;A<P;A++){const D=Array.isArray(b[A])?b[A]:[b[A]];for(let I=0,F=D.length;I<F;I++){const H=D[I],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,k=O.length;V<k;V++){const Y=O[V],tt=m(Y),J=w%R,nt=J%tt.boundary,at=J+nt;w+=nt,at!==0&&R-at<tt.storage&&(w+=R-at),H.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=w,w+=tt.storage}}}const M=w%R;return M>0&&(w+=R-M),_.__size=w,_.__cache={},this}function m(_){const b={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(b.boundary=4,b.storage=4):_.isVector2?(b.boundary=8,b.storage=8):_.isVector3||_.isColor?(b.boundary=16,b.storage=12):_.isVector4?(b.boundary=16,b.storage=16):_.isMatrix3?(b.boundary=48,b.storage=48):_.isMatrix4?(b.boundary=64,b.storage=64):_.isTexture?wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(b.boundary=16,b.storage=_.byteLength):wt("WebGLRenderer: Unsupported uniform value type.",_),b}function S(_){const b=_.target;b.removeEventListener("dispose",S);const w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[b.id]),delete i[b.id],delete r[b.id]}function E(){for(const _ in i)s.deleteBuffer(i[_]);a=[],i={},r={}}return{bind:c,update:l,dispose:E}}const g3=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 oi=null;function v3(){return oi===null&&(oi=new Ur(g3,16,16,Us,cn),oi.name="DFG_LUT",oi.minFilter=ye,oi.magFilter=ye,oi.wrapS=gn,oi.wrapT=gn,oi.generateMipmaps=!1,oi.needsUpdate=!0),oi}class M3{constructor(t={}){const{canvas:e=W1(),context:n=null,depth:i=!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=In}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const v=f,g=new Set([Lu,Iu,Pu]),m=new Set([In,ti,wa,Aa,Du,Cu]),S=new Uint32Array(4),E=new Int32Array(4),_=new C;let b=null,w=null;const R=[],M=[];let A=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=xi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let D=!1,I=null,F=null,H=null,O=null;this._outputColorSpace=Pn;let V=0,k=0,Y=null,tt=-1,J=null;const nt=new le,at=new le;let Ht=null;const $t=new ct(0);let Bt=0,K=e.width,rt=e.height,it=1,B=null,Et=null;const It=new le(0,0,K,rt),Tt=new le(0,0,K,rt);let xt=!1;const Nt=new Bu;let Ot=!1,Ut=!1;const ee=new Wt,ne=new C,Te=new le,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Re=!1;function Be(){return Y===null?it:1}let N=n;function xn(y,U){return e.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Au}`),e.addEventListener("webglcontextlost",De,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",ii,!1),N===null){const U="webgl2";if(N=xn(U,y),N===null)throw xn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw zt("WebGLRenderer: "+y.message),y}let ie,T,x,z,X,$,st,lt,Z,Q,ht,Rt,ft,ut,Lt,Ft,Gt,L,ot,j,dt,vt,et;function At(){ie=new v_(N),ie.init(),dt=new c3(N,ie),T=new l_(N,ie,t,dt),x=new a3(N,ie),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),F=N.createFramebuffer(),H=N.createFramebuffer(),O=N.createFramebuffer(),z=new __(N),X=new qy,$=new o3(N,ie,x,X,T,dt,z),st=new g_(P),lt=new E2(N),vt=new o_(N,lt),Z=new M_(N,lt,z,vt),Q=new S_(N,Z,lt,vt,z),L=new y_(N,T,$),Lt=new h_(X),ht=new Xy(P,st,ie,T,vt,Lt),Rt=new p3(P,X),ft=new Ky,ut=new t3(ie),Gt=new a_(P,st,x,Q,p,c),Ft=new r3(P,Q,T),et=new m3(N,z,T,x),ot=new c_(N,ie,z),j=new x_(N,ie,z),z.programs=ht.programs,P.capabilities=T,P.extensions=ie,P.properties=X,P.renderLists=ft,P.shadowMap=Ft,P.state=x,P.info=z}At(),v!==In&&(A=new E_(v,e.width,e.height,o,i,r));const yt=new d3(P,N);this.xr=yt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ie.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ie.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return it},this.setPixelRatio=function(y){y!==void 0&&(it=y,this.setSize(K,rt,!1))},this.getSize=function(y){return y.set(K,rt)},this.setSize=function(y,U,q=!0){if(yt.isPresenting){wt("WebGLRenderer: Can't change size while VR device is presenting.");return}K=y,rt=U,e.width=Math.floor(y*it),e.height=Math.floor(U*it),q===!0&&(e.style.width=y+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(K*it,rt*it).floor()},this.setDrawingBufferSize=function(y,U,q){K=y,rt=U,it=q,e.width=Math.floor(y*q),e.height=Math.floor(U*q),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===In){zt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){wt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(nt)},this.getViewport=function(y){return y.copy(It)},this.setViewport=function(y,U,q,G){y.isVector4?It.set(y.x,y.y,y.z,y.w):It.set(y,U,q,G),x.viewport(nt.copy(It).multiplyScalar(it).round())},this.getScissor=function(y){return y.copy(Tt)},this.setScissor=function(y,U,q,G){y.isVector4?Tt.set(y.x,y.y,y.z,y.w):Tt.set(y,U,q,G),x.scissor(at.copy(Tt).multiplyScalar(it).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(y){x.setScissorTest(xt=y)},this.setOpaqueSort=function(y){B=y},this.setTransparentSort=function(y){Et=y},this.getClearColor=function(y){return y.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,q=!0){let G=0;if(y){let W=!1;if(Y!==null){const gt=Y.texture.format;W=g.has(gt)}if(W){const gt=Y.texture.type,_t=m.has(gt),mt=Gt.getClearColor(),bt=Gt.getClearAlpha(),Dt=mt.r,Vt=mt.g,Yt=mt.b;_t?(S[0]=Dt,S[1]=Vt,S[2]=Yt,S[3]=bt,N.clearBufferuiv(N.COLOR,0,S)):(E[0]=Dt,E[1]=Vt,E[2]=Yt,E[3]=bt,N.clearBufferiv(N.COLOR,0,E))}else G|=N.COLOR_BUFFER_BIT}U&&(G|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(G|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&N.clear(G)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){e.removeEventListener("webglcontextlost",De,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",ii,!1),Gt.dispose(),ft.dispose(),ut.dispose(),X.dispose(),st.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),yt.dispose(),yt.removeEventListener("sessionstart",ed),yt.removeEventListener("sessionend",nd),ps.stop()};function De(y){y.preventDefault(),cc("WebGLRenderer: Context Lost."),D=!0}function fe(){cc("WebGLRenderer: Context Restored."),D=!1;const y=z.autoReset,U=Ft.enabled,q=Ft.autoUpdate,G=Ft.needsUpdate,W=Ft.type;At(),z.autoReset=y,Ft.enabled=U,Ft.autoUpdate=q,Ft.needsUpdate=G,Ft.type=W}function ii(y){zt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function si(y){const U=y.target;U.removeEventListener("dispose",si),jm(U)}function jm(y){Qm(y),X.remove(y)}function Qm(y){const U=X.get(y).programs;U!==void 0&&(U.forEach(function(q){ht.releaseProgram(q)}),y.isShaderMaterial&&ht.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,q,G,W,gt){U===null&&(U=ve);const _t=W.isMesh&&W.matrixWorld.determinantAffine()<0,mt=ng(y,U,q,G,W);x.setMaterial(G,_t);let bt=q.index,Dt=1;if(G.wireframe===!0){if(bt=Z.getWireframeAttribute(q),bt===void 0)return;Dt=2}const Vt=q.drawRange,Yt=q.attributes.position;let Ct=Vt.start*Dt,oe=(Vt.start+Vt.count)*Dt;gt!==null&&(Ct=Math.max(Ct,gt.start*Dt),oe=Math.min(oe,(gt.start+gt.count)*Dt)),bt!==null?(Ct=Math.max(Ct,0),oe=Math.min(oe,bt.count)):Yt!=null&&(Ct=Math.max(Ct,0),oe=Math.min(oe,Yt.count));const Le=oe-Ct;if(Le<0||Le===1/0)return;vt.setup(W,G,mt,q,bt);let Ce,he=ot;if(bt!==null&&(Ce=lt.get(bt),he=j,he.setIndex(Ce)),W.isMesh)G.wireframe===!0?(x.setLineWidth(G.wireframeLinewidth*Be()),he.setMode(N.LINES)):he.setMode(N.TRIANGLES);else if(W.isLine){let nn=G.linewidth;nn===void 0&&(nn=1),x.setLineWidth(nn*Be()),W.isLineSegments?he.setMode(N.LINES):W.isLineLoop?he.setMode(N.LINE_LOOP):he.setMode(N.LINE_STRIP)}else W.isPoints?he.setMode(N.POINTS):W.isSprite&&he.setMode(N.TRIANGLES);if(W.isBatchedMesh)if(ie.get("WEBGL_multi_draw"))he.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const nn=W._multiDrawStarts,Mt=W._multiDrawCounts,An=W._multiDrawCount,Qt=bt?lt.get(bt).bytesPerElement:1,Ln=X.get(G).currentProgram.getUniforms();for(let ri=0;ri<An;ri++)Ln.setValue(N,"_gl_DrawID",ri),he.render(nn[ri]/Qt,Mt[ri])}else if(W.isInstancedMesh)he.renderInstances(Ct,Le,W.count);else if(q.isInstancedBufferGeometry){const nn=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Mt=Math.min(q.instanceCount,nn);he.renderInstances(Ct,Le,Mt)}else he.render(Ct,Le)};function td(y,U,q){y.transparent===!0&&y.side===$n&&y.forceSinglePass===!1?(y.side=ze,y.needsUpdate=!0,ka(y,U,q),y.side=us,y.needsUpdate=!0,ka(y,U,q),y.side=$n):ka(y,U,q)}this.compile=function(y,U,q=null){q===null&&(q=y),w=ut.get(q),w.init(U),M.push(w),q.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),y!==q&&y.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const G=new Set;return y.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const gt=W.material;if(gt)if(Array.isArray(gt))for(let _t=0;_t<gt.length;_t++){const mt=gt[_t];td(mt,q,W),G.add(mt)}else td(gt,q,W),G.add(gt)}),w=M.pop(),G},this.compileAsync=function(y,U,q=null){const G=this.compile(y,U,q);return new Promise(W=>{function gt(){if(G.forEach(function(_t){X.get(_t).currentProgram.isReady()&&G.delete(_t)}),G.size===0){W(y);return}setTimeout(gt,10)}ie.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Nc=null;function tg(y){Nc&&Nc(y)}function ed(){ps.stop()}function nd(){ps.start()}const ps=new sm;ps.setAnimationLoop(tg),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(y){Nc=y,yt.setAnimationLoop(y),y===null?ps.stop():ps.start()},yt.addEventListener("sessionstart",ed),yt.addEventListener("sessionend",nd),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){zt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(y,U);const q=yt.enabled===!0&&yt.isPresenting===!0,G=A!==null&&(Y===null||q)&&A.begin(P,Y);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(U),U=yt.getCamera()),y.isScene===!0&&y.onBeforeRender(P,y,U,Y),w=ut.get(y,M.length),w.init(U),w.state.textureUnits=$.getTextureUnits(),M.push(w),ee.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Nt.setFromProjectionMatrix(ee,gi,U.reversedDepth),Ut=this.localClippingEnabled,Ot=Lt.init(this.clippingPlanes,Ut),b=ft.get(y,R.length),b.init(),R.push(b),yt.enabled===!0&&yt.isPresenting===!0){const _t=P.xr.getDepthSensingMesh();_t!==null&&Oc(_t,U,-1/0,P.sortObjects)}Oc(y,U,0,P.sortObjects),b.finish(),P.sortObjects===!0&&b.sort(B,Et,U.reversedDepth),Re=yt.enabled===!1||yt.isPresenting===!1||yt.hasDepthSensing()===!1,Re&&Gt.addToRenderList(b,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ot===!0&&Lt.beginShadows();const W=w.state.shadowsArray;if(Ft.render(W,y,U),Ot===!0&&Lt.endShadows(),(G&&A.hasRenderPass())===!1){const _t=b.opaque,mt=b.transmissive;if(w.setupLights(),U.isArrayCamera){const bt=U.cameras;if(mt.length>0)for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt];sd(_t,mt,y,Yt)}Re&&Gt.render(y);for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt];id(b,y,Yt,Yt.viewport)}}else mt.length>0&&sd(_t,mt,y,U),Re&&Gt.render(y),id(b,y,U)}Y!==null&&k===0&&($.updateMultisampleRenderTarget(Y),$.updateRenderTargetMipmap(Y)),G&&A.end(P),y.isScene===!0&&y.onAfterRender(P,y,U),vt.resetDefaultState(),tt=-1,J=null,M.pop(),M.length>0?(w=M[M.length-1],$.setTextureUnits(w.state.textureUnits),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?b=R[R.length-1]:b=null,I!==null&&I.renderEnd()};function Oc(y,U,q,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)q=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Nt.intersectsSprite(y)){G&&Te.setFromMatrixPosition(y.matrixWorld).applyMatrix4(ee);const _t=Q.update(y),mt=y.material;mt.visible&&b.push(y,_t,mt,q,Te.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Nt.intersectsObject(y))){const _t=Q.update(y),mt=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Te.copy(y.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),Te.copy(_t.boundingSphere.center)),Te.applyMatrix4(y.matrixWorld).applyMatrix4(ee)),Array.isArray(mt)){const bt=_t.groups;for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt],Ct=mt[Yt.materialIndex];Ct&&Ct.visible&&b.push(y,_t,Ct,q,Te.z,Yt)}}else mt.visible&&b.push(y,_t,mt,q,Te.z,null)}}const gt=y.children;for(let _t=0,mt=gt.length;_t<mt;_t++)Oc(gt[_t],U,q,G)}function id(y,U,q,G){const{opaque:W,transmissive:gt,transparent:_t}=y;w.setupLightsView(q),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,q),G&&x.viewport(nt.copy(G)),W.length>0&&za(W,U,q),gt.length>0&&za(gt,U,q),_t.length>0&&za(_t,U,q),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function sd(y,U,q,G){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[G.id]===void 0){const Ct=ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[G.id]=new wn(1,1,{generateMipmaps:!0,type:Ct?cn:In,minFilter:Ds,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:jt.workingColorSpace})}const gt=w.state.transmissionRenderTarget[G.id],_t=G.viewport||nt;gt.setSize(_t.z*P.transmissionResolutionScale,_t.w*P.transmissionResolutionScale);const mt=P.getRenderTarget(),bt=P.getActiveCubeFace(),Dt=P.getActiveMipmapLevel();P.setRenderTarget(gt),P.getClearColor($t),Bt=P.getClearAlpha(),Bt<1&&P.setClearColor(16777215,.5),P.clear(),Re&&Gt.render(q);const Vt=P.toneMapping;P.toneMapping=xi;const Yt=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),w.setupLightsView(G),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,G),za(y,q,G),$.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt),ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let oe=0,Le=U.length;oe<Le;oe++){const Ce=U[oe],{object:he,geometry:nn,material:Mt,group:An}=Ce;if(Mt.side===$n&&he.layers.test(G.layers)){const Qt=Mt.side;Mt.side=ze,Mt.needsUpdate=!0,rd(he,q,G,nn,Mt,An),Mt.side=Qt,Mt.needsUpdate=!0,Ct=!0}}Ct===!0&&($.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt))}P.setRenderTarget(mt,bt,Dt),P.setClearColor($t,Bt),Yt!==void 0&&(G.viewport=Yt),P.toneMapping=Vt}function za(y,U,q){const G=U.isScene===!0?U.overrideMaterial:null;for(let W=0,gt=y.length;W<gt;W++){const _t=y[W],{object:mt,geometry:bt,group:Dt}=_t;let Vt=_t.material;Vt.allowOverride===!0&&G!==null&&(Vt=G),mt.layers.test(q.layers)&&rd(mt,U,q,bt,Vt,Dt)}}function rd(y,U,q,G,W,gt){y.onBeforeRender(P,U,q,G,W,gt),y.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),W.onBeforeRender(P,U,q,G,y,gt),W.transparent===!0&&W.side===$n&&W.forceSinglePass===!1?(W.side=ze,W.needsUpdate=!0,P.renderBufferDirect(q,U,G,W,y,gt),W.side=us,W.needsUpdate=!0,P.renderBufferDirect(q,U,G,W,y,gt),W.side=$n):P.renderBufferDirect(q,U,G,W,y,gt),y.onAfterRender(P,U,q,G,W,gt)}function ka(y,U,q){U.isScene!==!0&&(U=ve);const G=X.get(y),W=w.state.lights,gt=w.state.shadowsArray,_t=W.state.version,mt=ht.getParameters(y,W.state,gt,U,q,w.state.lightProbeGridArray),bt=ht.getProgramCacheKey(mt);let Dt=G.programs;G.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;const Vt=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;G.envMap=st.get(y.envMap||G.environment,Vt),G.envMapRotation=G.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Dt===void 0&&(y.addEventListener("dispose",si),Dt=new Map,G.programs=Dt);let Yt=Dt.get(bt);if(Yt!==void 0){if(G.currentProgram===Yt&&G.lightsStateVersion===_t)return od(y,mt),Yt}else mt.uniforms=ht.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,q,mt),y.onBeforeCompile(mt,P),Yt=ht.acquireProgram(mt,bt),Dt.set(bt,Yt),G.uniforms=mt.uniforms;const Ct=G.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ct.clippingPlanes=Lt.uniform),od(y,mt),G.needsLights=sg(y),G.lightsStateVersion=_t,G.needsLights&&(Ct.ambientLightColor.value=W.state.ambient,Ct.lightProbe.value=W.state.probe,Ct.directionalLights.value=W.state.directional,Ct.directionalLightShadows.value=W.state.directionalShadow,Ct.spotLights.value=W.state.spot,Ct.spotLightShadows.value=W.state.spotShadow,Ct.rectAreaLights.value=W.state.rectArea,Ct.ltc_1.value=W.state.rectAreaLTC1,Ct.ltc_2.value=W.state.rectAreaLTC2,Ct.pointLights.value=W.state.point,Ct.pointLightShadows.value=W.state.pointShadow,Ct.hemisphereLights.value=W.state.hemi,Ct.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Ct.spotLightMatrix.value=W.state.spotLightMatrix,Ct.spotLightMap.value=W.state.spotLightMap,Ct.pointShadowMatrix.value=W.state.pointShadowMatrix),G.lightProbeGrid=w.state.lightProbeGridArray.length>0,G.currentProgram=Yt,G.uniformsList=null,Yt}function ad(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=$o.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function od(y,U){const q=X.get(y);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 eg(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,G=y.length;q<G;q++){const W=y[q];if(W.texture!==null&&W.boundingBox.containsPoint(_))return W}return null}function ng(y,U,q,G,W){U.isScene!==!0&&(U=ve),$.resetTextureUnits();const gt=U.fog,_t=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,mt=Y===null?P.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:jt.workingColorSpace,bt=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Dt=st.get(G.envMap||_t,bt),Vt=G.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Yt=!!q.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ct=!!q.morphAttributes.position,oe=!!q.morphAttributes.normal,Le=!!q.morphAttributes.color;let Ce=xi;G.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Ce=P.toneMapping);const he=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,nn=he!==void 0?he.length:0,Mt=X.get(G),An=w.state.lights;if(Ot===!0&&(Ut===!0||y!==J)){const pe=y===J&&G.id===tt;Lt.setState(G,y,pe)}let Qt=!1;G.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==An.state.version||Mt.outputColorSpace!==mt||W.isBatchedMesh&&Mt.batching===!1||!W.isBatchedMesh&&Mt.batching===!0||W.isBatchedMesh&&Mt.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&Mt.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&Mt.instancing===!1||!W.isInstancedMesh&&Mt.instancing===!0||W.isSkinnedMesh&&Mt.skinning===!1||!W.isSkinnedMesh&&Mt.skinning===!0||W.isInstancedMesh&&Mt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Mt.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&Mt.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&Mt.instancingMorph===!1&&W.morphTexture!==null||Mt.envMap!==Dt||G.fog===!0&&Mt.fog!==gt||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==Lt.numPlanes||Mt.numIntersection!==Lt.numIntersection)||Mt.vertexAlphas!==Vt||Mt.vertexTangents!==Yt||Mt.morphTargets!==Ct||Mt.morphNormals!==oe||Mt.morphColors!==Le||Mt.toneMapping!==Ce||Mt.morphTargetsCount!==nn||!!Mt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(Qt=!0):(Qt=!0,Mt.__version=G.version);let Ln=Mt.currentProgram;Qt===!0&&(Ln=ka(G,U,W),I&&G.isNodeMaterial&&I.onUpdateProgram(G,Ln,Mt));let ri=!1,Xi=!1,Gs=!1;const ue=Ln.getUniforms(),Ne=Mt.uniforms;if(x.useProgram(Ln.program)&&(ri=!0,Xi=!0,Gs=!0),G.id!==tt&&(tt=G.id,Xi=!0),Mt.needsLights){const pe=eg(w.state.lightProbeGridArray,W);Mt.lightProbeGrid!==pe&&(Mt.lightProbeGrid=pe,Xi=!0)}if(ri||J!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ue.setValue(N,"projectionMatrix",y.projectionMatrix),ue.setValue(N,"viewMatrix",y.matrixWorldInverse);const Yi=ue.map.cameraPosition;Yi!==void 0&&Yi.setValue(N,ne.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ue.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&ue.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),J!==y&&(J=y,Xi=!0,Gs=!0)}if(Mt.needsLights&&(An.state.directionalShadowMap.length>0&&ue.setValue(N,"directionalShadowMap",An.state.directionalShadowMap,$),An.state.spotShadowMap.length>0&&ue.setValue(N,"spotShadowMap",An.state.spotShadowMap,$),An.state.pointShadowMap.length>0&&ue.setValue(N,"pointShadowMap",An.state.pointShadowMap,$)),W.isSkinnedMesh){ue.setOptional(N,W,"bindMatrix"),ue.setOptional(N,W,"bindMatrixInverse");const pe=W.skeleton;pe&&(pe.boneTexture===null&&pe.computeBoneTexture(),ue.setValue(N,"boneTexture",pe.boneTexture,$))}W.isBatchedMesh&&(ue.setOptional(N,W,"batchingTexture"),ue.setValue(N,"batchingTexture",W._matricesTexture,$),ue.setOptional(N,W,"batchingIdTexture"),ue.setValue(N,"batchingIdTexture",W._indirectTexture,$),ue.setOptional(N,W,"batchingColorTexture"),W._colorsTexture!==null&&ue.setValue(N,"batchingColorTexture",W._colorsTexture,$));const qi=q.morphAttributes;if((qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)&&L.update(W,q,Ln),(Xi||Mt.receiveShadow!==W.receiveShadow)&&(Mt.receiveShadow=W.receiveShadow,ue.setValue(N,"receiveShadow",W.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Ne.envMapIntensity.value=U.environmentIntensity),Ne.dfgLUT!==void 0&&(Ne.dfgLUT.value=v3()),Xi){if(ue.setValue(N,"toneMappingExposure",P.toneMappingExposure),Mt.needsLights&&ig(Ne,Gs),gt&&G.fog===!0&&Rt.refreshFogUniforms(Ne,gt),Rt.refreshMaterialUniforms(Ne,G,it,rt,w.state.transmissionRenderTarget[y.id]),Mt.needsLights&&Mt.lightProbeGrid){const pe=Mt.lightProbeGrid;Ne.probesSH.value=pe.texture,Ne.probesMin.value.copy(pe.boundingBox.min),Ne.probesMax.value.copy(pe.boundingBox.max),Ne.probesResolution.value.copy(pe.resolution)}$o.upload(N,ad(Mt),Ne,$)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&($o.upload(N,ad(Mt),Ne,$),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&ue.setValue(N,"center",W.center),ue.setValue(N,"modelViewMatrix",W.modelViewMatrix),ue.setValue(N,"normalMatrix",W.normalMatrix),ue.setValue(N,"modelMatrix",W.matrixWorld),G.uniformsGroups!==void 0){const pe=G.uniformsGroups;for(let Yi=0,Vs=pe.length;Yi<Vs;Yi++){const cd=pe[Yi];et.update(cd,Ln),et.bind(cd,Ln)}}return Ln}function ig(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function sg(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return Y},this.setRenderTargetTextures=function(y,U,q){const G=X.get(y);G.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),X.get(y.texture).__webglTexture=U,X.get(y.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:q,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const q=X.get(y);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,q=0){Y=y,V=U,k=q;let G=null,W=!1,gt=!1;if(y){const mt=X.get(y);if(mt.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,mt.__webglFramebuffer),nt.copy(y.viewport),at.copy(y.scissor),Ht=y.scissorTest,x.viewport(nt),x.scissor(at),x.setScissorTest(Ht),tt=-1;return}else if(mt.__webglFramebuffer===void 0)$.setupRenderTarget(y);else if(mt.__hasExternalTextures)$.rebindTextures(y,X.get(y.texture).__webglTexture,X.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Vt=y.depthTexture;if(mt.__boundDepthTexture!==Vt){if(Vt!==null&&X.has(Vt)&&(y.width!==Vt.image.width||y.height!==Vt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(y)}}const bt=y.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(gt=!0);const Dt=X.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Dt[U])?G=Dt[U][q]:G=Dt[U],W=!0):y.samples>0&&$.useMultisampledRTT(y)===!1?G=X.get(y).__webglMultisampledFramebuffer:Array.isArray(Dt)?G=Dt[q]:G=Dt,nt.copy(y.viewport),at.copy(y.scissor),Ht=y.scissorTest}else nt.copy(It).multiplyScalar(it).floor(),at.copy(Tt).multiplyScalar(it).floor(),Ht=xt;if(q!==0&&(G=F),x.bindFramebuffer(N.FRAMEBUFFER,G)&&x.drawBuffers(y,G),x.viewport(nt),x.scissor(at),x.setScissorTest(Ht),W){const mt=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,mt.__webglTexture,q)}else if(gt){const mt=U;for(let bt=0;bt<y.textures.length;bt++){const Dt=X.get(y.textures[bt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+bt,Dt.__webglTexture,q,mt)}}else if(y!==null&&q!==0){const mt=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,mt.__webglTexture,q)}tt=-1},this.readRenderTargetPixels=function(y,U,q,G,W,gt,_t,mt=0){if(!(y&&y.isWebGLRenderTarget)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt){x.bindFramebuffer(N.FRAMEBUFFER,bt);try{const Dt=y.textures[mt],Vt=Dt.format,Yt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!T.textureFormatReadable(Vt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(Yt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W&&N.readPixels(U,q,G,W,dt.convert(Vt),dt.convert(Yt),gt)}finally{const Dt=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(y,U,q,G,W,gt,_t,mt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt)if(U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W){x.bindFramebuffer(N.FRAMEBUFFER,bt);const Dt=y.textures[mt],Vt=Dt.format,Yt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!T.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(Yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.bufferData(N.PIXEL_PACK_BUFFER,gt.byteLength,N.STREAM_READ),N.readPixels(U,q,G,W,dt.convert(Vt),dt.convert(Yt),0);const oe=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,oe);const Le=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await X1(N,Le,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,gt),N.deleteBuffer(Ct),N.deleteSync(Le),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,q=0){const G=Math.pow(2,-q),W=Math.floor(y.image.width*G),gt=Math.floor(y.image.height*G),_t=U!==null?U.x:0,mt=U!==null?U.y:0;$.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,q,0,0,_t,mt,W,gt),x.unbindTexture()},this.copyTextureToTexture=function(y,U,q=null,G=null,W=0,gt=0){let _t,mt,bt,Dt,Vt,Yt,Ct,oe,Le;const Ce=y.isCompressedTexture?y.mipmaps[gt]:y.image;if(q!==null)_t=q.max.x-q.min.x,mt=q.max.y-q.min.y,bt=q.isBox3?q.max.z-q.min.z:1,Dt=q.min.x,Vt=q.min.y,Yt=q.isBox3?q.min.z:0;else{const Ne=Math.pow(2,-W);_t=Math.floor(Ce.width*Ne),mt=Math.floor(Ce.height*Ne),y.isDataArrayTexture?bt=Ce.depth:y.isData3DTexture?bt=Math.floor(Ce.depth*Ne):bt=1,Dt=0,Vt=0,Yt=0}G!==null?(Ct=G.x,oe=G.y,Le=G.z):(Ct=0,oe=0,Le=0);const he=dt.convert(U.format),nn=dt.convert(U.type);let Mt;U.isData3DTexture?($.setTexture3D(U,0),Mt=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Mt=N.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Mt=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const An=x.getParameter(N.UNPACK_ROW_LENGTH),Qt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Ln=x.getParameter(N.UNPACK_SKIP_PIXELS),ri=x.getParameter(N.UNPACK_SKIP_ROWS),Xi=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Ce.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ce.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Dt),x.pixelStorei(N.UNPACK_SKIP_ROWS,Vt),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Yt);const Gs=y.isDataArrayTexture||y.isData3DTexture,ue=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Ne=X.get(y),qi=X.get(U),pe=X.get(Ne.__renderTarget),Yi=X.get(qi.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,pe.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let Vs=0;Vs<bt;Vs++)Gs&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(y).__webglTexture,W,Yt+Vs),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(U).__webglTexture,gt,Le+Vs)),N.blitFramebuffer(Dt,Vt,_t,mt,Ct,oe,_t,mt,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(W!==0||y.isRenderTargetTexture||X.has(y)){const Ne=X.get(y),qi=X.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,H),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let pe=0;pe<bt;pe++)Gs?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ne.__webglTexture,W,Yt+pe):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ne.__webglTexture,W),ue?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,qi.__webglTexture,gt,Le+pe):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,qi.__webglTexture,gt),W!==0?N.blitFramebuffer(Dt,Vt,_t,mt,Ct,oe,_t,mt,N.COLOR_BUFFER_BIT,N.NEAREST):ue?N.copyTexSubImage3D(Mt,gt,Ct,oe,Le+pe,Dt,Vt,_t,mt):N.copyTexSubImage2D(Mt,gt,Ct,oe,Dt,Vt,_t,mt);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ue?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,nn,Ce.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,Ce.data):N.texSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,nn,Ce):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,gt,Ct,oe,_t,mt,he,nn,Ce.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,gt,Ct,oe,Ce.width,Ce.height,he,Ce.data):N.texSubImage2D(N.TEXTURE_2D,gt,Ct,oe,_t,mt,he,nn,Ce);x.pixelStorei(N.UNPACK_ROW_LENGTH,An),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Qt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Ln),x.pixelStorei(N.UNPACK_SKIP_ROWS,ri),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Xi),gt===0&&U.generateMipmaps&&N.generateMipmap(Mt),x.unbindTexture()},this.initRenderTarget=function(y){X.get(y).__webglFramebuffer===void 0&&$.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?$.setTextureCube(y,0):y.isData3DTexture?$.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?$.setTexture2DArray(y,0):$.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){V=0,k=0,Y=null,x.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return gi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=jt._getDrawingBufferColorSpace(t),e.unpackColorSpace=jt._getUnpackColorSpace()}}const x3=`
4629
+ }`;class u3{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new jp(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new Ae({vertexShader:l3,fragmentShader:h3,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new qt(new Wi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class d3 extends Bs{constructor(t,e){super();const n=this;let i=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",g=new u3,m={},S=e.getContextAttributes();let E=null,_=null;const b=[],w=[],R=new Pt;let M=null;const A=new En;A.viewport=new le;const P=new En;P.viewport=new le;const D=[A,P],I=new f2;let F=null,H=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getGripSpace()},this.getHand=function(K){let rt=b[K];return rt===void 0&&(rt=new Yc,b[K]=rt),rt.getHandSpace()};function O(K){const rt=w.indexOf(K.inputSource);if(rt===-1)return;const it=b[rt];it!==void 0&&(it.update(K.inputSource,K.frame,l||a),it.dispatchEvent({type:K.type,data:K.inputSource}))}function V(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",V),i.removeEventListener("inputsourceschange",k);for(let K=0;K<b.length;K++){const rt=w[K];rt!==null&&(w[K]=null,b[K].disconnect(rt))}F=null,H=null,g.reset();for(const K in m)delete m[K];t.setRenderTarget(E),f=null,d=null,u=null,i=null,_=null,Bt.stop(),n.isPresenting=!1,t.setPixelRatio(M),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(K){r=K,n.isPresenting===!0&&wt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(K){o=K,n.isPresenting===!0&&wt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(K){l=K},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return p},this.getSession=function(){return i},this.setSession=async function(K){if(i=K,i!==null){if(E=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",V),i.addEventListener("inputsourceschange",k),S.xrCompatible!==!0&&await e.makeXRCompatible(),M=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let it=null,B=null,Et=null;S.depth&&(Et=S.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,it=S.stencil?Cs:ki,B=S.stencil?Aa:ei);const It={colorFormat:e.RGBA8,depthFormat:Et,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(It),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),_=new wn(d.textureWidth,d.textureHeight,{format:vn,type:In,depthTexture:new Fs(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,it),stencilBuffer:S.stencil,colorSpace:t.outputColorSpace,samples:S.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const it={antialias:S.antialias,alpha:!0,depth:S.depth,stencil:S.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,e,it),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),_=new wn(f.framebufferWidth,f.framebufferHeight,{format:vn,type:In,colorSpace:t.outputColorSpace,stencilBuffer:S.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}_.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),Bt.setContext(i),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return g.getDepthTexture()};function k(K){for(let rt=0;rt<K.removed.length;rt++){const it=K.removed[rt],B=w.indexOf(it);B>=0&&(w[B]=null,b[B].disconnect(it))}for(let rt=0;rt<K.added.length;rt++){const it=K.added[rt];let B=w.indexOf(it);if(B===-1){for(let It=0;It<b.length;It++)if(It>=w.length){w.push(it),B=It;break}else if(w[It]===null){w[It]=it,B=It;break}if(B===-1)break}const Et=b[B];Et&&Et.connect(it)}}const Y=new C,tt=new C;function J(K,rt,it){Y.setFromMatrixPosition(rt.matrixWorld),tt.setFromMatrixPosition(it.matrixWorld);const B=Y.distanceTo(tt),Et=rt.projectionMatrix.elements,It=it.projectionMatrix.elements,Tt=Et[14]/(Et[10]-1),xt=Et[14]/(Et[10]+1),Nt=(Et[9]+1)/Et[5],Ot=(Et[9]-1)/Et[5],Ut=(Et[8]-1)/Et[0],ee=(It[8]+1)/It[0],ne=Tt*Ut,Te=Tt*ee,ve=B/(-Ut+ee),Re=ve*-Ut;if(rt.matrixWorld.decompose(K.position,K.quaternion,K.scale),K.translateX(Re),K.translateZ(ve),K.matrixWorld.compose(K.position,K.quaternion,K.scale),K.matrixWorldInverse.copy(K.matrixWorld).invert(),Et[10]===-1)K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Be=Tt+ve,N=xt+ve,xn=ne-Re,ie=Te+(B-Re),T=Nt*xt/N*Be,x=Ot*xt/N*Be;K.projectionMatrix.makePerspective(xn,ie,T,x,Be,N),K.projectionMatrixInverse.copy(K.projectionMatrix).invert()}}function nt(K,rt){rt===null?K.matrixWorld.copy(K.matrix):K.matrixWorld.multiplyMatrices(rt.matrixWorld,K.matrix),K.matrixWorldInverse.copy(K.matrixWorld).invert()}this.updateCamera=function(K){if(i===null)return;let rt=K.near,it=K.far;g.texture!==null&&(g.depthNear>0&&(rt=g.depthNear),g.depthFar>0&&(it=g.depthFar)),I.near=P.near=A.near=rt,I.far=P.far=A.far=it,(F!==I.near||H!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),F=I.near,H=I.far),I.layers.mask=K.layers.mask|6,A.layers.mask=I.layers.mask&-5,P.layers.mask=I.layers.mask&-3;const B=K.parent,Et=I.cameras;nt(I,B);for(let It=0;It<Et.length;It++)nt(Et[It],B);Et.length===2?J(I,A,P):I.projectionMatrix.copy(A.projectionMatrix),at(K,I,B)};function at(K,rt,it){it===null?K.matrix.copy(rt.matrixWorld):(K.matrix.copy(it.matrixWorld),K.matrix.invert(),K.matrix.multiply(rt.matrixWorld)),K.matrix.decompose(K.position,K.quaternion,K.scale),K.updateMatrixWorld(!0),K.projectionMatrix.copy(rt.projectionMatrix),K.projectionMatrixInverse.copy(rt.projectionMatrixInverse),K.isPerspectiveCamera&&(K.fov=Lr*2*Math.atan(1/K.projectionMatrix.elements[5]),K.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(K){c=K,d!==null&&(d.fixedFoveation=K),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=K)},this.hasDepthSensing=function(){return g.texture!==null},this.getDepthSensingMesh=function(){return g.getMesh(I)},this.getCameraTexture=function(K){return m[K]};let Ht=null;function $t(K,rt){if(h=rt.getViewerPose(l||a),p=rt,h!==null){const it=h.views;f!==null&&(t.setRenderTargetFramebuffer(_,f.framebuffer),t.setRenderTarget(_));let B=!1;it.length!==I.cameras.length&&(I.cameras.length=0,B=!0);for(let xt=0;xt<it.length;xt++){const Nt=it[xt];let Ot=null;if(f!==null)Ot=f.getViewport(Nt);else{const ee=u.getViewSubImage(d,Nt);Ot=ee.viewport,xt===0&&(t.setRenderTargetTextures(_,ee.colorTexture,ee.depthStencilTexture),t.setRenderTarget(_))}let Ut=D[xt];Ut===void 0&&(Ut=new En,Ut.layers.enable(xt),Ut.viewport=new le,D[xt]=Ut),Ut.matrix.fromArray(Nt.transform.matrix),Ut.matrix.decompose(Ut.position,Ut.quaternion,Ut.scale),Ut.projectionMatrix.fromArray(Nt.projectionMatrix),Ut.projectionMatrixInverse.copy(Ut.projectionMatrix).invert(),Ut.viewport.set(Ot.x,Ot.y,Ot.width,Ot.height),xt===0&&(I.matrix.copy(Ut.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),B===!0&&I.cameras.push(Ut)}const Et=i.enabledFeatures;if(Et&&Et.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const xt=u.getDepthInformation(it[0]);xt&&xt.isValid&&xt.texture&&g.init(xt,i.renderState)}if(Et&&Et.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let xt=0;xt<it.length;xt++){const Nt=it[xt].camera;if(Nt){let Ot=m[Nt];Ot||(Ot=new jp,m[Nt]=Ot);const Ut=u.getCameraImage(Nt);Ot.sourceTexture=Ut}}}}for(let it=0;it<b.length;it++){const B=w[it],Et=b[it];B!==null&&Et!==void 0&&Et.update(B,rt,l||a)}Ht&&Ht(K,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),p=null}const Bt=new sm;Bt.setAnimationLoop($t),this.setAnimationLoop=function(K){Ht=K},this.dispose=function(){}}}const f3=new Wt,um=new kt;um.set(-1,0,0,0,1,0,0,0,1);function p3(s,t){function e(g,m){g.matrixAutoUpdate===!0&&g.updateMatrix(),m.value.copy(g.matrix)}function n(g,m){m.color.getRGB(g.fogColor.value,Qp(s)),m.isFog?(g.fogNear.value=m.near,g.fogFar.value=m.far):m.isFogExp2&&(g.fogDensity.value=m.density)}function i(g,m,S,E,_){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?r(g,m):m.isMeshLambertMaterial?(r(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(r(g,m),u(g,m)):m.isMeshPhongMaterial?(r(g,m),h(g,m),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(r(g,m),d(g,m),m.isMeshPhysicalMaterial&&f(g,m,_)):m.isMeshMatcapMaterial?(r(g,m),p(g,m)):m.isMeshDepthMaterial?r(g,m):m.isMeshDistanceMaterial?(r(g,m),v(g,m)):m.isMeshNormalMaterial?r(g,m):m.isLineBasicMaterial?(a(g,m),m.isLineDashedMaterial&&o(g,m)):m.isPointsMaterial?c(g,m,S,E):m.isSpriteMaterial?l(g,m):m.isShadowMaterial?(g.color.value.copy(m.color),g.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(g,m){g.opacity.value=m.opacity,m.color&&g.diffuse.value.copy(m.color),m.emissive&&g.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.bumpMap&&(g.bumpMap.value=m.bumpMap,e(m.bumpMap,g.bumpMapTransform),g.bumpScale.value=m.bumpScale,m.side===ze&&(g.bumpScale.value*=-1)),m.normalMap&&(g.normalMap.value=m.normalMap,e(m.normalMap,g.normalMapTransform),g.normalScale.value.copy(m.normalScale),m.side===ze&&g.normalScale.value.negate()),m.displacementMap&&(g.displacementMap.value=m.displacementMap,e(m.displacementMap,g.displacementMapTransform),g.displacementScale.value=m.displacementScale,g.displacementBias.value=m.displacementBias),m.emissiveMap&&(g.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,g.emissiveMapTransform)),m.specularMap&&(g.specularMap.value=m.specularMap,e(m.specularMap,g.specularMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest);const S=t.get(m),E=S.envMap,_=S.envMapRotation;E&&(g.envMap.value=E,g.envMapRotation.value.setFromMatrix4(f3.makeRotationFromEuler(_)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&g.envMapRotation.value.premultiply(um),g.reflectivity.value=m.reflectivity,g.ior.value=m.ior,g.refractionRatio.value=m.refractionRatio),m.lightMap&&(g.lightMap.value=m.lightMap,g.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,g.lightMapTransform)),m.aoMap&&(g.aoMap.value=m.aoMap,g.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,g.aoMapTransform))}function a(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform))}function o(g,m){g.dashSize.value=m.dashSize,g.totalSize.value=m.dashSize+m.gapSize,g.scale.value=m.scale}function c(g,m,S,E){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.size.value=m.size*S,g.scale.value=E*.5,m.map&&(g.map.value=m.map,e(m.map,g.uvTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function l(g,m){g.diffuse.value.copy(m.color),g.opacity.value=m.opacity,g.rotation.value=m.rotation,m.map&&(g.map.value=m.map,e(m.map,g.mapTransform)),m.alphaMap&&(g.alphaMap.value=m.alphaMap,e(m.alphaMap,g.alphaMapTransform)),m.alphaTest>0&&(g.alphaTest.value=m.alphaTest)}function h(g,m){g.specular.value.copy(m.specular),g.shininess.value=Math.max(m.shininess,1e-4)}function u(g,m){m.gradientMap&&(g.gradientMap.value=m.gradientMap)}function d(g,m){g.metalness.value=m.metalness,m.metalnessMap&&(g.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,g.metalnessMapTransform)),g.roughness.value=m.roughness,m.roughnessMap&&(g.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,g.roughnessMapTransform)),m.envMap&&(g.envMapIntensity.value=m.envMapIntensity)}function f(g,m,S){g.ior.value=m.ior,m.sheen>0&&(g.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),g.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(g.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,g.sheenColorMapTransform)),m.sheenRoughnessMap&&(g.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,g.sheenRoughnessMapTransform))),m.clearcoat>0&&(g.clearcoat.value=m.clearcoat,g.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(g.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,g.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(g.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,g.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(g.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,g.clearcoatNormalMapTransform),g.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===ze&&g.clearcoatNormalScale.value.negate())),m.dispersion>0&&(g.dispersion.value=m.dispersion),m.iridescence>0&&(g.iridescence.value=m.iridescence,g.iridescenceIOR.value=m.iridescenceIOR,g.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],g.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(g.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,g.iridescenceMapTransform)),m.iridescenceThicknessMap&&(g.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,g.iridescenceThicknessMapTransform))),m.transmission>0&&(g.transmission.value=m.transmission,g.transmissionSamplerMap.value=S.texture,g.transmissionSamplerSize.value.set(S.width,S.height),m.transmissionMap&&(g.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,g.transmissionMapTransform)),g.thickness.value=m.thickness,m.thicknessMap&&(g.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,g.thicknessMapTransform)),g.attenuationDistance.value=m.attenuationDistance,g.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(g.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(g.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,g.anisotropyMapTransform))),g.specularIntensity.value=m.specularIntensity,g.specularColor.value.copy(m.specularColor),m.specularColorMap&&(g.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,g.specularColorMapTransform)),m.specularIntensityMap&&(g.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,g.specularIntensityMapTransform))}function p(g,m){m.matcap&&(g.matcap.value=m.matcap)}function v(g,m){const S=t.get(m).light;g.referencePosition.value.setFromMatrixPosition(S.matrixWorld),g.nearDistance.value=S.shadow.camera.near,g.farDistance.value=S.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function m3(s,t,e,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(_,b){const w=b.program;n.uniformBlockBinding(_,w)}function l(_,b){let w=i[_.id];w===void 0&&(g(_),w=h(_),i[_.id]=w,_.addEventListener("dispose",S));const R=b.program;n.updateUBOMapping(_,R);const M=t.render.frame;r[_.id]!==M&&(d(_),r[_.id]=M)}function h(_){const b=u();_.__bindingPointIndex=b;const w=s.createBuffer(),R=_.__size,M=_.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,M),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,b,w),w}function u(){for(let _=0;_<o;_++)if(a.indexOf(_)===-1)return a.push(_),_;return zt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(_){const b=i[_.id],w=_.uniforms,R=_.__cache;s.bindBuffer(s.UNIFORM_BUFFER,b);for(let M=0,A=w.length;M<A;M++){const P=w[M];if(Array.isArray(P))for(let D=0,I=P.length;D<I;D++)f(P[D],M,D,R);else f(P,M,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(_,b,w,R){if(v(_,b,w,R)===!0){const M=_.__offset,A=_.value;if(Array.isArray(A)){let P=0;for(let D=0;D<A.length;D++){const I=A[D],F=m(I);p(I,_.__data,P),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(P+=F.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,_.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,M,_.__data)}}function p(_,b,w){typeof _=="number"||typeof _=="boolean"?b[0]=_:_.isMatrix3?(b[0]=_.elements[0],b[1]=_.elements[1],b[2]=_.elements[2],b[3]=0,b[4]=_.elements[3],b[5]=_.elements[4],b[6]=_.elements[5],b[7]=0,b[8]=_.elements[6],b[9]=_.elements[7],b[10]=_.elements[8],b[11]=0):ArrayBuffer.isView(_)?b.set(new _.constructor(_.buffer,_.byteOffset,b.length)):_.toArray(b,w)}function v(_,b,w,R){const M=_.value,A=b+"_"+w;if(R[A]===void 0)return typeof M=="number"||typeof M=="boolean"?R[A]=M:ArrayBuffer.isView(M)?R[A]=M.slice():R[A]=M.clone(),!0;{const P=R[A];if(typeof M=="number"||typeof M=="boolean"){if(P!==M)return R[A]=M,!0}else{if(ArrayBuffer.isView(M))return!0;if(P.equals(M)===!1)return P.copy(M),!0}}return!1}function g(_){const b=_.uniforms;let w=0;const R=16;for(let A=0,P=b.length;A<P;A++){const D=Array.isArray(b[A])?b[A]:[b[A]];for(let I=0,F=D.length;I<F;I++){const H=D[I],O=Array.isArray(H.value)?H.value:[H.value];for(let V=0,k=O.length;V<k;V++){const Y=O[V],tt=m(Y),J=w%R,nt=J%tt.boundary,at=J+nt;w+=nt,at!==0&&R-at<tt.storage&&(w+=R-at),H.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),H.__offset=w,w+=tt.storage}}}const M=w%R;return M>0&&(w+=R-M),_.__size=w,_.__cache={},this}function m(_){const b={boundary:0,storage:0};return typeof _=="number"||typeof _=="boolean"?(b.boundary=4,b.storage=4):_.isVector2?(b.boundary=8,b.storage=8):_.isVector3||_.isColor?(b.boundary=16,b.storage=12):_.isVector4?(b.boundary=16,b.storage=16):_.isMatrix3?(b.boundary=48,b.storage=48):_.isMatrix4?(b.boundary=64,b.storage=64):_.isTexture?wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(_)?(b.boundary=16,b.storage=_.byteLength):wt("WebGLRenderer: Unsupported uniform value type.",_),b}function S(_){const b=_.target;b.removeEventListener("dispose",S);const w=a.indexOf(b.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[b.id]),delete i[b.id],delete r[b.id]}function E(){for(const _ in i)s.deleteBuffer(i[_]);a=[],i={},r={}}return{bind:c,update:l,dispose:E}}const g3=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 ci=null;function v3(){return ci===null&&(ci=new Ur(g3,16,16,Us,cn),ci.name="DFG_LUT",ci.minFilter=ye,ci.magFilter=ye,ci.wrapS=gn,ci.wrapT=gn,ci.generateMipmaps=!1,ci.needsUpdate=!0),ci}class M3{constructor(t={}){const{canvas:e=W1(),context:n=null,depth:i=!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=In}=t;this.isWebGLRenderer=!0;let p;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=n.getContextAttributes().alpha}else p=a;const v=f,g=new Set([Lu,Iu,Pu]),m=new Set([In,ei,wa,Aa,Du,Cu]),S=new Uint32Array(4),E=new Int32Array(4),_=new C;let b=null,w=null;const R=[],M=[];let A=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=_i,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const P=this;let D=!1,I=null,F=null,H=null,O=null;this._outputColorSpace=Pn;let V=0,k=0,Y=null,tt=-1,J=null;const nt=new le,at=new le;let Ht=null;const $t=new ct(0);let Bt=0,K=e.width,rt=e.height,it=1,B=null,Et=null;const It=new le(0,0,K,rt),Tt=new le(0,0,K,rt);let xt=!1;const Nt=new Bu;let Ot=!1,Ut=!1;const ee=new Wt,ne=new C,Te=new le,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Re=!1;function Be(){return Y===null?it:1}let N=n;function xn(y,U){return e.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Au}`),e.addEventListener("webglcontextlost",De,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",si,!1),N===null){const U="webgl2";if(N=xn(U,y),N===null)throw xn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw zt("WebGLRenderer: "+y.message),y}let ie,T,x,z,X,$,st,lt,Z,Q,ht,Rt,ft,ut,Lt,Ft,Gt,L,ot,j,dt,vt,et;function At(){ie=new v_(N),ie.init(),dt=new c3(N,ie),T=new l_(N,ie,t,dt),x=new a3(N,ie),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),F=N.createFramebuffer(),H=N.createFramebuffer(),O=N.createFramebuffer(),z=new __(N),X=new qy,$=new o3(N,ie,x,X,T,dt,z),st=new g_(P),lt=new E2(N),vt=new o_(N,lt),Z=new M_(N,lt,z,vt),Q=new S_(N,Z,lt,vt,z),L=new y_(N,T,$),Lt=new h_(X),ht=new Xy(P,st,ie,T,vt,Lt),Rt=new p3(P,X),ft=new Ky,ut=new t3(ie),Gt=new a_(P,st,x,Q,p,c),Ft=new r3(P,Q,T),et=new m3(N,z,T,x),ot=new c_(N,ie,z),j=new x_(N,ie,z),z.programs=ht.programs,P.capabilities=T,P.extensions=ie,P.properties=X,P.renderLists=ft,P.shadowMap=Ft,P.state=x,P.info=z}At(),v!==In&&(A=new E_(v,e.width,e.height,o,i,r));const yt=new d3(P,N);this.xr=yt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ie.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ie.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return it},this.setPixelRatio=function(y){y!==void 0&&(it=y,this.setSize(K,rt,!1))},this.getSize=function(y){return y.set(K,rt)},this.setSize=function(y,U,q=!0){if(yt.isPresenting){wt("WebGLRenderer: Can't change size while VR device is presenting.");return}K=y,rt=U,e.width=Math.floor(y*it),e.height=Math.floor(U*it),q===!0&&(e.style.width=y+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(K*it,rt*it).floor()},this.setDrawingBufferSize=function(y,U,q){K=y,rt=U,it=q,e.width=Math.floor(y*q),e.height=Math.floor(U*q),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===In){zt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){wt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(nt)},this.getViewport=function(y){return y.copy(It)},this.setViewport=function(y,U,q,G){y.isVector4?It.set(y.x,y.y,y.z,y.w):It.set(y,U,q,G),x.viewport(nt.copy(It).multiplyScalar(it).round())},this.getScissor=function(y){return y.copy(Tt)},this.setScissor=function(y,U,q,G){y.isVector4?Tt.set(y.x,y.y,y.z,y.w):Tt.set(y,U,q,G),x.scissor(at.copy(Tt).multiplyScalar(it).round())},this.getScissorTest=function(){return xt},this.setScissorTest=function(y){x.setScissorTest(xt=y)},this.setOpaqueSort=function(y){B=y},this.setTransparentSort=function(y){Et=y},this.getClearColor=function(y){return y.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,q=!0){let G=0;if(y){let W=!1;if(Y!==null){const gt=Y.texture.format;W=g.has(gt)}if(W){const gt=Y.texture.type,_t=m.has(gt),mt=Gt.getClearColor(),bt=Gt.getClearAlpha(),Dt=mt.r,Vt=mt.g,Yt=mt.b;_t?(S[0]=Dt,S[1]=Vt,S[2]=Yt,S[3]=bt,N.clearBufferuiv(N.COLOR,0,S)):(E[0]=Dt,E[1]=Vt,E[2]=Yt,E[3]=bt,N.clearBufferiv(N.COLOR,0,E))}else G|=N.COLOR_BUFFER_BIT}U&&(G|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(G|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),G!==0&&N.clear(G)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){e.removeEventListener("webglcontextlost",De,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",si,!1),Gt.dispose(),ft.dispose(),ut.dispose(),X.dispose(),st.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),yt.dispose(),yt.removeEventListener("sessionstart",ed),yt.removeEventListener("sessionend",nd),ps.stop()};function De(y){y.preventDefault(),cc("WebGLRenderer: Context Lost."),D=!0}function fe(){cc("WebGLRenderer: Context Restored."),D=!1;const y=z.autoReset,U=Ft.enabled,q=Ft.autoUpdate,G=Ft.needsUpdate,W=Ft.type;At(),z.autoReset=y,Ft.enabled=U,Ft.autoUpdate=q,Ft.needsUpdate=G,Ft.type=W}function si(y){zt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function ri(y){const U=y.target;U.removeEventListener("dispose",ri),jm(U)}function jm(y){Qm(y),X.remove(y)}function Qm(y){const U=X.get(y).programs;U!==void 0&&(U.forEach(function(q){ht.releaseProgram(q)}),y.isShaderMaterial&&ht.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,q,G,W,gt){U===null&&(U=ve);const _t=W.isMesh&&W.matrixWorld.determinantAffine()<0,mt=ng(y,U,q,G,W);x.setMaterial(G,_t);let bt=q.index,Dt=1;if(G.wireframe===!0){if(bt=Z.getWireframeAttribute(q),bt===void 0)return;Dt=2}const Vt=q.drawRange,Yt=q.attributes.position;let Ct=Vt.start*Dt,oe=(Vt.start+Vt.count)*Dt;gt!==null&&(Ct=Math.max(Ct,gt.start*Dt),oe=Math.min(oe,(gt.start+gt.count)*Dt)),bt!==null?(Ct=Math.max(Ct,0),oe=Math.min(oe,bt.count)):Yt!=null&&(Ct=Math.max(Ct,0),oe=Math.min(oe,Yt.count));const Le=oe-Ct;if(Le<0||Le===1/0)return;vt.setup(W,G,mt,q,bt);let Ce,he=ot;if(bt!==null&&(Ce=lt.get(bt),he=j,he.setIndex(Ce)),W.isMesh)G.wireframe===!0?(x.setLineWidth(G.wireframeLinewidth*Be()),he.setMode(N.LINES)):he.setMode(N.TRIANGLES);else if(W.isLine){let nn=G.linewidth;nn===void 0&&(nn=1),x.setLineWidth(nn*Be()),W.isLineSegments?he.setMode(N.LINES):W.isLineLoop?he.setMode(N.LINE_LOOP):he.setMode(N.LINE_STRIP)}else W.isPoints?he.setMode(N.POINTS):W.isSprite&&he.setMode(N.TRIANGLES);if(W.isBatchedMesh)if(ie.get("WEBGL_multi_draw"))he.renderMultiDraw(W._multiDrawStarts,W._multiDrawCounts,W._multiDrawCount);else{const nn=W._multiDrawStarts,Mt=W._multiDrawCounts,An=W._multiDrawCount,Qt=bt?lt.get(bt).bytesPerElement:1,Ln=X.get(G).currentProgram.getUniforms();for(let ai=0;ai<An;ai++)Ln.setValue(N,"_gl_DrawID",ai),he.render(nn[ai]/Qt,Mt[ai])}else if(W.isInstancedMesh)he.renderInstances(Ct,Le,W.count);else if(q.isInstancedBufferGeometry){const nn=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,Mt=Math.min(q.instanceCount,nn);he.renderInstances(Ct,Le,Mt)}else he.render(Ct,Le)};function td(y,U,q){y.transparent===!0&&y.side===Zn&&y.forceSinglePass===!1?(y.side=ze,y.needsUpdate=!0,ka(y,U,q),y.side=us,y.needsUpdate=!0,ka(y,U,q),y.side=Zn):ka(y,U,q)}this.compile=function(y,U,q=null){q===null&&(q=y),w=ut.get(q),w.init(U),M.push(w),q.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),y!==q&&y.traverseVisible(function(W){W.isLight&&W.layers.test(U.layers)&&(w.pushLight(W),W.castShadow&&w.pushShadow(W))}),w.setupLights();const G=new Set;return y.traverse(function(W){if(!(W.isMesh||W.isPoints||W.isLine||W.isSprite))return;const gt=W.material;if(gt)if(Array.isArray(gt))for(let _t=0;_t<gt.length;_t++){const mt=gt[_t];td(mt,q,W),G.add(mt)}else td(gt,q,W),G.add(gt)}),w=M.pop(),G},this.compileAsync=function(y,U,q=null){const G=this.compile(y,U,q);return new Promise(W=>{function gt(){if(G.forEach(function(_t){X.get(_t).currentProgram.isReady()&&G.delete(_t)}),G.size===0){W(y);return}setTimeout(gt,10)}ie.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Nc=null;function tg(y){Nc&&Nc(y)}function ed(){ps.stop()}function nd(){ps.start()}const ps=new sm;ps.setAnimationLoop(tg),typeof self<"u"&&ps.setContext(self),this.setAnimationLoop=function(y){Nc=y,yt.setAnimationLoop(y),y===null?ps.stop():ps.start()},yt.addEventListener("sessionstart",ed),yt.addEventListener("sessionend",nd),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){zt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(y,U);const q=yt.enabled===!0&&yt.isPresenting===!0,G=A!==null&&(Y===null||q)&&A.begin(P,Y);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(U),U=yt.getCamera()),y.isScene===!0&&y.onBeforeRender(P,y,U,Y),w=ut.get(y,M.length),w.init(U),w.state.textureUnits=$.getTextureUnits(),M.push(w),ee.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Nt.setFromProjectionMatrix(ee,vi,U.reversedDepth),Ut=this.localClippingEnabled,Ot=Lt.init(this.clippingPlanes,Ut),b=ft.get(y,R.length),b.init(),R.push(b),yt.enabled===!0&&yt.isPresenting===!0){const _t=P.xr.getDepthSensingMesh();_t!==null&&Oc(_t,U,-1/0,P.sortObjects)}Oc(y,U,0,P.sortObjects),b.finish(),P.sortObjects===!0&&b.sort(B,Et,U.reversedDepth),Re=yt.enabled===!1||yt.isPresenting===!1||yt.hasDepthSensing()===!1,Re&&Gt.addToRenderList(b,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ot===!0&&Lt.beginShadows();const W=w.state.shadowsArray;if(Ft.render(W,y,U),Ot===!0&&Lt.endShadows(),(G&&A.hasRenderPass())===!1){const _t=b.opaque,mt=b.transmissive;if(w.setupLights(),U.isArrayCamera){const bt=U.cameras;if(mt.length>0)for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt];sd(_t,mt,y,Yt)}Re&&Gt.render(y);for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt];id(b,y,Yt,Yt.viewport)}}else mt.length>0&&sd(_t,mt,y,U),Re&&Gt.render(y),id(b,y,U)}Y!==null&&k===0&&($.updateMultisampleRenderTarget(Y),$.updateRenderTargetMipmap(Y)),G&&A.end(P),y.isScene===!0&&y.onAfterRender(P,y,U),vt.resetDefaultState(),tt=-1,J=null,M.pop(),M.length>0?(w=M[M.length-1],$.setTextureUnits(w.state.textureUnits),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?b=R[R.length-1]:b=null,I!==null&&I.renderEnd()};function Oc(y,U,q,G){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)q=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Nt.intersectsSprite(y)){G&&Te.setFromMatrixPosition(y.matrixWorld).applyMatrix4(ee);const _t=Q.update(y),mt=y.material;mt.visible&&b.push(y,_t,mt,q,Te.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Nt.intersectsObject(y))){const _t=Q.update(y),mt=y.material;if(G&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Te.copy(y.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),Te.copy(_t.boundingSphere.center)),Te.applyMatrix4(y.matrixWorld).applyMatrix4(ee)),Array.isArray(mt)){const bt=_t.groups;for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const Yt=bt[Dt],Ct=mt[Yt.materialIndex];Ct&&Ct.visible&&b.push(y,_t,Ct,q,Te.z,Yt)}}else mt.visible&&b.push(y,_t,mt,q,Te.z,null)}}const gt=y.children;for(let _t=0,mt=gt.length;_t<mt;_t++)Oc(gt[_t],U,q,G)}function id(y,U,q,G){const{opaque:W,transmissive:gt,transparent:_t}=y;w.setupLightsView(q),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,q),G&&x.viewport(nt.copy(G)),W.length>0&&za(W,U,q),gt.length>0&&za(gt,U,q),_t.length>0&&za(_t,U,q),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function sd(y,U,q,G){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[G.id]===void 0){const Ct=ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[G.id]=new wn(1,1,{generateMipmaps:!0,type:Ct?cn:In,minFilter:Ds,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:jt.workingColorSpace})}const gt=w.state.transmissionRenderTarget[G.id],_t=G.viewport||nt;gt.setSize(_t.z*P.transmissionResolutionScale,_t.w*P.transmissionResolutionScale);const mt=P.getRenderTarget(),bt=P.getActiveCubeFace(),Dt=P.getActiveMipmapLevel();P.setRenderTarget(gt),P.getClearColor($t),Bt=P.getClearAlpha(),Bt<1&&P.setClearColor(16777215,.5),P.clear(),Re&&Gt.render(q);const Vt=P.toneMapping;P.toneMapping=_i;const Yt=G.viewport;if(G.viewport!==void 0&&(G.viewport=void 0),w.setupLightsView(G),Ot===!0&&Lt.setGlobalState(P.clippingPlanes,G),za(y,q,G),$.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt),ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let oe=0,Le=U.length;oe<Le;oe++){const Ce=U[oe],{object:he,geometry:nn,material:Mt,group:An}=Ce;if(Mt.side===Zn&&he.layers.test(G.layers)){const Qt=Mt.side;Mt.side=ze,Mt.needsUpdate=!0,rd(he,q,G,nn,Mt,An),Mt.side=Qt,Mt.needsUpdate=!0,Ct=!0}}Ct===!0&&($.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt))}P.setRenderTarget(mt,bt,Dt),P.setClearColor($t,Bt),Yt!==void 0&&(G.viewport=Yt),P.toneMapping=Vt}function za(y,U,q){const G=U.isScene===!0?U.overrideMaterial:null;for(let W=0,gt=y.length;W<gt;W++){const _t=y[W],{object:mt,geometry:bt,group:Dt}=_t;let Vt=_t.material;Vt.allowOverride===!0&&G!==null&&(Vt=G),mt.layers.test(q.layers)&&rd(mt,U,q,bt,Vt,Dt)}}function rd(y,U,q,G,W,gt){y.onBeforeRender(P,U,q,G,W,gt),y.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),W.onBeforeRender(P,U,q,G,y,gt),W.transparent===!0&&W.side===Zn&&W.forceSinglePass===!1?(W.side=ze,W.needsUpdate=!0,P.renderBufferDirect(q,U,G,W,y,gt),W.side=us,W.needsUpdate=!0,P.renderBufferDirect(q,U,G,W,y,gt),W.side=Zn):P.renderBufferDirect(q,U,G,W,y,gt),y.onAfterRender(P,U,q,G,W,gt)}function ka(y,U,q){U.isScene!==!0&&(U=ve);const G=X.get(y),W=w.state.lights,gt=w.state.shadowsArray,_t=W.state.version,mt=ht.getParameters(y,W.state,gt,U,q,w.state.lightProbeGridArray),bt=ht.getProgramCacheKey(mt);let Dt=G.programs;G.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,G.fog=U.fog;const Vt=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;G.envMap=st.get(y.envMap||G.environment,Vt),G.envMapRotation=G.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Dt===void 0&&(y.addEventListener("dispose",ri),Dt=new Map,G.programs=Dt);let Yt=Dt.get(bt);if(Yt!==void 0){if(G.currentProgram===Yt&&G.lightsStateVersion===_t)return od(y,mt),Yt}else mt.uniforms=ht.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,q,mt),y.onBeforeCompile(mt,P),Yt=ht.acquireProgram(mt,bt),Dt.set(bt,Yt),G.uniforms=mt.uniforms;const Ct=G.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ct.clippingPlanes=Lt.uniform),od(y,mt),G.needsLights=sg(y),G.lightsStateVersion=_t,G.needsLights&&(Ct.ambientLightColor.value=W.state.ambient,Ct.lightProbe.value=W.state.probe,Ct.directionalLights.value=W.state.directional,Ct.directionalLightShadows.value=W.state.directionalShadow,Ct.spotLights.value=W.state.spot,Ct.spotLightShadows.value=W.state.spotShadow,Ct.rectAreaLights.value=W.state.rectArea,Ct.ltc_1.value=W.state.rectAreaLTC1,Ct.ltc_2.value=W.state.rectAreaLTC2,Ct.pointLights.value=W.state.point,Ct.pointLightShadows.value=W.state.pointShadow,Ct.hemisphereLights.value=W.state.hemi,Ct.directionalShadowMatrix.value=W.state.directionalShadowMatrix,Ct.spotLightMatrix.value=W.state.spotLightMatrix,Ct.spotLightMap.value=W.state.spotLightMap,Ct.pointShadowMatrix.value=W.state.pointShadowMatrix),G.lightProbeGrid=w.state.lightProbeGridArray.length>0,G.currentProgram=Yt,G.uniformsList=null,Yt}function ad(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=$o.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function od(y,U){const q=X.get(y);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 eg(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;_.setFromMatrixPosition(U.matrixWorld);for(let q=0,G=y.length;q<G;q++){const W=y[q];if(W.texture!==null&&W.boundingBox.containsPoint(_))return W}return null}function ng(y,U,q,G,W){U.isScene!==!0&&(U=ve),$.resetTextureUnits();const gt=U.fog,_t=G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial?U.environment:null,mt=Y===null?P.outputColorSpace:Y.isXRRenderTarget===!0?Y.texture.colorSpace:jt.workingColorSpace,bt=G.isMeshStandardMaterial||G.isMeshLambertMaterial&&!G.envMap||G.isMeshPhongMaterial&&!G.envMap,Dt=st.get(G.envMap||_t,bt),Vt=G.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Yt=!!q.attributes.tangent&&(!!G.normalMap||G.anisotropy>0),Ct=!!q.morphAttributes.position,oe=!!q.morphAttributes.normal,Le=!!q.morphAttributes.color;let Ce=_i;G.toneMapped&&(Y===null||Y.isXRRenderTarget===!0)&&(Ce=P.toneMapping);const he=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,nn=he!==void 0?he.length:0,Mt=X.get(G),An=w.state.lights;if(Ot===!0&&(Ut===!0||y!==J)){const pe=y===J&&G.id===tt;Lt.setState(G,y,pe)}let Qt=!1;G.version===Mt.__version?(Mt.needsLights&&Mt.lightsStateVersion!==An.state.version||Mt.outputColorSpace!==mt||W.isBatchedMesh&&Mt.batching===!1||!W.isBatchedMesh&&Mt.batching===!0||W.isBatchedMesh&&Mt.batchingColor===!0&&W.colorTexture===null||W.isBatchedMesh&&Mt.batchingColor===!1&&W.colorTexture!==null||W.isInstancedMesh&&Mt.instancing===!1||!W.isInstancedMesh&&Mt.instancing===!0||W.isSkinnedMesh&&Mt.skinning===!1||!W.isSkinnedMesh&&Mt.skinning===!0||W.isInstancedMesh&&Mt.instancingColor===!0&&W.instanceColor===null||W.isInstancedMesh&&Mt.instancingColor===!1&&W.instanceColor!==null||W.isInstancedMesh&&Mt.instancingMorph===!0&&W.morphTexture===null||W.isInstancedMesh&&Mt.instancingMorph===!1&&W.morphTexture!==null||Mt.envMap!==Dt||G.fog===!0&&Mt.fog!==gt||Mt.numClippingPlanes!==void 0&&(Mt.numClippingPlanes!==Lt.numPlanes||Mt.numIntersection!==Lt.numIntersection)||Mt.vertexAlphas!==Vt||Mt.vertexTangents!==Yt||Mt.morphTargets!==Ct||Mt.morphNormals!==oe||Mt.morphColors!==Le||Mt.toneMapping!==Ce||Mt.morphTargetsCount!==nn||!!Mt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(Qt=!0):(Qt=!0,Mt.__version=G.version);let Ln=Mt.currentProgram;Qt===!0&&(Ln=ka(G,U,W),I&&G.isNodeMaterial&&I.onUpdateProgram(G,Ln,Mt));let ai=!1,Xi=!1,Gs=!1;const ue=Ln.getUniforms(),Ne=Mt.uniforms;if(x.useProgram(Ln.program)&&(ai=!0,Xi=!0,Gs=!0),G.id!==tt&&(tt=G.id,Xi=!0),Mt.needsLights){const pe=eg(w.state.lightProbeGridArray,W);Mt.lightProbeGrid!==pe&&(Mt.lightProbeGrid=pe,Xi=!0)}if(ai||J!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ue.setValue(N,"projectionMatrix",y.projectionMatrix),ue.setValue(N,"viewMatrix",y.matrixWorldInverse);const Yi=ue.map.cameraPosition;Yi!==void 0&&Yi.setValue(N,ne.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ue.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(G.isMeshPhongMaterial||G.isMeshToonMaterial||G.isMeshLambertMaterial||G.isMeshBasicMaterial||G.isMeshStandardMaterial||G.isShaderMaterial)&&ue.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),J!==y&&(J=y,Xi=!0,Gs=!0)}if(Mt.needsLights&&(An.state.directionalShadowMap.length>0&&ue.setValue(N,"directionalShadowMap",An.state.directionalShadowMap,$),An.state.spotShadowMap.length>0&&ue.setValue(N,"spotShadowMap",An.state.spotShadowMap,$),An.state.pointShadowMap.length>0&&ue.setValue(N,"pointShadowMap",An.state.pointShadowMap,$)),W.isSkinnedMesh){ue.setOptional(N,W,"bindMatrix"),ue.setOptional(N,W,"bindMatrixInverse");const pe=W.skeleton;pe&&(pe.boneTexture===null&&pe.computeBoneTexture(),ue.setValue(N,"boneTexture",pe.boneTexture,$))}W.isBatchedMesh&&(ue.setOptional(N,W,"batchingTexture"),ue.setValue(N,"batchingTexture",W._matricesTexture,$),ue.setOptional(N,W,"batchingIdTexture"),ue.setValue(N,"batchingIdTexture",W._indirectTexture,$),ue.setOptional(N,W,"batchingColorTexture"),W._colorsTexture!==null&&ue.setValue(N,"batchingColorTexture",W._colorsTexture,$));const qi=q.morphAttributes;if((qi.position!==void 0||qi.normal!==void 0||qi.color!==void 0)&&L.update(W,q,Ln),(Xi||Mt.receiveShadow!==W.receiveShadow)&&(Mt.receiveShadow=W.receiveShadow,ue.setValue(N,"receiveShadow",W.receiveShadow)),(G.isMeshStandardMaterial||G.isMeshLambertMaterial||G.isMeshPhongMaterial)&&G.envMap===null&&U.environment!==null&&(Ne.envMapIntensity.value=U.environmentIntensity),Ne.dfgLUT!==void 0&&(Ne.dfgLUT.value=v3()),Xi){if(ue.setValue(N,"toneMappingExposure",P.toneMappingExposure),Mt.needsLights&&ig(Ne,Gs),gt&&G.fog===!0&&Rt.refreshFogUniforms(Ne,gt),Rt.refreshMaterialUniforms(Ne,G,it,rt,w.state.transmissionRenderTarget[y.id]),Mt.needsLights&&Mt.lightProbeGrid){const pe=Mt.lightProbeGrid;Ne.probesSH.value=pe.texture,Ne.probesMin.value.copy(pe.boundingBox.min),Ne.probesMax.value.copy(pe.boundingBox.max),Ne.probesResolution.value.copy(pe.resolution)}$o.upload(N,ad(Mt),Ne,$)}if(G.isShaderMaterial&&G.uniformsNeedUpdate===!0&&($o.upload(N,ad(Mt),Ne,$),G.uniformsNeedUpdate=!1),G.isSpriteMaterial&&ue.setValue(N,"center",W.center),ue.setValue(N,"modelViewMatrix",W.modelViewMatrix),ue.setValue(N,"normalMatrix",W.normalMatrix),ue.setValue(N,"modelMatrix",W.matrixWorld),G.uniformsGroups!==void 0){const pe=G.uniformsGroups;for(let Yi=0,Vs=pe.length;Yi<Vs;Yi++){const cd=pe[Yi];et.update(cd,Ln),et.bind(cd,Ln)}}return Ln}function ig(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function sg(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return Y},this.setRenderTargetTextures=function(y,U,q){const G=X.get(y);G.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,G.__autoAllocateDepthBuffer===!1&&(G.__useRenderToTexture=!1),X.get(y.texture).__webglTexture=U,X.get(y.depthTexture).__webglTexture=G.__autoAllocateDepthBuffer?void 0:q,G.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const q=X.get(y);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,q=0){Y=y,V=U,k=q;let G=null,W=!1,gt=!1;if(y){const mt=X.get(y);if(mt.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,mt.__webglFramebuffer),nt.copy(y.viewport),at.copy(y.scissor),Ht=y.scissorTest,x.viewport(nt),x.scissor(at),x.setScissorTest(Ht),tt=-1;return}else if(mt.__webglFramebuffer===void 0)$.setupRenderTarget(y);else if(mt.__hasExternalTextures)$.rebindTextures(y,X.get(y.texture).__webglTexture,X.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Vt=y.depthTexture;if(mt.__boundDepthTexture!==Vt){if(Vt!==null&&X.has(Vt)&&(y.width!==Vt.image.width||y.height!==Vt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(y)}}const bt=y.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(gt=!0);const Dt=X.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Dt[U])?G=Dt[U][q]:G=Dt[U],W=!0):y.samples>0&&$.useMultisampledRTT(y)===!1?G=X.get(y).__webglMultisampledFramebuffer:Array.isArray(Dt)?G=Dt[q]:G=Dt,nt.copy(y.viewport),at.copy(y.scissor),Ht=y.scissorTest}else nt.copy(It).multiplyScalar(it).floor(),at.copy(Tt).multiplyScalar(it).floor(),Ht=xt;if(q!==0&&(G=F),x.bindFramebuffer(N.FRAMEBUFFER,G)&&x.drawBuffers(y,G),x.viewport(nt),x.scissor(at),x.setScissorTest(Ht),W){const mt=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,mt.__webglTexture,q)}else if(gt){const mt=U;for(let bt=0;bt<y.textures.length;bt++){const Dt=X.get(y.textures[bt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+bt,Dt.__webglTexture,q,mt)}}else if(y!==null&&q!==0){const mt=X.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,mt.__webglTexture,q)}tt=-1},this.readRenderTargetPixels=function(y,U,q,G,W,gt,_t,mt=0){if(!(y&&y.isWebGLRenderTarget)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt){x.bindFramebuffer(N.FRAMEBUFFER,bt);try{const Dt=y.textures[mt],Vt=Dt.format,Yt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!T.textureFormatReadable(Vt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(Yt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W&&N.readPixels(U,q,G,W,dt.convert(Vt),dt.convert(Yt),gt)}finally{const Dt=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(y,U,q,G,W,gt,_t,mt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=X.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt)if(U>=0&&U<=y.width-G&&q>=0&&q<=y.height-W){x.bindFramebuffer(N.FRAMEBUFFER,bt);const Dt=y.textures[mt],Vt=Dt.format,Yt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+mt),!T.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(Yt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.bufferData(N.PIXEL_PACK_BUFFER,gt.byteLength,N.STREAM_READ),N.readPixels(U,q,G,W,dt.convert(Vt),dt.convert(Yt),0);const oe=Y!==null?X.get(Y).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,oe);const Le=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await X1(N,Le,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,gt),N.deleteBuffer(Ct),N.deleteSync(Le),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,q=0){const G=Math.pow(2,-q),W=Math.floor(y.image.width*G),gt=Math.floor(y.image.height*G),_t=U!==null?U.x:0,mt=U!==null?U.y:0;$.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,q,0,0,_t,mt,W,gt),x.unbindTexture()},this.copyTextureToTexture=function(y,U,q=null,G=null,W=0,gt=0){let _t,mt,bt,Dt,Vt,Yt,Ct,oe,Le;const Ce=y.isCompressedTexture?y.mipmaps[gt]:y.image;if(q!==null)_t=q.max.x-q.min.x,mt=q.max.y-q.min.y,bt=q.isBox3?q.max.z-q.min.z:1,Dt=q.min.x,Vt=q.min.y,Yt=q.isBox3?q.min.z:0;else{const Ne=Math.pow(2,-W);_t=Math.floor(Ce.width*Ne),mt=Math.floor(Ce.height*Ne),y.isDataArrayTexture?bt=Ce.depth:y.isData3DTexture?bt=Math.floor(Ce.depth*Ne):bt=1,Dt=0,Vt=0,Yt=0}G!==null?(Ct=G.x,oe=G.y,Le=G.z):(Ct=0,oe=0,Le=0);const he=dt.convert(U.format),nn=dt.convert(U.type);let Mt;U.isData3DTexture?($.setTexture3D(U,0),Mt=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),Mt=N.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),Mt=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const An=x.getParameter(N.UNPACK_ROW_LENGTH),Qt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Ln=x.getParameter(N.UNPACK_SKIP_PIXELS),ai=x.getParameter(N.UNPACK_SKIP_ROWS),Xi=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Ce.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Ce.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Dt),x.pixelStorei(N.UNPACK_SKIP_ROWS,Vt),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Yt);const Gs=y.isDataArrayTexture||y.isData3DTexture,ue=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Ne=X.get(y),qi=X.get(U),pe=X.get(Ne.__renderTarget),Yi=X.get(qi.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,pe.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,Yi.__webglFramebuffer);for(let Vs=0;Vs<bt;Vs++)Gs&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(y).__webglTexture,W,Yt+Vs),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,X.get(U).__webglTexture,gt,Le+Vs)),N.blitFramebuffer(Dt,Vt,_t,mt,Ct,oe,_t,mt,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(W!==0||y.isRenderTargetTexture||X.has(y)){const Ne=X.get(y),qi=X.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,H),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let pe=0;pe<bt;pe++)Gs?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Ne.__webglTexture,W,Yt+pe):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Ne.__webglTexture,W),ue?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,qi.__webglTexture,gt,Le+pe):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,qi.__webglTexture,gt),W!==0?N.blitFramebuffer(Dt,Vt,_t,mt,Ct,oe,_t,mt,N.COLOR_BUFFER_BIT,N.NEAREST):ue?N.copyTexSubImage3D(Mt,gt,Ct,oe,Le+pe,Dt,Vt,_t,mt):N.copyTexSubImage2D(Mt,gt,Ct,oe,Dt,Vt,_t,mt);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ue?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,nn,Ce.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,Ce.data):N.texSubImage3D(Mt,gt,Ct,oe,Le,_t,mt,bt,he,nn,Ce):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,gt,Ct,oe,_t,mt,he,nn,Ce.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,gt,Ct,oe,Ce.width,Ce.height,he,Ce.data):N.texSubImage2D(N.TEXTURE_2D,gt,Ct,oe,_t,mt,he,nn,Ce);x.pixelStorei(N.UNPACK_ROW_LENGTH,An),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Qt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Ln),x.pixelStorei(N.UNPACK_SKIP_ROWS,ai),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Xi),gt===0&&U.generateMipmaps&&N.generateMipmap(Mt),x.unbindTexture()},this.initRenderTarget=function(y){X.get(y).__webglFramebuffer===void 0&&$.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?$.setTextureCube(y,0):y.isData3DTexture?$.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?$.setTexture2DArray(y,0):$.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){V=0,k=0,Y=null,x.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return vi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=jt._getDrawingBufferColorSpace(t),e.unpackColorSpace=jt._getUnpackColorSpace()}}const x3=`
4630
4630
  varying vec3 vDir;
4631
4631
 
4632
4632
  void main() {
@@ -4998,7 +4998,7 @@ float transmissionAt(vec3 dir, float distanceM) {
4998
4998
  if (transmission < 0.015) break;
4999
4999
  }
5000
5000
  return transmission;
5001
- }`,n=/\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(t+e).replace(n,i=>s+i)}class fc{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new C(0,1,0)},sunColor:{value:new ct(1,1,1)},ambientColor:{value:new ct(.4,.45,.5)},hazeColor:{value:new ct(.5,.6,.7)},offsetM:{value:new C},seedOffset:{value:new C},localCenter:{value:new C},localSize:{value:new C},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:ta},()=>new C)},holeSize:{value:Array.from({length:ta},()=>new C)},holeRotation:{value:new Array(ta).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 n=new Ae({uniforms:this.uniforms,vertexShader:A3,fragmentShader:Jh,transparent:!0,depthWrite:!1,depthTest:!0,side:ze});this.mesh=new qt(new ln(e,32,16),n),this.mesh.frustumCulled=!1}update(t,e,n,i=[]){const r=this.uniforms;r.localSize.value.set(n?.widthM??0,n?.thicknessM??0,n?.depthM??0),r.localCenter.value.set(n?.eastM??0,n?n.baseM+n.thicknessM/2:0,-(n?.northM??0)),r.localRotation.value=(n?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(ta,i.length),i.slice(0,ta).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,t.baseM),r.thicknessM.value=Math.max(10,t.thicknessM),r.coverage.value=Math.max(0,Math.min(1,t.coverage)),r.sizeM.value=Math.max(50,t.sizeM),r.density.value=Math.max(0,Math.min(2,t.density)),r.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),r.eyeM.value=Math.max(.1,e),r.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const a=Zh(t);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(n!==void 0||r.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,n=(F,H,O)=>{const V=Math.max(0,Math.min(1,(O-F)/(H-F)));return V*V*(3-2*V)},i=(F,H,O)=>F+(H-F)*O,r=e.eyeM.value+t.y,a=2*Mr*r+t.x**2+r**2+t.z**2,o=a/(Math.sqrt(Mr**2+a)+Mr),c=(o-e.baseM.value)/e.thicknessM.value,l=e.localSize.value.x>0;if(c<=0||c>=1||e.coverage.value<=0&&!l)return 0;const h=(F,H,O)=>{const V=t.x+e.offsetM.value.x-F.x,k=t.z+e.offsetM.value.z-F.z,Y=Math.cos(O),tt=Math.sin(O);return Math.hypot((Y*V-tt*k)/(H.x*.5),(o-F.y)/(H.y*.5),(tt*V+Y*k)/(H.z*.5))},u=l?h(e.localCenter.value,e.localSize.value,e.localRotation.value):0;if(u>1.3)return 0;const d=[t.x,t.y,t.z].map((F,H)=>(F+e.offsetM.value.getComponent(H))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(H)),f=e.noiseMap.value.image.data,p=(F,H,O)=>{const V=[F,H,O].map(J=>(J%1+1)%1*Ue-.5),k=V.map(Math.floor),Y=V.map((J,nt)=>J-k[nt]);let tt=0;for(let J=0;J<2;J++)for(let nt=0;nt<2;nt++)for(let at=0;at<2;at++){const Ht=(k[0]+at+Ue)%Ue,$t=(k[1]+nt+Ue)%Ue,Bt=(k[2]+J+Ue)%Ue;tt+=f[Ht+Ue*($t+Ue*Bt)]/255*(at?Y[0]:1-Y[0])*(nt?Y[1]:1-Y[1])*(J?Y[2]:1-Y[2])}return tt},v=[d[0]*.173,bl,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 g=(d[0]*.731+d[2]*.682)*1.371,m=(-d[0]*.682+d[2]*.731)*1.371;let S=n(.2,.8,p(d[0],bl,d[2])*.65+p(g,bl+.37,m)*.35);const E=n(8e3,4e4,Math.hypot(t.x,t.y,t.z)),_=i(p(d[0]*2,d[1]*3,d[2]*2),.5,E),b=i(p(d[0]*7,d[1]*7,d[2]*7),.5,E);let w=fc.thresholdFor(e.coverage.value),R=1,M=0;if(l){const F=u+(_-.5)*.18;M=1-n(.35,1,F),R=1-n(.85,1.15,F),S=i(S,1,M),w=Math.min(w,fc.thresholdFor(.5))}for(let F=0;F<e.holeCount.value;F++)R*=n(.85,1.15,h(e.holeCenter.value[F],e.holeSize.value[F],e.holeRotation.value[F])+(_-.5)*.18);if(R<.001)return 0;let A=n(w-.1,w+.1,S);if(A=i(A,1,n(.92,1,e.coverage.value)),A=i(A,Math.max(e.coverage.value,M),E),A<.001)return 0;const P=i(.45+.55*_,.96,e.flatness.value),D=n(0,.09,c)*(1-n(P-.22,P,c)),I=i(Math.max(0,A-(1-_)*.38-(1-b)*.1),A*.8,e.flatness.value);return D*I*e.density.value*R}transmissionAt(t,e=1/0){const n=this.uniforms,i=w3(t.y,n.eyeM.value,n.baseM.value,n.thicknessM.value);if(!i)return 1;let[r,a]=i;if(n.localSize.value.x>0){const h=n.localCenter.value.clone().sub(n.offsetM.value);h.y-=n.eyeM.value+(h.x**2+h.z**2)/(2*Mr);const u=n.localSize.value.length()*.5+25,d=t.x*h.x+t.y*h.y+t.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,e,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:t.x*u,y:t.y*u,z:t.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class Jn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=Jn.build(24);static build(t){const e=[];let n=0,i=0,r=0;for(let a=0;a<t;a++){const o=Jn.VIOLET_NM+(a+.5)/t*(Jn.DEEP_RED_NM-Jn.VIOLET_NM),[c,l,h]=Jn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,i+=u.g,r+=u.b,e.push(u)}for(const a of e)a.r/=n,a.g/=i,a.b/=r;return e}static colourMatching(t){const e=(n,i,r)=>{const a=(t-n)/(t<n?i:r);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class pc{static reflectance(t,e,n){const r=e/n*Math.sqrt(Math.max(0,1-t*t));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*t-e*a)/(n*t+e*a),c=(e*t-n*a)/(e*t+n*a);return(o*o+c*c)/2}}class Ze{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Ze.ANCHOR_BLUE-Ze.ANCHOR_RED)/(1/(Ze.BLUE_NM*Ze.BLUE_NM)-1/(Ze.RED_NM*Ze.RED_NM));static A=Ze.ANCHOR_RED-Ze.B/(Ze.RED_NM*Ze.RED_NM);static indexAt(t){return Ze.A+Ze.B/(t*t)}}class Tr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const n=Math.min(1,Math.max(0,t)),i=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=pc.reflectance(i,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=Tr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=pc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Tr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=Tr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let n=t%e;return n<0&&(n+=e),n>Math.PI?e-n:n}}class Oe{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Tr;previous=Oe.emergences();current=Oe.emergences();tally=new Float32Array(Oe.BINS*3);radiance=new Float32Array(Oe.BINS*3);scratch=new Float32Array(Oe.BINS*3);static emergences(){return Array.from({length:Tr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of Jn.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Oe.BINS,data:this.radiance,binDeg:180/Oe.BINS}}sweep(t){this.drop.refractiveIndex=Ze.indexAt(t.wavelengthNm);const e=Oe.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/e;for(let r=1;r<=e;r++){const a=this.drop.trace(Math.sqrt(r/e),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*i,t)}n=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let n=0;n<t.length;n++)e[n].chords=t[n].chords,e[n].scatteringAngle=t[n].scatteringAngle,e[n].weight=t[n].weight}deposit(t,e,n,i){if(n<=0)return;const r=Oe.BINS,a=Math.PI/r,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,i);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,i)}}add(t,e,n){const i=t*3,r=e*Jn.SAMPLES.length;this.tally[i]+=r*n.r,this.tally[i+1]+=r*n.g,this.tally[i+2]+=r*n.b}toRadiance(){const t=Oe.BINS,e=Math.PI/t;for(let n=0;n<t;n++){const i=2*Math.PI*(Math.cos(n*e)-Math.cos((n+1)*e)),r=i>0?this.backwardShare((n+.5)*(180/t))/i:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(t){const e=180-t;if(e<=Oe.FULL_UNTIL_DEG)return 1;if(e>=Oe.FADED_BY_DEG)return 0;const n=(e-Oe.FULL_UNTIL_DEG)/(Oe.FADED_BY_DEG-Oe.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const t=Oe.BINS,e=Oe.SOURCE_RADIUS_DEG*t/180,n=Math.max(1,Math.ceil(e)),i=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);i.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=i[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Ps{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Oe;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Oe.BINS*4),this.texture=new Ur(this.texels,Oe.BINS,1,vn,cn),this.texture.minFilter=ye,this.texture.magFilter=ye,this.texture.wrapS=gn,this.texture.wrapT=gn,this.texture.needsUpdate=!0,this.material=new Ae({uniforms:{uSource:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Ps.GAIN}},vertexShader:`
5001
+ }`,n=/\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(t+e).replace(n,i=>s+i)}class fc{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new C(0,1,0)},sunColor:{value:new ct(1,1,1)},ambientColor:{value:new ct(.4,.45,.5)},hazeColor:{value:new ct(.5,.6,.7)},offsetM:{value:new C},seedOffset:{value:new C},localCenter:{value:new C},localSize:{value:new C},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:ta},()=>new C)},holeSize:{value:Array.from({length:ta},()=>new C)},holeRotation:{value:new Array(ta).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 n=new Ae({uniforms:this.uniforms,vertexShader:A3,fragmentShader:Jh,transparent:!0,depthWrite:!1,depthTest:!0,side:ze});this.mesh=new qt(new ln(e,32,16),n),this.mesh.frustumCulled=!1}update(t,e,n,i=[]){const r=this.uniforms;r.localSize.value.set(n?.widthM??0,n?.thicknessM??0,n?.depthM??0),r.localCenter.value.set(n?.eastM??0,n?n.baseM+n.thicknessM/2:0,-(n?.northM??0)),r.localRotation.value=(n?.rotationDeg??0)*Math.PI/180,r.holeCount.value=Math.min(ta,i.length),i.slice(0,ta).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,t.baseM),r.thicknessM.value=Math.max(10,t.thicknessM),r.coverage.value=Math.max(0,Math.min(1,t.coverage)),r.sizeM.value=Math.max(50,t.sizeM),r.density.value=Math.max(0,Math.min(2,t.density)),r.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),r.eyeM.value=Math.max(.1,e),r.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const a=Zh(t);r.seedOffset.value.set(a%97/97,a%61/61,a%37/37),this.mesh.visible=r.density.value>0&&(n!==void 0||r.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .645-.23*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,n=(F,H,O)=>{const V=Math.max(0,Math.min(1,(O-F)/(H-F)));return V*V*(3-2*V)},i=(F,H,O)=>F+(H-F)*O,r=e.eyeM.value+t.y,a=2*Mr*r+t.x**2+r**2+t.z**2,o=a/(Math.sqrt(Mr**2+a)+Mr),c=(o-e.baseM.value)/e.thicknessM.value,l=e.localSize.value.x>0;if(c<=0||c>=1||e.coverage.value<=0&&!l)return 0;const h=(F,H,O)=>{const V=t.x+e.offsetM.value.x-F.x,k=t.z+e.offsetM.value.z-F.z,Y=Math.cos(O),tt=Math.sin(O);return Math.hypot((Y*V-tt*k)/(H.x*.5),(o-F.y)/(H.y*.5),(tt*V+Y*k)/(H.z*.5))},u=l?h(e.localCenter.value,e.localSize.value,e.localRotation.value):0;if(u>1.3)return 0;const d=[t.x,t.y,t.z].map((F,H)=>(F+e.offsetM.value.getComponent(H))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(H)),f=e.noiseMap.value.image.data,p=(F,H,O)=>{const V=[F,H,O].map(J=>(J%1+1)%1*Ue-.5),k=V.map(Math.floor),Y=V.map((J,nt)=>J-k[nt]);let tt=0;for(let J=0;J<2;J++)for(let nt=0;nt<2;nt++)for(let at=0;at<2;at++){const Ht=(k[0]+at+Ue)%Ue,$t=(k[1]+nt+Ue)%Ue,Bt=(k[2]+J+Ue)%Ue;tt+=f[Ht+Ue*($t+Ue*Bt)]/255*(at?Y[0]:1-Y[0])*(nt?Y[1]:1-Y[1])*(J?Y[2]:1-Y[2])}return tt},v=[d[0]*.173,bl,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 g=(d[0]*.731+d[2]*.682)*1.371,m=(-d[0]*.682+d[2]*.731)*1.371;let S=n(.2,.8,p(d[0],bl,d[2])*.65+p(g,bl+.37,m)*.35);const E=n(8e3,4e4,Math.hypot(t.x,t.y,t.z)),_=i(p(d[0]*2,d[1]*3,d[2]*2),.5,E),b=i(p(d[0]*7,d[1]*7,d[2]*7),.5,E);let w=fc.thresholdFor(e.coverage.value),R=1,M=0;if(l){const F=u+(_-.5)*.18;M=1-n(.35,1,F),R=1-n(.85,1.15,F),S=i(S,1,M),w=Math.min(w,fc.thresholdFor(.5))}for(let F=0;F<e.holeCount.value;F++)R*=n(.85,1.15,h(e.holeCenter.value[F],e.holeSize.value[F],e.holeRotation.value[F])+(_-.5)*.18);if(R<.001)return 0;let A=n(w-.1,w+.1,S);if(A=i(A,1,n(.92,1,e.coverage.value)),A=i(A,Math.max(e.coverage.value,M),E),A<.001)return 0;const P=i(.45+.55*_,.96,e.flatness.value),D=n(0,.09,c)*(1-n(P-.22,P,c)),I=i(Math.max(0,A-(1-_)*.38-(1-b)*.1),A*.8,e.flatness.value);return D*I*e.density.value*R}transmissionAt(t,e=1/0){const n=this.uniforms,i=w3(t.y,n.eyeM.value,n.baseM.value,n.thicknessM.value);if(!i)return 1;let[r,a]=i;if(n.localSize.value.x>0){const h=n.localCenter.value.clone().sub(n.offsetM.value);h.y-=n.eyeM.value+(h.x**2+h.z**2)/(2*Mr);const u=n.localSize.value.length()*.5+25,d=t.x*h.x+t.y*h.y+t.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,e,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:t.x*u,y:t.y*u,z:t.z*u})*c*.006),l<.015)break}return l}dispose(){this.mesh.removeFromParent(),this.mesh.geometry.dispose(),this.mesh.material.dispose()}}class jn{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=jn.build(24);static build(t){const e=[];let n=0,i=0,r=0;for(let a=0;a<t;a++){const o=jn.VIOLET_NM+(a+.5)/t*(jn.DEEP_RED_NM-jn.VIOLET_NM),[c,l,h]=jn.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,i+=u.g,r+=u.b,e.push(u)}for(const a of e)a.r/=n,a.g/=i,a.b/=r;return e}static colourMatching(t){const e=(n,i,r)=>{const a=(t-n)/(t<n?i:r);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class pc{static reflectance(t,e,n){const r=e/n*Math.sqrt(Math.max(0,1-t*t));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*t-e*a)/(n*t+e*a),c=(e*t-n*a)/(e*t+n*a);return(o*o+c*c)/2}}class Ze{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Ze.ANCHOR_BLUE-Ze.ANCHOR_RED)/(1/(Ze.BLUE_NM*Ze.BLUE_NM)-1/(Ze.RED_NM*Ze.RED_NM));static A=Ze.ANCHOR_RED-Ze.B/(Ze.RED_NM*Ze.RED_NM);static indexAt(t){return Ze.A+Ze.B/(t*t)}}class Tr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const n=Math.min(1,Math.max(0,t)),i=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=pc.reflectance(i,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=Tr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=pc.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Tr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=Tr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let n=t%e;return n<0&&(n+=e),n>Math.PI?e-n:n}}class Oe{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Tr;previous=Oe.emergences();current=Oe.emergences();tally=new Float32Array(Oe.BINS*3);radiance=new Float32Array(Oe.BINS*3);scratch=new Float32Array(Oe.BINS*3);static emergences(){return Array.from({length:Tr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of jn.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Oe.BINS,data:this.radiance,binDeg:180/Oe.BINS}}sweep(t){this.drop.refractiveIndex=Ze.indexAt(t.wavelengthNm);const e=Oe.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/e;for(let r=1;r<=e;r++){const a=this.drop.trace(Math.sqrt(r/e),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*i,t)}n=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let n=0;n<t.length;n++)e[n].chords=t[n].chords,e[n].scatteringAngle=t[n].scatteringAngle,e[n].weight=t[n].weight}deposit(t,e,n,i){if(n<=0)return;const r=Oe.BINS,a=Math.PI/r,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,i);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,i)}}add(t,e,n){const i=t*3,r=e*jn.SAMPLES.length;this.tally[i]+=r*n.r,this.tally[i+1]+=r*n.g,this.tally[i+2]+=r*n.b}toRadiance(){const t=Oe.BINS,e=Math.PI/t;for(let n=0;n<t;n++){const i=2*Math.PI*(Math.cos(n*e)-Math.cos((n+1)*e)),r=i>0?this.backwardShare((n+.5)*(180/t))/i:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(t){const e=180-t;if(e<=Oe.FULL_UNTIL_DEG)return 1;if(e>=Oe.FADED_BY_DEG)return 0;const n=(e-Oe.FULL_UNTIL_DEG)/(Oe.FADED_BY_DEG-Oe.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const t=Oe.BINS,e=Oe.SOURCE_RADIUS_DEG*t/180,n=Math.max(1,Math.ceil(e)),i=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);i.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=i[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class Ps{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Oe;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Oe.BINS*4),this.texture=new Ur(this.texels,Oe.BINS,1,vn,cn),this.texture.minFilter=ye,this.texture.magFilter=ye,this.texture.wrapS=gn,this.texture.wrapT=gn,this.texture.needsUpdate=!0,this.material=new Ae({uniforms:{uSource:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:Ps.GAIN}},vertexShader:`
5002
5002
  varying vec3 vDirection;
5003
5003
  void main() {
5004
5004
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5026,7 +5026,7 @@ float transmissionAt(vec3 dir, float distanceM) {
5026
5026
  light = mix(vec3(grey), light, uSaturation);
5027
5027
  gl_FragColor = vec4(light * uStrength, 1.0);
5028
5028
  }
5029
- `,transparent:!0,blending:Qn,depthWrite:!1,depthTest:!0,side:ze,fog:!1}),this.object=new qt(new ln(Ps.RADIUS,64,32),this.material),this.object.renderOrder=Ps.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,i){const r=this.material.uniforms;if(e<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(t.x,t.y,t.z).normalize(),r.uStrength.value=e,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=i?1:Ps.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=ls.toHalfFloat(e[i]),this.texels[n+1]=ls.toHalfFloat(e[i+1]),this.texels[n+2]=ls.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class mc{constructor(t,e,n){this.group=t,this.radius=e,this.mode=n}decks=new Map;noise;update(t,e){const n=jo(t).flatMap(a=>{const o={...a,darkness:a.darkness??t.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??Zh(o),instances:void 0}}))]}),i=new Set(n.map(a=>a.key));for(const[a,o]of this.decks)i.has(a)||(this.disposeDeck(o),this.decks.delete(a));[...n].sort((a,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-e)-Math.abs(a.layer.baseM+a.layer.thicknessM/2-e)).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??=E3(),d.volume=new fc(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=Kh(new ct(1,1,1),a.coverage,Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),a.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new qt($h(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=a,d.instance=c;const f=mc.deckOrder(a.baseM<e,h,n.length);d.volume&&(d.volume.update(a,e,c,c?[]:a.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=a.baseM<e?-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??t.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),d.uniforms.fibrous.value=a.type==="cirrus"?1:0)})}static deckOrder(t,e,n){const i=e/Math.max(1,n);return t?Ps.RENDER_ORDER+.1+.3*i:4+i}setOffsets(t,e){for(const n of this.decks.values()){const i=e[n.parentId]??t;n.volume?.uniforms.offsetM.value.set(i.x,0,i.z);const r=.25*1400/Math.max(50,n.layer.sizeM),a=Zh(n.layer);n.uniforms?.fieldOffset.value.set(i.x*r+a%97,0,i.z*r+a%37)}}setLighting(t,e,n,i){for(const r of this.decks.values()){const a=r.volume?.uniforms??r.uniforms;a.sunDir.value.copy(t),a.sunColor.value.copy(e),a.ambientColor.value.copy(n),r.volume?.uniforms.hazeColor.value.copy(i)}}get cirrusMask(){const t=[...this.decks.values()].filter(e=>e.layer.type==="cirrus"&&e.uniforms).sort((e,n)=>n.layer.coverage-e.layer.coverage)[0];return t?.uniforms?{cover:t.layer.coverage,layerHeight:t.uniforms.layerHeight.value,offset:t.uniforms.fieldOffset.value,iceCrystalAlignment:t.layer.iceCrystalAlignment}:void 0}get volumes(){return[...this.decks.values()].flatMap(t=>t.volume?.mesh.visible?[t.volume]:[])}pickInstance(t){let e=1/0,n;for(const i of this.decks.values()){if(!i.instance||!i.volume?.mesh.visible)continue;const r=i.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(t);o<=0||o>=e||i.volume.transmissionAt(t)>.98||(e=o,n={layerId:i.parentId,instanceId:i.instance.id,center:a})}return n}transmissionAt(t){let e=1;for(const n of this.decks.values())n.volume?e*=n.volume.transmissionAt(t):n.uniforms&&(e*=1-Pe.alphaAt(t,n.uniforms.layerHeight.value,n.layer.coverage,n.uniforms.fieldOffset.value)*(n.layer.type==="cirrus"?.2:.95));return e}disposeDeck(t){t.volume?.dispose(),t.surface&&(t.surface.removeFromParent(),t.surface.geometry.dispose(),t.surface.material.dispose())}dispose(){for(const t of this.decks.values())this.disposeDeck(t);this.decks.clear(),this.noise?.dispose()}}const Dc=`
5029
+ `,transparent:!0,blending:ti,depthWrite:!1,depthTest:!0,side:ze,fog:!1}),this.object=new qt(new ln(Ps.RADIUS,64,32),this.material),this.object.renderOrder=Ps.RENDER_ORDER,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,i){const r=this.material.uniforms;if(e<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(t.x,t.y,t.z).normalize(),r.uStrength.value=e,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=i?1:Ps.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=ls.toHalfFloat(e[i]),this.texels[n+1]=ls.toHalfFloat(e[i+1]),this.texels[n+2]=ls.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class mc{constructor(t,e,n){this.group=t,this.radius=e,this.mode=n}decks=new Map;noise;update(t,e){const n=jo(t).flatMap(a=>{const o={...a,darkness:a.darkness??t.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??Zh(o),instances:void 0}}))]}),i=new Set(n.map(a=>a.key));for(const[a,o]of this.decks)i.has(a)||(this.disposeDeck(o),this.decks.delete(a));[...n].sort((a,o)=>Math.abs(o.layer.baseM+o.layer.thicknessM/2-e)-Math.abs(a.layer.baseM+a.layer.thicknessM/2-e)).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??=E3(),d.volume=new fc(this.noise,this.radius),this.group.add(d.volume.mesh);else{const p=Kh(new ct(1,1,1),a.coverage,Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),a.type==="cirrus"?1:0);d.uniforms=p.uniforms,d.surface=new qt($h(this.radius),p.material),this.group.add(d.surface)}this.decks.set(o,d)}d.layer=a,d.instance=c;const f=mc.deckOrder(a.baseM<e,h,n.length);d.volume&&(d.volume.update(a,e,c,c?[]:a.instances??[]),d.volume.mesh.renderOrder=f),d.surface&&d.uniforms&&(d.surface.renderOrder=f,d.surface.scale.y=a.baseM<e?-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??t.cloudDarkness)),d.uniforms.layerHeight.value=Math.max(1,Math.abs(a.baseM-e)*.25*1400/Math.max(50,a.sizeM)),d.uniforms.fibrous.value=a.type==="cirrus"?1:0)})}static deckOrder(t,e,n){const i=e/Math.max(1,n);return t?Ps.RENDER_ORDER+.1+.3*i:4+i}setOffsets(t,e){for(const n of this.decks.values()){const i=e[n.parentId]??t;n.volume?.uniforms.offsetM.value.set(i.x,0,i.z);const r=.25*1400/Math.max(50,n.layer.sizeM),a=Zh(n.layer);n.uniforms?.fieldOffset.value.set(i.x*r+a%97,0,i.z*r+a%37)}}setLighting(t,e,n,i){for(const r of this.decks.values()){const a=r.volume?.uniforms??r.uniforms;a.sunDir.value.copy(t),a.sunColor.value.copy(e),a.ambientColor.value.copy(n),r.volume?.uniforms.hazeColor.value.copy(i)}}get cirrusMask(){const t=[...this.decks.values()].filter(e=>e.layer.type==="cirrus"&&e.uniforms).sort((e,n)=>n.layer.coverage-e.layer.coverage)[0];return t?.uniforms?{cover:t.layer.coverage,layerHeight:t.uniforms.layerHeight.value,offset:t.uniforms.fieldOffset.value,iceCrystalAlignment:t.layer.iceCrystalAlignment}:void 0}get volumes(){return[...this.decks.values()].flatMap(t=>t.volume?.mesh.visible?[t.volume]:[])}pickInstance(t){let e=1/0,n;for(const i of this.decks.values()){if(!i.instance||!i.volume?.mesh.visible)continue;const r=i.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(t);o<=0||o>=e||i.volume.transmissionAt(t)>.98||(e=o,n={layerId:i.parentId,instanceId:i.instance.id,center:a})}return n}transmissionAt(t){let e=1;for(const n of this.decks.values())n.volume?e*=n.volume.transmissionAt(t):n.uniforms&&(e*=1-Pe.alphaAt(t,n.uniforms.layerHeight.value,n.layer.coverage,n.uniforms.fieldOffset.value)*(n.layer.type==="cirrus"?.2:.95));return e}disposeDeck(t){t.volume?.dispose(),t.surface&&(t.surface.removeFromParent(),t.surface.geometry.dispose(),t.surface.material.dispose())}dispose(){for(const t of this.decks.values())this.disposeDeck(t);this.decks.clear(),this.noise?.dispose()}}const Dc=`
5030
5030
  vec3 encodeSrgb(vec3 linear) {
5031
5031
  vec3 clamped = max(linear, vec3(0.0));
5032
5032
  vec3 low = clamped * 12.92;
@@ -5047,7 +5047,7 @@ vec3 encodeSrgb(vec3 linear) {
5047
5047
  void main() {
5048
5048
  gl_FragColor = vec4(texture2D(uSource, vUv).rgb * uShare, 1.0);
5049
5049
  }
5050
- `,blending:Qn,depthTest:!1,depthWrite:!1}),this.developMaterial=new Ae({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
5050
+ `,blending:ti,depthTest:!1,depthWrite:!1}),this.developMaterial=new Ae({uniforms:{uFilm:{value:this.filmTarget.texture},uGain:{value:1}},vertexShader:n,fragmentShader:`
5051
5051
  precision highp float;
5052
5052
  ${Dc}
5053
5053
  varying vec2 vUv;
@@ -5056,7 +5056,7 @@ vec3 encodeSrgb(vec3 linear) {
5056
5056
  void main() {
5057
5057
  gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
5058
5058
  }
5059
- `,blending:Mi,depthTest:!1,depthWrite:!1}),this.quad=new qt(new Wi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(t){const e=t.getRenderTarget();t.setRenderTarget(this.filmTarget),t.setClearColor(0,1),t.clear(!0,!0,!0),t.setRenderTarget(e)}add(t,e){this.addMaterial.uniforms.uShare.value=e,this.quad.material=this.addMaterial;const n=t.getRenderTarget(),i=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.filmTarget),t.render(this.quadScene,this.quadCamera),t.setRenderTarget(n),t.autoClear=i}develop(t,e=1){this.developMaterial.uniforms.uGain.value=e,this.quad.material=this.developMaterial,t.setRenderTarget(null),t.render(this.quadScene,this.quadCamera)}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),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 jh=Math.PI/180,tf=180/Math.PI;function Ua(s,t,e){return Math.max(t,Math.min(e,s))}const ts=[{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 El(s,t,e){return s+(t-s)*e}function gc(s,t,e){return[El(s[0],t[0],e),El(s[1],t[1],e),El(s[2],t[2],e)]}function Qh(s){const t=Math.max(ts[0].altitudeDeg,Math.min(ts[ts.length-1].altitudeDeg,s));for(let n=0;n<ts.length-1;n++){const i=ts[n],r=ts[n+1];if(t>=i.altitudeDeg&&t<=r.altitudeDeg){const a=(t-i.altitudeDeg)/(r.altitudeDeg-i.altitudeDeg);return{zenith:gc(i.zenith,r.zenith,a),horizon:gc(i.horizon,r.horizon,a)}}}const e=ts[ts.length-1];return{zenith:e.zenith,horizon:e.horizon}}const ef=-18,nf=-4,D3=1.8;function mm(s,t=0){if(s<=ef)return Zo+t;if(s>=0)return nf+t;const e=s/ef;return Zo-(Zo-nf)*(1-e)**D3+t}const sf=-1.5,Zo=6.5,C3=1.6;function wl(s,t=Zo){const e=Math.max(t,sf+1),n=(e-s)/(e-sf);return Ua(n,0,1)**C3}function pn(s,t,e){const n=s*jh,i=t*jh,r=e*Math.cos(n);return{x:r*Math.sin(i),y:e*Math.sin(n),z:-r*Math.cos(i)}}function P3(s,t,e){const n=Math.sqrt(s*s+t*t+e*e),i=n===0?0:Math.asin(Ua(t/n,-1,1))*tf,r=(Math.atan2(s,-e)*tf+360)%360;return{altitudeDeg:i,azimuthDeg:r}}function I3(s,t){const e=Math.abs(s-t)%360;return e>180?360-e:e}function L3(s,t,e,n){const i=Math.max(0,1-I3(s,e)/N3),r=Math.exp(-Math.max(0,t)/O3),a=n>0?Math.max(0,1-n/U3):Math.max(0,1-Math.abs(n+F3)/z3);return i*r*a}const N3=90,O3=12,U3=8,F3=2,z3=12;function k3(s,t,e,n){const{zenith:i,horizon:r}=Qh(n),a=Ua((s+90)/180,0,1),o=gc(r,i,a),c=L3(t,s,e,n);if(c<=0)return o;const l=Qh(n+B3).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return gc(o,h,c)}const B3=6;function Al(s){return .12+.88*s}const H3=-4;function G3(s){return Math.max(0,H3-s)}const V3=6,W3=60;function X3(s){return Math.min(W3,V3*Math.sqrt(s))}const q3=3,Y3=.55;function K3(s){return Y3*Ua(s/q3,0,1)}function gm(s){const t=Math.max(s,-4),e=Math.sin(t*jh)+.50572*Math.pow(t+6.07995,-1.6364);return Ua(1/e,1,40)}function xs(s){const t=gm(s)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function $3(s){return J3*(gm(Math.max(s,0))-1)}function Z3(s){return Math.pow(10,-.4*$3(s))}const J3=5/37,vm=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function j3(s){return vm.findIndex(t=>s<=t.maxBrightness)}const Q3=.25,rf=.3,tS=2.2;function eS(s,{phase:t,speedFactor:e},n){const r=1+Q3*(rf+(1-rf)*s)*Math.sin(n*tS*e+t);return Math.min(1,Math.max(0,r))}/**
5059
+ `,blending:xi,depthTest:!1,depthWrite:!1}),this.quad=new qt(new Wi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(t){const e=t.getRenderTarget();t.setRenderTarget(this.filmTarget),t.setClearColor(0,1),t.clear(!0,!0,!0),t.setRenderTarget(e)}add(t,e){this.addMaterial.uniforms.uShare.value=e,this.quad.material=this.addMaterial;const n=t.getRenderTarget(),i=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.filmTarget),t.render(this.quadScene,this.quadCamera),t.setRenderTarget(n),t.autoClear=i}develop(t,e=1){this.developMaterial.uniforms.uGain.value=e,this.quad.material=this.developMaterial,t.setRenderTarget(null),t.render(this.quadScene,this.quadCamera)}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),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 jh=Math.PI/180,tf=180/Math.PI;function Ua(s,t,e){return Math.max(t,Math.min(e,s))}const ts=[{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 El(s,t,e){return s+(t-s)*e}function gc(s,t,e){return[El(s[0],t[0],e),El(s[1],t[1],e),El(s[2],t[2],e)]}function Qh(s){const t=Math.max(ts[0].altitudeDeg,Math.min(ts[ts.length-1].altitudeDeg,s));for(let n=0;n<ts.length-1;n++){const i=ts[n],r=ts[n+1];if(t>=i.altitudeDeg&&t<=r.altitudeDeg){const a=(t-i.altitudeDeg)/(r.altitudeDeg-i.altitudeDeg);return{zenith:gc(i.zenith,r.zenith,a),horizon:gc(i.horizon,r.horizon,a)}}}const e=ts[ts.length-1];return{zenith:e.zenith,horizon:e.horizon}}const ef=-18,nf=-4,D3=1.8;function mm(s,t=0){if(s<=ef)return Zo+t;if(s>=0)return nf+t;const e=s/ef;return Zo-(Zo-nf)*(1-e)**D3+t}const sf=-1.5,Zo=6.5,C3=1.6;function wl(s,t=Zo){const e=Math.max(t,sf+1),n=(e-s)/(e-sf);return Ua(n,0,1)**C3}function pn(s,t,e){const n=s*jh,i=t*jh,r=e*Math.cos(n);return{x:r*Math.sin(i),y:e*Math.sin(n),z:-r*Math.cos(i)}}function P3(s,t,e){const n=Math.sqrt(s*s+t*t+e*e),i=n===0?0:Math.asin(Ua(t/n,-1,1))*tf,r=(Math.atan2(s,-e)*tf+360)%360;return{altitudeDeg:i,azimuthDeg:r}}function I3(s,t){const e=Math.abs(s-t)%360;return e>180?360-e:e}function L3(s,t,e,n){const i=Math.max(0,1-I3(s,e)/N3),r=Math.exp(-Math.max(0,t)/O3),a=n>0?Math.max(0,1-n/U3):Math.max(0,1-Math.abs(n+F3)/z3);return i*r*a}const N3=90,O3=12,U3=8,F3=2,z3=12;function k3(s,t,e,n){const{zenith:i,horizon:r}=Qh(n),a=Ua((s+90)/180,0,1),o=gc(r,i,a),c=L3(t,s,e,n);if(c<=0)return o;const l=Qh(n+B3).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return gc(o,h,c)}const B3=6;function Al(s){return .12+.88*s}const H3=-4;function G3(s){return Math.max(0,H3-s)}const V3=6,W3=60;function X3(s){return Math.min(W3,V3*Math.sqrt(s))}const q3=3,Y3=.55;function K3(s){return Y3*Ua(s/q3,0,1)}function gm(s){const t=Math.max(s,-4),e=Math.sin(t*jh)+.50572*Math.pow(t+6.07995,-1.6364);return Ua(1/e,1,40)}function xs(s){const t=gm(s)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function $3(s){return J3*(gm(Math.max(s,0))-1)}function Z3(s){return Math.pow(10,-.4*$3(s))}const J3=5/37,vm=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function j3(s){return vm.findIndex(t=>s<=t.maxBrightness)}const Q3=.25,rf=.3,tS=2.2;function eS(s,{phase:t,speedFactor:e},n){const r=1+Q3*(rf+(1-rf)*s)*Math.sin(n*tS*e+t);return Math.min(1,Math.max(0,r))}/**
5060
5060
  @preserve
5061
5061
 
5062
5062
  Astronomy library for JavaScript (browser and Node.js).
@@ -5087,11 +5087,11 @@ vec3 encodeSrgb(vec3 linear) {
5087
5087
  * @fileoverview Astronomy calculation library for browser scripting and Node.js.
5088
5088
  * @author Don Cross <cosinekitty@gmail.com>
5089
5089
  * @license MIT
5090
- */const Yu=173.1446326846693,As=14959787069098932e-8,ae=.017453292519943295,af=.26179938779914946,_i=57.29577951308232,Mm=3.819718634205488,nS=365.24217,of=new Date("2000-01-01T12:00:00Z"),Ri=2*Math.PI,es=3600*(180/Math.PI),xr=484813681109536e-20,xm=10800*60,iS=2*xm,cf=7292115e-11,sS=xm/Math.PI,rS=-.17-5*Math.log10(sS),tu=.996647180302104,aS=tu*tu,eu=6378.1366,oS=eu/As,_m=81.30056,Ku=.0002959122082855911,nu=2825345909524226e-22,iu=8459715185680659e-23,su=1292024916781969e-23,ru=1524358900784276e-23;function vc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function Je(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function fr(s){return s-Math.floor(s)}function cS(s,t){const e=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*t.x+s.y*t.y+s.z*t.z)/Math.sqrt(e*n);return i<=-1?180:i>=1?0:_i*Math.acos(i)}var St;(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"})(St||(St={}));const lS=[St.Star1,St.Star2,St.Star3,St.Star4,St.Star5,St.Star6,St.Star7,St.Star8],hS=[{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 uS(s){const t=lS.indexOf(s);return t>=0?hS[t]:null}function $u(s){const t=uS(s);return t&&t.dist>0?t:null}var Mn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(Mn||(Mn={}));const vi={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 dS(s){var t,e,n,i,r,a,o;const c=2e3+(s-14)/nS;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,i=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-i/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,o=n*i,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,i=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*i+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,i=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*i):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,i=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let fS=dS;function lf(s){return s+fS(s)/86400}class Rr{constructor(t){if(t instanceof Rr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-of.getTime())/e,this.tt=lf(this.ut);return}if(Number.isFinite(t)){this.date=new Date(of.getTime()+t*e),this.ut=t,this.tt=lf(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Rr(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new Rr(this.ut+t)}}function ke(s){return s instanceof Rr?s:new Rr(s)}function pS(s){function t(d){return d%iS*xr}const e=s.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),i=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function ym(s){var t=s.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Ao;function Fa(s){if(!Ao||Math.abs(Ao.tt-s.tt)>1e-6){const t=pS(s),e=ym(s),n=e+t.deps/3600;Ao={tt:s.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ae)/15,mobl:e,tobl:n}}return Ao}function mS(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[t[0],t[1]*n-t[2]*i,t[1]*i+t[2]*n]}function gS(s,t){return mS(ym(s),t)}function vS(s){const t=s.tt/36525;function e(Tt,xt){const Nt=[];let Ot;for(Ot=0;Ot<=xt-Tt;++Ot)Nt.push(0);return{min:Tt,array:Nt}}function n(Tt,xt,Nt,Ot){const Ut=[];for(let ee=0;ee<=xt-Tt;++ee)Ut.push(e(Nt,Ot));return{min:Tt,array:Ut}}function i(Tt,xt,Nt){const Ot=Tt.array[xt-Tt.min];return Ot.array[Nt-Ot.min]}function r(Tt,xt,Nt,Ot){const Ut=Tt.array[xt-Tt.min];Ut.array[Nt-Ut.min]=Ot}let a,o,c,l,h,u,d,f,p,v,g,m,S,E,_,b,w,R,M,A,P,D,I,F=n(-6,6,1,4),H=n(-6,6,1,4);function O(Tt,xt){return i(F,Tt,xt)}function V(Tt,xt){return i(H,Tt,xt)}function k(Tt,xt,Nt){return r(F,Tt,xt,Nt)}function Y(Tt,xt,Nt){return r(H,Tt,xt,Nt)}function tt(Tt,xt,Nt,Ot,Ut){Ut(Tt*Nt-xt*Ot,xt*Nt+Tt*Ot)}function J(Tt){return Math.sin(Ri*Tt)}d=t*t,p=0,I=0,g=0,m=3422.7;var nt=J(.19833+.05611*t),at=J(.27869+.04508*t),Ht=J(.16827-.36903*t),$t=J(.34734-5.37261*t),Bt=J(.10498-5.37899*t),K=J(.42681-.41855*t),rt=J(.14943-5.37511*t);for(R=.84*nt+.31*at+14.27*Ht+7.26*$t+.28*Bt+.24*K,M=2.94*nt+.31*at+14.27*Ht+9.34*$t+1.12*Bt+.83*K,A=-6.4*nt-1.89*K,P=.21*nt+.31*at+14.27*Ht-88.7*$t-15.3*Bt+.24*K-1.86*rt,D=R-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=Ri*fr(.60643382+1336.85522467*t-313e-8*d)+R/es,E=Ri*fr(.37489701+1325.55240982*t+2565e-8*d)+M/es,_=Ri*fr(.99312619+99.99735956*t-44e-8*d)+A/es,b=Ri*fr(.25909118+1342.2278298*t-892e-8*d)+P/es,w=Ri*fr(.82736186+1236.85308708*t-397e-8*d)+D/es,h=1;h<=4;++h){switch(h){case 1:c=E,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*t;break;case 3:c=b,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),Y(0,h,0),Y(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(O(u-1,h),V(u-1,h),O(1,h),V(1,h),(Tt,xt)=>(k(u,h,Tt),Y(u,h,xt)));for(u=1;u<=o;++u)k(-u,h,O(u,h)),Y(-u,h,-V(u,h))}function it(Tt,xt,Nt,Ot){for(var Ut={x:1,y:0},ee=[0,Tt,xt,Nt,Ot],ne=1;ne<=4;++ne)ee[ne]!==0&&tt(Ut.x,Ut.y,O(ee[ne],ne),V(ee[ne],ne),(Te,ve)=>(Ut.x=Te,Ut.y=ve));return Ut}function B(Tt,xt,Nt,Ot,Ut,ee,ne,Te){var ve=it(Ut,ee,ne,Te);p+=Tt*ve.y,I+=xt*ve.y,g+=Nt*ve.x,m+=Ot*ve.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 Et(Tt,xt,Nt,Ot,Ut){return Tt*it(xt,Nt,Ot,Ut).y}v=0,v+=Et(-526.069,0,0,1,-2),v+=Et(-3.352,0,0,1,-4),v+=Et(44.297,1,0,1,-2),v+=Et(-6,1,0,1,-4),v+=Et(20.599,-1,0,1,0),v+=Et(-30.598,-1,0,1,-2),v+=Et(-24.649,-2,0,1,0),v+=Et(-2,-2,0,1,-2),v+=Et(-22.571,0,1,1,-2),v+=Et(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+I/es;let It=(1.000002708+139.978*f)*(18518.511+1.189+g)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Ri*fr((S+p/es)/Ri),geo_eclip_lat:Math.PI/(180*3600)*It,distance_au:es*oS/(.999953253*m)}}function Sm(s,t){return[s.rot[0][0]*t[0]+s.rot[1][0]*t[1]+s.rot[2][0]*t[2],s.rot[0][1]*t[0]+s.rot[1][1]*t[1]+s.rot[2][1]*t[2],s.rot[0][2]*t[0]+s.rot[1][2]*t[1]+s.rot[2][2]*t[2]]}function Mc(s,t,e){const n=bm(t,e);return Sm(n,s)}function bm(s,t){const e=s.tt/36525;let n=84381.406,i=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=xr,i*=xr,r*=xr,a*=xr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,g=p*l*c+f*d*h*c-o*f*u,m=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,E=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(t===Mn.Into2000)return new ds([[v,g,m],[S,E,_],[b,w,R]]);if(t===Mn.From2000)return new ds([[v,S,b],[g,E,w],[m,_,R]]);throw"Invalid precess direction"}function MS(s){const t=.779057273264+.00273781191135448*s.ut,e=s.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let To;function Cc(s){if(!To||To.tt!==s.tt){const t=s.tt/36525;let e=15*Fa(s).ee;const n=MS(s);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),To={tt:s.tt,st:r}}return To.st}function xS(s){const t=ke(s);return Cc(t)}function Em(s,t){const e=s.latitude*ae,n=Math.sin(e),i=Math.cos(e),r=1/Math.hypot(i,tu*n),a=aS*r,o=s.height/1e3,c=eu*r+o,l=eu*a+o,h=(15*t+s.longitude)*ae,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/As,c*i*u/As,l*n/As],vel:[-cf*c*i*u*86400/As,cf*c*i*d*86400/As,0]}}function au(s,t,e){const n=wm(t,e);return Sm(n,s)}function wm(s,t){const e=Fa(s),n=e.mobl*ae,i=e.tobl*ae,r=e.dpsi*xr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,g=h*a*c+o*l,m=h*o*c-a*l,S=u*l,E=h*a*l-o*c,_=h*o*l+a*c;if(t===Mn.From2000)return new ds([[d,v,S],[f,g,E],[p,m,_]]);if(t===Mn.Into2000)return new ds([[d,f,p],[v,g,m],[S,E,_]]);throw"Invalid precess direction"}function Zu(s,t,e){return e===Mn.Into2000?Mc(au(s,t,e),t,e):au(Mc(s,t,e),t,e)}function _S(s,t){const e=Cc(s),n=Em(t,e).pos;return Zu(n,s,Mn.Into2000)}class ge{constructor(t,e,n,i){this.x=t,this.y=e,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class cs{constructor(t,e,n,i,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class Ju{constructor(t,e,n){this.lat=Je(t),this.lon=Je(e),this.dist=Je(n)}}class ou{constructor(t,e,n,i){this.ra=Je(t),this.dec=Je(e),this.dist=Je(n),this.vec=i}}class ds{constructor(t){this.rot=t}}class yS{constructor(t,e,n,i){this.azimuth=Je(t),this.altitude=Je(e),this.ra=Je(n),this.dec=Je(i)}}class SS{constructor(t,e,n){this.vec=t,this.elat=Je(e),this.elon=Je(n)}}function Am(s,t){return new ge(s[0],s[1],s[2],t)}function bS(s,t){const e=Am(s,t),n=e.x*e.x+e.y*e.y,i=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new ou(0,e.z<0?-90:90,i,e)}let r=Mm*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=_i*Math.atan2(s[2],Math.sqrt(n));return new ou(r,a,i,e)}function Tl(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[n*t[0]+i*t[1],n*t[1]-i*t[0],t[2]]}function Tm(s,t,e,n,i){let r=ke(s);ju(t),Je(e),Je(n);const a=Math.sin(t.latitude*ae),o=Math.cos(t.latitude*ae),c=Math.sin(t.longitude*ae),l=Math.cos(t.longitude*ae),h=Math.sin(n*ae),u=Math.cos(n*ae),d=Math.sin(e*af),f=Math.cos(e*af);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],g=[c,-l,0];const m=-15*Cc(r);let S=Tl(m,p),E=Tl(m,v),_=Tl(m,g),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],R=b[0]*E[0]+b[1]*E[1]+b[2]*E[2],M=b[0]*_[0]+b[1]*_[1]+b[2]*_[2];let A=Math.hypot(R,M),P;A>0?(P=-_i*Math.atan2(M,R),P<0&&(P+=360)):P=0;let D=_i*Math.atan2(A,w),I=e,F=n;if(i){let H=D,O=Fm(i,90-D);if(D-=O,O>0&&D>3e-4){const V=Math.sin(D*ae),k=Math.cos(D*ae),Y=Math.sin(H*ae),tt=Math.cos(H*ae),J=[];for(let nt=0;nt<3;++nt)J.push((b[nt]-tt*S[nt])/Y*V+S[nt]*k);A=Math.hypot(J[0],J[1]),A>0?(I=Mm*Math.atan2(J[1],J[0]),I<0&&(I+=24)):I=0,F=_i*Math.atan2(J[2],A)}}return new yS(P,90-D,I,F)}function ju(s){if(!(s instanceof Qu))throw`Not an instance of the Observer class: ${s}`;if(Je(s.latitude),Je(s.longitude),Je(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Qu{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,ju(this)}}function ES(s){const t=ke(s).AddDays(-1/Yu),e=Cr(vi.Earth,t),n=[-e.x,-e.y,-e.z],[i,r,a]=Zu(n,t,Mn.From2000),o=ae*Fa(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ge(i,r,a,t);return Rm(h,c,l)}function wS(s,t,e,n,i){ju(e),vc(n),vc(i);const r=ke(t),a=_S(r,e),o=vu(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Zu(c,r,Mn.From2000);return bS(l,r)}function AS(s,t,e){const n=ke(s),i=Cc(n);let r=Em(t,i).pos;return Am(r,n)}function Rm(s,t,e){const n=s.x,i=s.y*t+s.z*e,r=-s.y*e+s.z*t,a=Math.hypot(n,i);let o=0;a>0&&(o=_i*Math.atan2(i,n),o<0&&(o+=360));let c=_i*Math.atan2(r,a),l=new ge(n,i,r,s.t);return new SS(l,c,o)}function cu(s){const t=Fa(s.t),e=[s.x,s.y,s.z],n=Mc(e,s.t,Mn.From2000),[i,r,a]=au(n,s.t,Mn.From2000),o=new ge(i,r,a,s.t),c=t.tobl*ae;return Rm(o,Math.cos(c),Math.sin(c))}function Or(s){const t=ke(s),e=vS(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),i=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=gS(t,i),a=Mc(r,t,Mn.Into2000);return new ge(a[0],a[1],a[2],t)}function Dm(s){const t=ke(s),e=1e-5,n=t.AddDays(-e),i=t.AddDays(+e),r=Or(n),a=Or(i);return new cs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function TS(s){const t=ke(s),e=Dm(t),n=1+_m;return new cs(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Dr(s,t,e){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=Ri),i+=o,n*=t}return i}function Rl(s,t){let e=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-e*o,n=e,e*=t,++r}return i}const la=365250,lu=0,hu=1,uu=2;function du(s){return new an(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 Cm(s,t,e){const n=e*Math.cos(t),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,e*Math.sin(t)]}function Cr(s,t){const e=t.tt/la,n=Dr(s[lu],e,!0),i=Dr(s[hu],e,!1),r=Dr(s[uu],e,!1),a=Cm(n,i,r);return du(a).ToAstroVector(t)}function fu(s,t){const e=t/la,n=Dr(s[lu],e,!0),i=Dr(s[hu],e,!1),r=Dr(s[uu],e,!1),a=Rl(s[lu],e),o=Rl(s[hu],e),c=Rl(s[uu],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),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,g=Cm(n,i,r),m=[f/la,p/la,v/la],S=du(g),E=du(m);return new zs(t,S,E)}function Ro(s,t,e,n){const i=n/(n+Ku),r=Cr(vi[e],t);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function RS(s){const t=new ge(0,0,0,s);return Ro(t,s,St.Jupiter,nu),Ro(t,s,St.Saturn,iu),Ro(t,s,St.Uranus,su),Ro(t,s,St.Neptune,ru),t}const pu=51,DS=29200,_r=146,Di=201,Is=[[-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 an{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new an(this.x,this.y,this.z)}ToAstroVector(t){return new ge(this.x,this.y,this.z,t)}static zero(){return new an(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new an(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new an(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new an(t*this.x,t*this.y,t*this.z)}div(t){return new an(this.x/t,this.y/t,this.z/t)}mean(t){return new an((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new an(-this.x,-this.y,-this.z)}}class zs{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new zs(this.tt,this.r,this.v)}sub(t){return new zs(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function CS(s){let[t,[e,n,i],[r,a,o]]=s;return new zs(t,new an(e,n,i),new an(r,a,o))}function Do(s,t,e,n){const i=n/(n+Ku),r=fu(vi[e],t);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function ea(s,t,e){const n=e.sub(s),i=n.quadrature();return n.mul(t/(i*Math.sqrt(i)))}class Pc{constructor(t){let e=new zs(t,new an(0,0,0),new an(0,0,0));this.Jupiter=Do(e,t,St.Jupiter,nu),this.Saturn=Do(e,t,St.Saturn,iu),this.Uranus=Do(e,t,St.Uranus,su),this.Neptune=Do(e,t,St.Neptune,ru),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new zs(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ea(t,Ku,this.Sun.r);return e.incr(ea(t,nu,this.Jupiter.r)),e.incr(ea(t,iu,this.Saturn.r)),e.incr(ea(t,su,this.Uranus.r)),e.incr(ea(t,ru,this.Neptune.r)),e}}class Ic{constructor(t,e,n,i){this.tt=t,this.r=e,this.v=n,this.a=i}clone(){return new Ic(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Pm{constructor(t,e){this.bary=t,this.grav=e}}function xc(s,t,e,n){return new an(t.x+s*(e.x+s*n.x/2),t.y+s*(e.y+s*n.y/2),t.z+s*(e.z+s*n.z/2))}function hf(s,t,e){return new an(t.x+s*e.x,t.y+s*e.y,t.z+s*e.z)}function mu(s,t){const e=s-t.tt,n=new Pc(s),i=xc(e,t.r,t.v,t.a),r=n.Acceleration(i).mean(t.a),a=xc(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new Ic(s,a,o,c);return new Pm(n,l)}const PS=[];function Im(s,t){const e=Math.floor(s);return e<0?0:e>=t?t-1:e}function gu(s){const t=CS(s),e=new Pc(t.tt),n=t.r.add(e.Sun.r),i=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new Ic(t.tt,n,i,r);return new Pm(e,a)}function IS(s,t){const e=Is[0][0];if(t<e||t>Is[pu-1][0])return null;const n=Im((t-e)/DS,pu-1);if(!s[n]){const r=s[n]=[];r[0]=gu(Is[n]).grav,r[Di-1]=gu(Is[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Di-1;++a)r[a]=mu(o+=_r,r[a-1]).grav;o=r[Di-1].tt;var i=[];for(i[Di-1]=r[Di-1],a=Di-2;a>0;--a)i[a]=mu(o-=_r,i[a+1]).grav;for(a=Di-2;a>0;--a){const c=a/(Di-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function uf(s,t,e){let n=gu(s);const i=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<i;++r)n=mu(r+1===i?t:n.grav.tt+e,n.grav);return n}function Lm(s,t){let e,n,i;const r=IS(PS,s.tt);if(r){const a=Im((s.tt-r[0].tt)/_r,Di-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=xc(s.tt-o.tt,o.r,o.v,l),u=hf(s.tt-o.tt,o.v,l),d=xc(s.tt-c.tt,c.r,c.v,l),f=hf(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/_r;e=h.mul(1-p).add(d.mul(p)),n=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Is[0][0]?a=uf(Is[0],s.tt,-_r):a=uf(Is[pu-1],s.tt,+_r),e=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new Pc(s.tt)),e=e.sub(i.Sun.r),n=n.sub(i.Sun.v),new cs(e.x,e.y,e.z,n.x,n.y,n.z,s)}function hs(s,t){var e=ke(t);if(s in vi)return Cr(vi[s],e);if(s===St.Pluto){const a=Lm(e);return new ge(a.x,a.y,a.z,e)}if(s===St.Sun)return new ge(0,0,0,e);if(s===St.Moon){var n=Cr(vi.Earth,e),i=Or(e);return new ge(n.x+i.x,n.y+i.y,n.z+i.z,e)}if(s===St.EMB){const a=Cr(vi.Earth,e),o=Or(e),c=1+_m;return new ge(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(s===St.SSB)return RS(e);const r=$u(s);if(r){const a=new Ju(r.dec,15*r.ra,r.dist);return Om(a,e)}throw`HelioVector: Unknown body "${s}"`}function LS(s,t){let e=t,n=0;for(let i=0;i<10;++i){const r=s(e),a=r.Length()/Yu;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class NS{constructor(t,e,n,i){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=i}Position(t){this.aberration&&(this.observerPos=hs(this.observerBody,t));const e=hs(this.targetBody,t);return new ge(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function OS(s,t,e,n){vc(n);const i=ke(s);if($u(e)){const o=hs(e,i);if(n){const l=FS(t,i),h=new ge(o.x-l.x,o.y-l.y,o.z-l.z,i),u=Yu/h.Length();return new ge(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=hs(t,i);return new ge(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new ge(0,0,0,i):r=hs(t,i);const a=new NS(t,e,n,r);return LS(o=>a.Position(o),i)}function vu(s,t,e){vc(e);const n=ke(t);switch(s){case St.Earth:return new ge(0,0,0,n);case St.Moon:return Or(n);default:const i=OS(n,St.Earth,s,e);return i.t=n,i}}function US(s,t){return new cs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,t)}function FS(s,t){const e=ke(t);switch(s){case St.Sun:return new cs(0,0,0,0,0,0,e);case St.SSB:const n=new Pc(e.tt);return new cs(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case St.Mercury:case St.Venus:case St.Earth:case St.Mars:case St.Jupiter:case St.Saturn:case St.Uranus:case St.Neptune:const i=fu(vi[s],e.tt);return US(i,e);case St.Pluto:return Lm(e);case St.Moon:case St.EMB:const r=fu(vi.Earth,e.tt),a=s==St.Moon?Dm(e):TS(e);return new cs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if($u(s)){const o=hs(s,e);return new cs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${s}"`}}function zS(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function kS(s,t,e){if(s===St.Earth||t===St.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=ke(e),i=vu(s,n,!1),r=cu(i),a=vu(t,n,!1),o=cu(a);return zS(r.elon-o.elon)}function BS(s,t,e,n){let i,r=0,a=0,o=0;switch(s){case St.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case St.Venus:t<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case St.Mars:i=-1.52,r=1.6;break;case St.Jupiter:i=-9.4,r=.5;break;case St.Uranus:i=-7.19,r=.25;break;case St.Neptune:i=-6.87;break;case St.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=t/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function HS(s,t,e,n,i){const r=cu(n),a=ae*28.06,o=ae*(169.51+382e-7*i.tt),c=ae*r.elat,l=ae*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(t*e),{mag:d,ring_tilt:_i*h}}function GS(s,t,e){let n=s*ae,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/As;let c=e/o;return a+=5*Math.log10(t*c),a}class VS{constructor(t,e,n,i,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ae*n))/2}}function Nm(s,t){if(s===St.Earth)throw"The illumination of the Earth is not defined.";const e=ke(t),n=Cr(vi.Earth,e);let i,r,a,o;s===St.Sun?(a=new ge(-n.x,-n.y,-n.z,e),r=new ge(0,0,0,e),i=0):(s===St.Moon?(a=Or(e),r=new ge(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=hs(s,t),a=new ge(r.x-n.x,r.y-n.y,r.z-n.z,e)),i=cS(a,r));let c=a.Length(),l=r.Length(),h;if(s===St.Sun)o=rS+5*Math.log10(c);else if(s===St.Moon)o=GS(i,l,c);else if(s===St.Saturn){const u=HS(i,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=BS(s,i,l,c);return new VS(e,o,i,l,c,a,r,h)}function WS(s){return kS(St.Moon,St.Sun,s)}var df;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(df||(df={}));function XS(s,t){return new ds([[t.rot[0][0]*s.rot[0][0]+t.rot[1][0]*s.rot[0][1]+t.rot[2][0]*s.rot[0][2],t.rot[0][1]*s.rot[0][0]+t.rot[1][1]*s.rot[0][1]+t.rot[2][1]*s.rot[0][2],t.rot[0][2]*s.rot[0][0]+t.rot[1][2]*s.rot[0][1]+t.rot[2][2]*s.rot[0][2]],[t.rot[0][0]*s.rot[1][0]+t.rot[1][0]*s.rot[1][1]+t.rot[2][0]*s.rot[1][2],t.rot[0][1]*s.rot[1][0]+t.rot[1][1]*s.rot[1][1]+t.rot[2][1]*s.rot[1][2],t.rot[0][2]*s.rot[1][0]+t.rot[1][2]*s.rot[1][1]+t.rot[2][2]*s.rot[1][2]],[t.rot[0][0]*s.rot[2][0]+t.rot[1][0]*s.rot[2][1]+t.rot[2][0]*s.rot[2][2],t.rot[0][1]*s.rot[2][0]+t.rot[1][1]*s.rot[2][1]+t.rot[2][1]*s.rot[2][2],t.rot[0][2]*s.rot[2][0]+t.rot[1][2]*s.rot[2][1]+t.rot[2][2]*s.rot[2][2]]])}function Om(s,t){t=ke(t);const e=s.lat*ae,n=s.lon*ae,i=s.dist*Math.cos(e);return new ge(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(e),t)}function Um(s){const t=qS(s);return new ou(t.lon/15,t.lat,t.dist,s)}function qS(s){const t=s.x*s.x+s.y*s.y,e=Math.sqrt(t+s.z*s.z);let n,i;if(t===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=_i*Math.atan2(s.y,s.x),i<0&&(i+=360),n=_i*Math.atan2(s.z,Math.sqrt(t));return new Ju(n,i,e)}function Fm(s,t){let e;if(Je(t),t<-90||t>90)return 0;if(s==="normal"||s==="jplhor"){let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ae)/60,s==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!s)e=0;else throw`Invalid refraction option: ${s}`;return e}function Jo(s,t){return new ge(s.rot[0][0]*t.x+s.rot[1][0]*t.y+s.rot[2][0]*t.z,s.rot[0][1]*t.x+s.rot[1][1]*t.y+s.rot[2][1]*t.z,s.rot[0][2]*t.x+s.rot[1][2]*t.y+s.rot[2][2]*t.z,t.t)}function YS(){return new ds([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function KS(){return new ds([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function $S(s){s=ke(s);const t=bm(s,Mn.From2000),e=wm(s,Mn.From2000);return XS(t,e)}function ZS(s){const e=Fa(ke(s)).tobl*ae,n=Math.cos(e),i=Math.sin(e);return new ds([[1,0,0],[0,+n,+i],[0,-i,+n]])}var ff;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(ff||(ff={}));var pf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(pf||(pf={}));const JS=["Venus","Mars","Jupiter","Saturn"];function zm(s){return new Qu(s.lat,s.lng,s.elevationM)}function Lc(s,t,e,n,i=!0){const r=Tm(e,zm(n),s,t,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class ma{up;north;west;constructor(t,e){const n=ke(t),i=Math.sin(e.lat*Ci),r=Math.cos(e.lat*Ci),a=Math.sin(e.lng*Ci),o=Math.cos(e.lng*Ci),c=-15*xS(n);this.up=ma.spin(c,[r*o,r*a,i]),this.north=ma.spin(c,[-i*o,-i*a,r]),this.west=ma.spin(c,[a,-o,0])}position(t,e){const n=Math.sin(e*Ci),i=Math.cos(e*Ci),r=Math.sin(t*gf),a=Math.cos(t*gf),o=i*a,c=i*r,l=n,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=-mf*Math.atan2(d,u),p<0&&(p+=360));let v=mf*Math.atan2(f,h);return v-=Fm("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,n,i]){const r=Math.cos(t*Ci),a=Math.sin(t*Ci);return[r*e+a*n,r*n-a*e,i]}}const Ci=Math.PI/180,mf=180/Math.PI,gf=15*Ci;function Dl(s,t,e){const n=zm(e),i=wS(St[s],t,n,!0,!0),r=Tm(t,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Cl(s,t){return Nm(St[s],t).mag}function jS(s){const t=WS(s),e=Nm(St.Moon,s);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const QS=2e3,tb=3,eb=20;function vf(s,t,e){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??QS,r=s.month??(n?1:tb),a=s.day??(n?1:eb),o=e??Math.round(t/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Ts{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Ts.patch(e.fragmentShader)}}static patch(t){return t.replace(Ts.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5090
+ */const Yu=173.1446326846693,As=14959787069098932e-8,ae=.017453292519943295,af=.26179938779914946,yi=57.29577951308232,Mm=3.819718634205488,nS=365.24217,of=new Date("2000-01-01T12:00:00Z"),Di=2*Math.PI,es=3600*(180/Math.PI),xr=484813681109536e-20,xm=10800*60,iS=2*xm,cf=7292115e-11,sS=xm/Math.PI,rS=-.17-5*Math.log10(sS),tu=.996647180302104,aS=tu*tu,eu=6378.1366,oS=eu/As,_m=81.30056,Ku=.0002959122082855911,nu=2825345909524226e-22,iu=8459715185680659e-23,su=1292024916781969e-23,ru=1524358900784276e-23;function vc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function Je(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function fr(s){return s-Math.floor(s)}function cS(s,t){const e=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*t.x+s.y*t.y+s.z*t.z)/Math.sqrt(e*n);return i<=-1?180:i>=1?0:yi*Math.acos(i)}var St;(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"})(St||(St={}));const lS=[St.Star1,St.Star2,St.Star3,St.Star4,St.Star5,St.Star6,St.Star7,St.Star8],hS=[{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 uS(s){const t=lS.indexOf(s);return t>=0?hS[t]:null}function $u(s){const t=uS(s);return t&&t.dist>0?t:null}var Mn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(Mn||(Mn={}));const Mi={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 dS(s){var t,e,n,i,r,a,o;const c=2e3+(s-14)/nS;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,i=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-i/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,o=n*i,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,i=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*i+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,i=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*i):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,i=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let fS=dS;function lf(s){return s+fS(s)/86400}class Rr{constructor(t){if(t instanceof Rr){this.date=t.date,this.ut=t.ut,this.tt=t.tt;return}const e=1e3*3600*24;if(t instanceof Date&&Number.isFinite(t.getTime())){this.date=t,this.ut=(t.getTime()-of.getTime())/e,this.tt=lf(this.ut);return}if(Number.isFinite(t)){this.date=new Date(of.getTime()+t*e),this.ut=t,this.tt=lf(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(t){let e=new Rr(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new Rr(this.ut+t)}}function ke(s){return s instanceof Rr?s:new Rr(s)}function pS(s){function t(d){return d%iS*xr}const e=s.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),i=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function ym(s){var t=s.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var Ao;function Fa(s){if(!Ao||Math.abs(Ao.tt-s.tt)>1e-6){const t=pS(s),e=ym(s),n=e+t.deps/3600;Ao={tt:s.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ae)/15,mobl:e,tobl:n}}return Ao}function mS(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[t[0],t[1]*n-t[2]*i,t[1]*i+t[2]*n]}function gS(s,t){return mS(ym(s),t)}function vS(s){const t=s.tt/36525;function e(Tt,xt){const Nt=[];let Ot;for(Ot=0;Ot<=xt-Tt;++Ot)Nt.push(0);return{min:Tt,array:Nt}}function n(Tt,xt,Nt,Ot){const Ut=[];for(let ee=0;ee<=xt-Tt;++ee)Ut.push(e(Nt,Ot));return{min:Tt,array:Ut}}function i(Tt,xt,Nt){const Ot=Tt.array[xt-Tt.min];return Ot.array[Nt-Ot.min]}function r(Tt,xt,Nt,Ot){const Ut=Tt.array[xt-Tt.min];Ut.array[Nt-Ut.min]=Ot}let a,o,c,l,h,u,d,f,p,v,g,m,S,E,_,b,w,R,M,A,P,D,I,F=n(-6,6,1,4),H=n(-6,6,1,4);function O(Tt,xt){return i(F,Tt,xt)}function V(Tt,xt){return i(H,Tt,xt)}function k(Tt,xt,Nt){return r(F,Tt,xt,Nt)}function Y(Tt,xt,Nt){return r(H,Tt,xt,Nt)}function tt(Tt,xt,Nt,Ot,Ut){Ut(Tt*Nt-xt*Ot,xt*Nt+Tt*Ot)}function J(Tt){return Math.sin(Di*Tt)}d=t*t,p=0,I=0,g=0,m=3422.7;var nt=J(.19833+.05611*t),at=J(.27869+.04508*t),Ht=J(.16827-.36903*t),$t=J(.34734-5.37261*t),Bt=J(.10498-5.37899*t),K=J(.42681-.41855*t),rt=J(.14943-5.37511*t);for(R=.84*nt+.31*at+14.27*Ht+7.26*$t+.28*Bt+.24*K,M=2.94*nt+.31*at+14.27*Ht+9.34*$t+1.12*Bt+.83*K,A=-6.4*nt-1.89*K,P=.21*nt+.31*at+14.27*Ht-88.7*$t-15.3*Bt+.24*K-1.86*rt,D=R-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),S=Di*fr(.60643382+1336.85522467*t-313e-8*d)+R/es,E=Di*fr(.37489701+1325.55240982*t+2565e-8*d)+M/es,_=Di*fr(.99312619+99.99735956*t-44e-8*d)+A/es,b=Di*fr(.25909118+1342.2278298*t-892e-8*d)+P/es,w=Di*fr(.82736186+1236.85308708*t-397e-8*d)+D/es,h=1;h<=4;++h){switch(h){case 1:c=E,o=4,l=1.000002208;break;case 2:c=_,o=3,l=.997504612-.002495388*t;break;case 3:c=b,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),Y(0,h,0),Y(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(O(u-1,h),V(u-1,h),O(1,h),V(1,h),(Tt,xt)=>(k(u,h,Tt),Y(u,h,xt)));for(u=1;u<=o;++u)k(-u,h,O(u,h)),Y(-u,h,-V(u,h))}function it(Tt,xt,Nt,Ot){for(var Ut={x:1,y:0},ee=[0,Tt,xt,Nt,Ot],ne=1;ne<=4;++ne)ee[ne]!==0&&tt(Ut.x,Ut.y,O(ee[ne],ne),V(ee[ne],ne),(Te,ve)=>(Ut.x=Te,Ut.y=ve));return Ut}function B(Tt,xt,Nt,Ot,Ut,ee,ne,Te){var ve=it(Ut,ee,ne,Te);p+=Tt*ve.y,I+=xt*ve.y,g+=Nt*ve.x,m+=Ot*ve.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 Et(Tt,xt,Nt,Ot,Ut){return Tt*it(xt,Nt,Ot,Ut).y}v=0,v+=Et(-526.069,0,0,1,-2),v+=Et(-3.352,0,0,1,-4),v+=Et(44.297,1,0,1,-2),v+=Et(-6,1,0,1,-4),v+=Et(20.599,-1,0,1,0),v+=Et(-30.598,-1,0,1,-2),v+=Et(-24.649,-2,0,1,0),v+=Et(-2,-2,0,1,-2),v+=Et(-22.571,0,1,1,-2),v+=Et(10.985,0,-1,1,-2),p+=.82*J(.7736-62.5512*t)+.31*J(.0466-125.1025*t)+.35*J(.5785-25.1042*t)+.66*J(.4591+1335.8075*t)+.64*J(.313-91.568*t)+1.14*J(.148+1331.2898*t)+.21*J(.5918+1056.5859*t)+.44*J(.5784+1322.8595*t)+.24*J(.2275-5.7374*t)+.28*J(.2965+2.6929*t)+.33*J(.3132+6.3368*t),a=b+I/es;let It=(1.000002708+139.978*f)*(18518.511+1.189+g)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Di*fr((S+p/es)/Di),geo_eclip_lat:Math.PI/(180*3600)*It,distance_au:es*oS/(.999953253*m)}}function Sm(s,t){return[s.rot[0][0]*t[0]+s.rot[1][0]*t[1]+s.rot[2][0]*t[2],s.rot[0][1]*t[0]+s.rot[1][1]*t[1]+s.rot[2][1]*t[2],s.rot[0][2]*t[0]+s.rot[1][2]*t[1]+s.rot[2][2]*t[2]]}function Mc(s,t,e){const n=bm(t,e);return Sm(n,s)}function bm(s,t){const e=s.tt/36525;let n=84381.406,i=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=xr,i*=xr,r*=xr,a*=xr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),p=Math.cos(a),v=p*h-l*f*d,g=p*l*c+f*d*h*c-o*f*u,m=p*l*o+f*d*h*o+c*f*u,S=-f*h-l*p*d,E=-f*l*c+p*d*h*c-o*p*u,_=-f*l*o+p*d*h*o+c*p*u,b=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(t===Mn.Into2000)return new ds([[v,g,m],[S,E,_],[b,w,R]]);if(t===Mn.From2000)return new ds([[v,S,b],[g,E,w],[m,_,R]]);throw"Invalid precess direction"}function MS(s){const t=.779057273264+.00273781191135448*s.ut,e=s.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let To;function Cc(s){if(!To||To.tt!==s.tt){const t=s.tt/36525;let e=15*Fa(s).ee;const n=MS(s);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),To={tt:s.tt,st:r}}return To.st}function xS(s){const t=ke(s);return Cc(t)}function Em(s,t){const e=s.latitude*ae,n=Math.sin(e),i=Math.cos(e),r=1/Math.hypot(i,tu*n),a=aS*r,o=s.height/1e3,c=eu*r+o,l=eu*a+o,h=(15*t+s.longitude)*ae,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/As,c*i*u/As,l*n/As],vel:[-cf*c*i*u*86400/As,cf*c*i*d*86400/As,0]}}function au(s,t,e){const n=wm(t,e);return Sm(n,s)}function wm(s,t){const e=Fa(s),n=e.mobl*ae,i=e.tobl*ae,r=e.dpsi*xr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,p=-u*o,v=u*c,g=h*a*c+o*l,m=h*o*c-a*l,S=u*l,E=h*a*l-o*c,_=h*o*l+a*c;if(t===Mn.From2000)return new ds([[d,v,S],[f,g,E],[p,m,_]]);if(t===Mn.Into2000)return new ds([[d,f,p],[v,g,m],[S,E,_]]);throw"Invalid precess direction"}function Zu(s,t,e){return e===Mn.Into2000?Mc(au(s,t,e),t,e):au(Mc(s,t,e),t,e)}function _S(s,t){const e=Cc(s),n=Em(t,e).pos;return Zu(n,s,Mn.Into2000)}class ge{constructor(t,e,n,i){this.x=t,this.y=e,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class cs{constructor(t,e,n,i,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class Ju{constructor(t,e,n){this.lat=Je(t),this.lon=Je(e),this.dist=Je(n)}}class ou{constructor(t,e,n,i){this.ra=Je(t),this.dec=Je(e),this.dist=Je(n),this.vec=i}}class ds{constructor(t){this.rot=t}}class yS{constructor(t,e,n,i){this.azimuth=Je(t),this.altitude=Je(e),this.ra=Je(n),this.dec=Je(i)}}class SS{constructor(t,e,n){this.vec=t,this.elat=Je(e),this.elon=Je(n)}}function Am(s,t){return new ge(s[0],s[1],s[2],t)}function bS(s,t){const e=Am(s,t),n=e.x*e.x+e.y*e.y,i=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new ou(0,e.z<0?-90:90,i,e)}let r=Mm*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=yi*Math.atan2(s[2],Math.sqrt(n));return new ou(r,a,i,e)}function Tl(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[n*t[0]+i*t[1],n*t[1]-i*t[0],t[2]]}function Tm(s,t,e,n,i){let r=ke(s);ju(t),Je(e),Je(n);const a=Math.sin(t.latitude*ae),o=Math.cos(t.latitude*ae),c=Math.sin(t.longitude*ae),l=Math.cos(t.longitude*ae),h=Math.sin(n*ae),u=Math.cos(n*ae),d=Math.sin(e*af),f=Math.cos(e*af);let p=[o*l,o*c,a],v=[-a*l,-a*c,o],g=[c,-l,0];const m=-15*Cc(r);let S=Tl(m,p),E=Tl(m,v),_=Tl(m,g),b=[u*f,u*d,h];const w=b[0]*S[0]+b[1]*S[1]+b[2]*S[2],R=b[0]*E[0]+b[1]*E[1]+b[2]*E[2],M=b[0]*_[0]+b[1]*_[1]+b[2]*_[2];let A=Math.hypot(R,M),P;A>0?(P=-yi*Math.atan2(M,R),P<0&&(P+=360)):P=0;let D=yi*Math.atan2(A,w),I=e,F=n;if(i){let H=D,O=Fm(i,90-D);if(D-=O,O>0&&D>3e-4){const V=Math.sin(D*ae),k=Math.cos(D*ae),Y=Math.sin(H*ae),tt=Math.cos(H*ae),J=[];for(let nt=0;nt<3;++nt)J.push((b[nt]-tt*S[nt])/Y*V+S[nt]*k);A=Math.hypot(J[0],J[1]),A>0?(I=Mm*Math.atan2(J[1],J[0]),I<0&&(I+=24)):I=0,F=yi*Math.atan2(J[2],A)}}return new yS(P,90-D,I,F)}function ju(s){if(!(s instanceof Qu))throw`Not an instance of the Observer class: ${s}`;if(Je(s.latitude),Je(s.longitude),Je(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Qu{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,ju(this)}}function ES(s){const t=ke(s).AddDays(-1/Yu),e=Cr(Mi.Earth,t),n=[-e.x,-e.y,-e.z],[i,r,a]=Zu(n,t,Mn.From2000),o=ae*Fa(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ge(i,r,a,t);return Rm(h,c,l)}function wS(s,t,e,n,i){ju(e),vc(n),vc(i);const r=ke(t),a=_S(r,e),o=vu(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Zu(c,r,Mn.From2000);return bS(l,r)}function AS(s,t,e){const n=ke(s),i=Cc(n);let r=Em(t,i).pos;return Am(r,n)}function Rm(s,t,e){const n=s.x,i=s.y*t+s.z*e,r=-s.y*e+s.z*t,a=Math.hypot(n,i);let o=0;a>0&&(o=yi*Math.atan2(i,n),o<0&&(o+=360));let c=yi*Math.atan2(r,a),l=new ge(n,i,r,s.t);return new SS(l,c,o)}function cu(s){const t=Fa(s.t),e=[s.x,s.y,s.z],n=Mc(e,s.t,Mn.From2000),[i,r,a]=au(n,s.t,Mn.From2000),o=new ge(i,r,a,s.t),c=t.tobl*ae;return Rm(o,Math.cos(c),Math.sin(c))}function Or(s){const t=ke(s),e=vS(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),i=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=gS(t,i),a=Mc(r,t,Mn.Into2000);return new ge(a[0],a[1],a[2],t)}function Dm(s){const t=ke(s),e=1e-5,n=t.AddDays(-e),i=t.AddDays(+e),r=Or(n),a=Or(i);return new cs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function TS(s){const t=ke(s),e=Dm(t),n=1+_m;return new cs(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Dr(s,t,e){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=Di),i+=o,n*=t}return i}function Rl(s,t){let e=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-e*o,n=e,e*=t,++r}return i}const la=365250,lu=0,hu=1,uu=2;function du(s){return new an(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 Cm(s,t,e){const n=e*Math.cos(t),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,e*Math.sin(t)]}function Cr(s,t){const e=t.tt/la,n=Dr(s[lu],e,!0),i=Dr(s[hu],e,!1),r=Dr(s[uu],e,!1),a=Cm(n,i,r);return du(a).ToAstroVector(t)}function fu(s,t){const e=t/la,n=Dr(s[lu],e,!0),i=Dr(s[hu],e,!1),r=Dr(s[uu],e,!1),a=Rl(s[lu],e),o=Rl(s[hu],e),c=Rl(s[uu],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),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,g=Cm(n,i,r),m=[f/la,p/la,v/la],S=du(g),E=du(m);return new zs(t,S,E)}function Ro(s,t,e,n){const i=n/(n+Ku),r=Cr(Mi[e],t);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function RS(s){const t=new ge(0,0,0,s);return Ro(t,s,St.Jupiter,nu),Ro(t,s,St.Saturn,iu),Ro(t,s,St.Uranus,su),Ro(t,s,St.Neptune,ru),t}const pu=51,DS=29200,_r=146,Ci=201,Is=[[-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 an{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new an(this.x,this.y,this.z)}ToAstroVector(t){return new ge(this.x,this.y,this.z,t)}static zero(){return new an(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new an(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new an(this.x-t.x,this.y-t.y,this.z-t.z)}incr(t){this.x+=t.x,this.y+=t.y,this.z+=t.z}decr(t){this.x-=t.x,this.y-=t.y,this.z-=t.z}mul(t){return new an(t*this.x,t*this.y,t*this.z)}div(t){return new an(this.x/t,this.y/t,this.z/t)}mean(t){return new an((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new an(-this.x,-this.y,-this.z)}}class zs{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new zs(this.tt,this.r,this.v)}sub(t){return new zs(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function CS(s){let[t,[e,n,i],[r,a,o]]=s;return new zs(t,new an(e,n,i),new an(r,a,o))}function Do(s,t,e,n){const i=n/(n+Ku),r=fu(Mi[e],t);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function ea(s,t,e){const n=e.sub(s),i=n.quadrature();return n.mul(t/(i*Math.sqrt(i)))}class Pc{constructor(t){let e=new zs(t,new an(0,0,0),new an(0,0,0));this.Jupiter=Do(e,t,St.Jupiter,nu),this.Saturn=Do(e,t,St.Saturn,iu),this.Uranus=Do(e,t,St.Uranus,su),this.Neptune=Do(e,t,St.Neptune,ru),this.Jupiter.r.decr(e.r),this.Jupiter.v.decr(e.v),this.Saturn.r.decr(e.r),this.Saturn.v.decr(e.v),this.Uranus.r.decr(e.r),this.Uranus.v.decr(e.v),this.Neptune.r.decr(e.r),this.Neptune.v.decr(e.v),this.Sun=new zs(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=ea(t,Ku,this.Sun.r);return e.incr(ea(t,nu,this.Jupiter.r)),e.incr(ea(t,iu,this.Saturn.r)),e.incr(ea(t,su,this.Uranus.r)),e.incr(ea(t,ru,this.Neptune.r)),e}}class Ic{constructor(t,e,n,i){this.tt=t,this.r=e,this.v=n,this.a=i}clone(){return new Ic(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class Pm{constructor(t,e){this.bary=t,this.grav=e}}function xc(s,t,e,n){return new an(t.x+s*(e.x+s*n.x/2),t.y+s*(e.y+s*n.y/2),t.z+s*(e.z+s*n.z/2))}function hf(s,t,e){return new an(t.x+s*e.x,t.y+s*e.y,t.z+s*e.z)}function mu(s,t){const e=s-t.tt,n=new Pc(s),i=xc(e,t.r,t.v,t.a),r=n.Acceleration(i).mean(t.a),a=xc(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new Ic(s,a,o,c);return new Pm(n,l)}const PS=[];function Im(s,t){const e=Math.floor(s);return e<0?0:e>=t?t-1:e}function gu(s){const t=CS(s),e=new Pc(t.tt),n=t.r.add(e.Sun.r),i=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new Ic(t.tt,n,i,r);return new Pm(e,a)}function IS(s,t){const e=Is[0][0];if(t<e||t>Is[pu-1][0])return null;const n=Im((t-e)/DS,pu-1);if(!s[n]){const r=s[n]=[];r[0]=gu(Is[n]).grav,r[Ci-1]=gu(Is[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Ci-1;++a)r[a]=mu(o+=_r,r[a-1]).grav;o=r[Ci-1].tt;var i=[];for(i[Ci-1]=r[Ci-1],a=Ci-2;a>0;--a)i[a]=mu(o-=_r,i[a+1]).grav;for(a=Ci-2;a>0;--a){const c=a/(Ci-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function uf(s,t,e){let n=gu(s);const i=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<i;++r)n=mu(r+1===i?t:n.grav.tt+e,n.grav);return n}function Lm(s,t){let e,n,i;const r=IS(PS,s.tt);if(r){const a=Im((s.tt-r[0].tt)/_r,Ci-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=xc(s.tt-o.tt,o.r,o.v,l),u=hf(s.tt-o.tt,o.v,l),d=xc(s.tt-c.tt,c.r,c.v,l),f=hf(s.tt-c.tt,c.v,l),p=(s.tt-o.tt)/_r;e=h.mul(1-p).add(d.mul(p)),n=u.mul(1-p).add(f.mul(p))}else{let a;s.tt<Is[0][0]?a=uf(Is[0],s.tt,-_r):a=uf(Is[pu-1],s.tt,+_r),e=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new Pc(s.tt)),e=e.sub(i.Sun.r),n=n.sub(i.Sun.v),new cs(e.x,e.y,e.z,n.x,n.y,n.z,s)}function hs(s,t){var e=ke(t);if(s in Mi)return Cr(Mi[s],e);if(s===St.Pluto){const a=Lm(e);return new ge(a.x,a.y,a.z,e)}if(s===St.Sun)return new ge(0,0,0,e);if(s===St.Moon){var n=Cr(Mi.Earth,e),i=Or(e);return new ge(n.x+i.x,n.y+i.y,n.z+i.z,e)}if(s===St.EMB){const a=Cr(Mi.Earth,e),o=Or(e),c=1+_m;return new ge(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(s===St.SSB)return RS(e);const r=$u(s);if(r){const a=new Ju(r.dec,15*r.ra,r.dist);return Om(a,e)}throw`HelioVector: Unknown body "${s}"`}function LS(s,t){let e=t,n=0;for(let i=0;i<10;++i){const r=s(e),a=r.Length()/Yu;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class NS{constructor(t,e,n,i){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=i}Position(t){this.aberration&&(this.observerPos=hs(this.observerBody,t));const e=hs(this.targetBody,t);return new ge(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function OS(s,t,e,n){vc(n);const i=ke(s);if($u(e)){const o=hs(e,i);if(n){const l=FS(t,i),h=new ge(o.x-l.x,o.y-l.y,o.z-l.z,i),u=Yu/h.Length();return new ge(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=hs(t,i);return new ge(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new ge(0,0,0,i):r=hs(t,i);const a=new NS(t,e,n,r);return LS(o=>a.Position(o),i)}function vu(s,t,e){vc(e);const n=ke(t);switch(s){case St.Earth:return new ge(0,0,0,n);case St.Moon:return Or(n);default:const i=OS(n,St.Earth,s,e);return i.t=n,i}}function US(s,t){return new cs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,t)}function FS(s,t){const e=ke(t);switch(s){case St.Sun:return new cs(0,0,0,0,0,0,e);case St.SSB:const n=new Pc(e.tt);return new cs(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case St.Mercury:case St.Venus:case St.Earth:case St.Mars:case St.Jupiter:case St.Saturn:case St.Uranus:case St.Neptune:const i=fu(Mi[s],e.tt);return US(i,e);case St.Pluto:return Lm(e);case St.Moon:case St.EMB:const r=fu(Mi.Earth,e.tt),a=s==St.Moon?Dm(e):TS(e);return new cs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if($u(s)){const o=hs(s,e);return new cs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${s}"`}}function zS(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function kS(s,t,e){if(s===St.Earth||t===St.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=ke(e),i=vu(s,n,!1),r=cu(i),a=vu(t,n,!1),o=cu(a);return zS(r.elon-o.elon)}function BS(s,t,e,n){let i,r=0,a=0,o=0;switch(s){case St.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case St.Venus:t<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case St.Mars:i=-1.52,r=1.6;break;case St.Jupiter:i=-9.4,r=.5;break;case St.Uranus:i=-7.19,r=.25;break;case St.Neptune:i=-6.87;break;case St.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=t/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function HS(s,t,e,n,i){const r=cu(n),a=ae*28.06,o=ae*(169.51+382e-7*i.tt),c=ae*r.elat,l=ae*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(t*e),{mag:d,ring_tilt:yi*h}}function GS(s,t,e){let n=s*ae,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/As;let c=e/o;return a+=5*Math.log10(t*c),a}class VS{constructor(t,e,n,i,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ae*n))/2}}function Nm(s,t){if(s===St.Earth)throw"The illumination of the Earth is not defined.";const e=ke(t),n=Cr(Mi.Earth,e);let i,r,a,o;s===St.Sun?(a=new ge(-n.x,-n.y,-n.z,e),r=new ge(0,0,0,e),i=0):(s===St.Moon?(a=Or(e),r=new ge(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=hs(s,t),a=new ge(r.x-n.x,r.y-n.y,r.z-n.z,e)),i=cS(a,r));let c=a.Length(),l=r.Length(),h;if(s===St.Sun)o=rS+5*Math.log10(c);else if(s===St.Moon)o=GS(i,l,c);else if(s===St.Saturn){const u=HS(i,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=BS(s,i,l,c);return new VS(e,o,i,l,c,a,r,h)}function WS(s){return kS(St.Moon,St.Sun,s)}var df;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(df||(df={}));function XS(s,t){return new ds([[t.rot[0][0]*s.rot[0][0]+t.rot[1][0]*s.rot[0][1]+t.rot[2][0]*s.rot[0][2],t.rot[0][1]*s.rot[0][0]+t.rot[1][1]*s.rot[0][1]+t.rot[2][1]*s.rot[0][2],t.rot[0][2]*s.rot[0][0]+t.rot[1][2]*s.rot[0][1]+t.rot[2][2]*s.rot[0][2]],[t.rot[0][0]*s.rot[1][0]+t.rot[1][0]*s.rot[1][1]+t.rot[2][0]*s.rot[1][2],t.rot[0][1]*s.rot[1][0]+t.rot[1][1]*s.rot[1][1]+t.rot[2][1]*s.rot[1][2],t.rot[0][2]*s.rot[1][0]+t.rot[1][2]*s.rot[1][1]+t.rot[2][2]*s.rot[1][2]],[t.rot[0][0]*s.rot[2][0]+t.rot[1][0]*s.rot[2][1]+t.rot[2][0]*s.rot[2][2],t.rot[0][1]*s.rot[2][0]+t.rot[1][1]*s.rot[2][1]+t.rot[2][1]*s.rot[2][2],t.rot[0][2]*s.rot[2][0]+t.rot[1][2]*s.rot[2][1]+t.rot[2][2]*s.rot[2][2]]])}function Om(s,t){t=ke(t);const e=s.lat*ae,n=s.lon*ae,i=s.dist*Math.cos(e);return new ge(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(e),t)}function Um(s){const t=qS(s);return new ou(t.lon/15,t.lat,t.dist,s)}function qS(s){const t=s.x*s.x+s.y*s.y,e=Math.sqrt(t+s.z*s.z);let n,i;if(t===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=yi*Math.atan2(s.y,s.x),i<0&&(i+=360),n=yi*Math.atan2(s.z,Math.sqrt(t));return new Ju(n,i,e)}function Fm(s,t){let e;if(Je(t),t<-90||t>90)return 0;if(s==="normal"||s==="jplhor"){let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ae)/60,s==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!s)e=0;else throw`Invalid refraction option: ${s}`;return e}function Jo(s,t){return new ge(s.rot[0][0]*t.x+s.rot[1][0]*t.y+s.rot[2][0]*t.z,s.rot[0][1]*t.x+s.rot[1][1]*t.y+s.rot[2][1]*t.z,s.rot[0][2]*t.x+s.rot[1][2]*t.y+s.rot[2][2]*t.z,t.t)}function YS(){return new ds([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function KS(){return new ds([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function $S(s){s=ke(s);const t=bm(s,Mn.From2000),e=wm(s,Mn.From2000);return XS(t,e)}function ZS(s){const e=Fa(ke(s)).tobl*ae,n=Math.cos(e),i=Math.sin(e);return new ds([[1,0,0],[0,+n,+i],[0,-i,+n]])}var ff;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(ff||(ff={}));var pf;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(pf||(pf={}));const JS=["Venus","Mars","Jupiter","Saturn"];function zm(s){return new Qu(s.lat,s.lng,s.elevationM)}function Lc(s,t,e,n,i=!0){const r=Tm(e,zm(n),s,t,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}class ma{up;north;west;constructor(t,e){const n=ke(t),i=Math.sin(e.lat*Pi),r=Math.cos(e.lat*Pi),a=Math.sin(e.lng*Pi),o=Math.cos(e.lng*Pi),c=-15*xS(n);this.up=ma.spin(c,[r*o,r*a,i]),this.north=ma.spin(c,[-i*o,-i*a,r]),this.west=ma.spin(c,[a,-o,0])}position(t,e){const n=Math.sin(e*Pi),i=Math.cos(e*Pi),r=Math.sin(t*gf),a=Math.cos(t*gf),o=i*a,c=i*r,l=n,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=-mf*Math.atan2(d,u),p<0&&(p+=360));let v=mf*Math.atan2(f,h);return v-=Fm("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,n,i]){const r=Math.cos(t*Pi),a=Math.sin(t*Pi);return[r*e+a*n,r*n-a*e,i]}}const Pi=Math.PI/180,mf=180/Math.PI,gf=15*Pi;function Dl(s,t,e){const n=zm(e),i=wS(St[s],t,n,!0,!0),r=Tm(t,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Cl(s,t){return Nm(St[s],t).mag}function jS(s){const t=WS(s),e=Nm(St.Moon,s);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const QS=2e3,tb=3,eb=20;function vf(s,t,e){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??QS,r=s.month??(n?1:tb),a=s.day??(n?1:eb),o=e??Math.round(t/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Ts{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Ts.patch(e.fragmentShader)}}static patch(t){return t.replace(Ts.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
5091
5091
  // Outside the inscribed circle there is no star at all — this is what kills the corners.
5092
5092
  if ( distanceFromCentre > ${Ts.RIM.toFixed(2)} ) discard;
5093
5093
  float glare = 1.0 - smoothstep( ${Ts.CORE.toFixed(2)}, ${Ts.RIM.toFixed(2)}, distanceFromCentre );
5094
- vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const nb=[{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}],ha=64,Ke=ha+1,Mf=512,ib=900,sb=700/900,rb=0,ab=.01;function ob(s,t,e){return{north:Ni(0,-e,s,t).lat,south:Ni(0,e,s,t).lat,east:Ni(e,0,s,t).lng,west:Ni(-e,0,s,t).lng}}async function cb(s,t,e,n=ib){const i=n,r=n*sb,a=ob(s,t,i),o={width:Ke,height:Ke},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:Mf,height:Mf})]),h=Math.floor(Ke/2),u=c.heights[h*Ke+h],d=new Float32Array(Ke*Ke*3),f=new Float32Array(Ke*Ke*2),p=new Float32Array(Ke*Ke*4);for(let b=0;b<Ke;b++){const w=b/(Ke-1),R=a.north+(a.south-a.north)*w;for(let M=0;M<Ke;M++){const A=M/(Ke-1),P=a.west+(a.east-a.west)*A,{x:D,z:I}=tn(R,P,s,t),F=c.heights[b*Ke+M],H=Math.max(Math.abs(D),Math.abs(I)),O=1-lb((H-r)/(i-r),0,1),V=rb+ab+(F-u),k=b*Ke+M;d[k*3]=D,d[k*3+1]=V,d[k*3+2]=I;const Y=Ep(l.bounds,P,R);f[k*2]=Y.x,f[k*2+1]=Y.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=O}}const v=new Uint16Array(ha*ha*6);let g=0;for(let b=0;b<ha;b++)for(let w=0;w<ha;w++){const R=b*Ke+w,M=R+1,A=R+Ke,P=A+1;v[g++]=R,v[g++]=A,v[g++]=M,v[g++]=M,v[g++]=A,v[g++]=P}const m=new we;m.setAttribute("position",new de(d,3)),m.setAttribute("uv",new de(f,2)),m.setAttribute("color",new de(p,4)),m.setIndex(new de(v,1)),m.computeVertexNormals();const S=new yi(l.source);S.flipY=!1;const E=new La({map:S,color:new ct(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),_=new qt(m,E);return _.receiveShadow=!0,_.castShadow=!0,{mesh:_,attribution:e.imagery.attribution}}function lb(s,t,e){return Math.max(t,Math.min(e,s))}const hb=18,ub=.55,db=.5,fb=`
5094
+ vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const nb=[{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}],ha=64,Ke=ha+1,Mf=512,ib=900,sb=700/900,rb=0,ab=.01;function ob(s,t,e){return{north:Ni(0,-e,s,t).lat,south:Ni(0,e,s,t).lat,east:Ni(e,0,s,t).lng,west:Ni(-e,0,s,t).lng}}async function cb(s,t,e,n=ib){const i=n,r=n*sb,a=ob(s,t,i),o={width:Ke,height:Ke},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:Mf,height:Mf})]),h=Math.floor(Ke/2),u=c.heights[h*Ke+h],d=new Float32Array(Ke*Ke*3),f=new Float32Array(Ke*Ke*2),p=new Float32Array(Ke*Ke*4);for(let b=0;b<Ke;b++){const w=b/(Ke-1),R=a.north+(a.south-a.north)*w;for(let M=0;M<Ke;M++){const A=M/(Ke-1),P=a.west+(a.east-a.west)*A,{x:D,z:I}=tn(R,P,s,t),F=c.heights[b*Ke+M],H=Math.max(Math.abs(D),Math.abs(I)),O=1-lb((H-r)/(i-r),0,1),V=rb+ab+(F-u),k=b*Ke+M;d[k*3]=D,d[k*3+1]=V,d[k*3+2]=I;const Y=Ep(l.bounds,P,R);f[k*2]=Y.x,f[k*2+1]=Y.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=O}}const v=new Uint16Array(ha*ha*6);let g=0;for(let b=0;b<ha;b++)for(let w=0;w<ha;w++){const R=b*Ke+w,M=R+1,A=R+Ke,P=A+1;v[g++]=R,v[g++]=A,v[g++]=M,v[g++]=M,v[g++]=A,v[g++]=P}const m=new we;m.setAttribute("position",new de(d,3)),m.setAttribute("uv",new de(f,2)),m.setAttribute("color",new de(p,4)),m.setIndex(new de(v,1)),m.computeVertexNormals();const S=new Si(l.source);S.flipY=!1;const E=new La({map:S,color:new ct(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),_=new qt(m,E);return _.receiveShadow=!0,_.castShadow=!0,{mesh:_,attribution:e.imagery.attribution}}function lb(s,t,e){return Math.max(t,Math.min(e,s))}const hb=18,ub=.55,db=.5,fb=`
5095
5095
  attribute float aSpeed;
5096
5096
  uniform float uTime;
5097
5097
  uniform float uOverallSpeed;
@@ -5191,7 +5191,7 @@ void main() {
5191
5191
  float blur = max(vNearBlur, vHaze);
5192
5192
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${db.toFixed(2)}));
5193
5193
  }
5194
- `;function mb(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const gb=.14,xf=4.5;let Co;function vb(){if(Co)return Co;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createImageData(s,s),i=s/2,r=s*gb,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-i,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*xf*xf)),f=(o*s+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return e.putImageData(n,0,0),Co=new yi(t),Co}function Mb(s){const t=mb(s.seed),e=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let l=0;l<s.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*s.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*s.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new we;r.setAttribute("position",new de(e,3)),r.setAttribute("aSpeed",new de(n,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 Pt(0,0)},uDropVelocity:{value:new C(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:vb()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Ae({uniforms:a,vertexShader:fb,fragmentShader:pb,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Ko(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class ks{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return ks.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(ks.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class Jt{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(t,e){return this.radianceTowards(t,e)*Jt.anchor()}static anchor(){return ks.fromMagPerArcsec2(Jt.PEAK_MAG_PER_ARCSEC2)/Jt.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Jt.NEAR_LIMIT_KPC),d=Math.log(Jt.FAR_LIMIT_KPC)-u;for(let f=0;f<Jt.STEPS;f++){const p=Math.exp(u+d*f/(Jt.STEPS-1)),v=p-h;h=p;const g=p-v/2,m=Jt.SUN_RADIUS_KPC+g*r,S=g*a,E=Jt.SUN_HEIGHT_KPC+g*o,_=Math.hypot(m,S),b=Math.exp(-(_-Jt.SUN_RADIUS_KPC)/Jt.DISK_SCALE_LENGTH_KPC-Math.abs(E)/Jt.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(_,E/Jt.BULGE_FLATTENING),R=Jt.BULGE_TO_LOCAL_DISK*Math.exp(-w/Jt.BULGE_SCALE_KPC);if(c+=(b+R)*v*10**(-.4*l),l+=Jt.EXTINCTION_MAG_PER_KPC*Math.exp(-(_-Jt.SUN_RADIUS_KPC)/Jt.DUST_SCALE_LENGTH_KPC-(Math.abs(E)-Jt.SUN_HEIGHT_KPC)/Jt.DUST_SCALE_HEIGHT_KPC)*v,l>Jt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Jt.LONGITUDE_STEPS*Jt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Jt.LATITUDE_STEPS}walk(t){const e=Jt.LONGITUDE_STEPS,n=Math.min(Jt.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=ks.latitudeOfRowCoord((this.walked+.5)/Jt.LATITUDE_STEPS);for(let r=0;r<e;r++)this.values[this.walked*e+r]=this.radianceTowards(360*(r+.5)/e,i)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const e=Jt.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Jt.LONGITUDE_STEPS,height:Jt.LATITUDE_STEPS,data:n}}}class be{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(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=be.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(be.NEAR_LIMIT_AU),d=Math.log(be.FAR_LIMIT_AU)-u;for(let f=0;f<be.STEPS;f++){const p=Math.exp(u+d*f/(be.STEPS-1)),v=p-h;h=p;const g=p-v/2,m=1+g*r,S=g*a,E=g*o,_=Math.hypot(m,S,E);if(_<be.SUBLIMATION_AU)continue;const b=E/_,w=_**-1.3*Math.exp(-2.6*Math.abs(b)),R=(c-g)/_;l+=w*this.scattering(R)*v/(_*_)}return l}scattering(t){let e=0;for(let n=0;n<be.LOBE_ASYMMETRY.length;n++){const i=be.LOBE_ASYMMETRY[n],r=1+i*i-2*i*t;e+=be.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return e}values=new Float32Array(be.LONGITUDE_STEPS*be.LATITUDE_STEPS);walked=0;get done(){return this.walked>=be.LATITUDE_STEPS}walk(t){const e=be.LONGITUDE_STEPS,n=Math.min(be.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=ks.latitudeOfRowCoord((this.walked+.5)/be.LATITUDE_STEPS);for(let r=0;r<e;r++){const a=ks.angleOfColumnCoord((r+.5)/e);this.values[this.walked*e+r]=this.radianceTowards(a,i)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:be.LONGITUDE_STEPS,height:be.LATITUDE_STEPS,data:n}}}class Zt{static get NANOLAMBERTS_PER_S10(){return Zt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Zt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(t){const e=Zt.TWILIGHT;for(let n=0;n<e.length-1;n++){const i=e[n],r=e[n+1];if(t<=i.sunAltitudeDeg&&t>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-t)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Zt.NANOLAMBERT_OFFSET-Zt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Zt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Zt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Zt.EXTINCTION_PER_AIR_MASS*Zt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Zt.toNanolamberts(Zt.moonlessMagPerArcsec2(t))-Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Zt.scatteringAt(90-t)*Zt.scatteredFraction(90);return Zt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,n,i){return Zt.scatteringAt(n)*Zt.moonOutput(t,e)*Zt.scatteredFraction(i)}static moonOutput(t,e){if(e<=0)return 0;const n=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Zt.EXTINCTION_PER_AIR_MASS*Zt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,n){const i=Zt.scatteredFraction(n),r=Zt.scatteringAt(t.separationDeg)*Zt.twilightOutput(t.altitudeDeg)*i,a=Zt.scatteringAt(e.separationDeg)*Zt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*i;return Zt.fromNanolamberts(Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class is{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=Rs.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=is.buildTexture(this.milkyWayTexels,Jt.LONGITUDE_STEPS,Jt.LATITUDE_STEPS,Ea),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=is.buildTexture(this.zodiacalTexels,be.LONGITUDE_STEPS,be.LATITUDE_STEPS,gn),this.material=new Ae({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new kt},uEclipticPole:{value:new C(0,1,0)},uSunLongitude:{value:new C(1,0,0)},uMoonDirection:{value:new C(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new C(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new C(0,0,0)},uMilkyWayTint:{value:new C(...is.MILKY_WAY_TINT)},uZodiacalTint:{value:new C(...is.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
5194
+ `;function mb(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const gb=.14,xf=4.5;let Co;function vb(){if(Co)return Co;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createImageData(s,s),i=s/2,r=s*gb,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-i,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*xf*xf)),f=(o*s+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return e.putImageData(n,0,0),Co=new Si(t),Co}function Mb(s){const t=mb(s.seed),e=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let l=0;l<s.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*s.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*s.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new we;r.setAttribute("position",new de(e,3)),r.setAttribute("aSpeed",new de(n,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 Pt(0,0)},uDropVelocity:{value:new C(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:vb()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new Ae({uniforms:a,vertexShader:fb,fragmentShader:pb,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Ko(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}class ks{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return ks.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(ks.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class Jt{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(t,e){return this.radianceTowards(t,e)*Jt.anchor()}static anchor(){return ks.fromMagPerArcsec2(Jt.PEAK_MAG_PER_ARCSEC2)/Jt.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Jt.NEAR_LIMIT_KPC),d=Math.log(Jt.FAR_LIMIT_KPC)-u;for(let f=0;f<Jt.STEPS;f++){const p=Math.exp(u+d*f/(Jt.STEPS-1)),v=p-h;h=p;const g=p-v/2,m=Jt.SUN_RADIUS_KPC+g*r,S=g*a,E=Jt.SUN_HEIGHT_KPC+g*o,_=Math.hypot(m,S),b=Math.exp(-(_-Jt.SUN_RADIUS_KPC)/Jt.DISK_SCALE_LENGTH_KPC-Math.abs(E)/Jt.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(_,E/Jt.BULGE_FLATTENING),R=Jt.BULGE_TO_LOCAL_DISK*Math.exp(-w/Jt.BULGE_SCALE_KPC);if(c+=(b+R)*v*10**(-.4*l),l+=Jt.EXTINCTION_MAG_PER_KPC*Math.exp(-(_-Jt.SUN_RADIUS_KPC)/Jt.DUST_SCALE_LENGTH_KPC-(Math.abs(E)-Jt.SUN_HEIGHT_KPC)/Jt.DUST_SCALE_HEIGHT_KPC)*v,l>Jt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Jt.LONGITUDE_STEPS*Jt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Jt.LATITUDE_STEPS}walk(t){const e=Jt.LONGITUDE_STEPS,n=Math.min(Jt.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=ks.latitudeOfRowCoord((this.walked+.5)/Jt.LATITUDE_STEPS);for(let r=0;r<e;r++)this.values[this.walked*e+r]=this.radianceTowards(360*(r+.5)/e,i)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const e=Jt.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Jt.LONGITUDE_STEPS,height:Jt.LATITUDE_STEPS,data:n}}}class be{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(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=be.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(be.NEAR_LIMIT_AU),d=Math.log(be.FAR_LIMIT_AU)-u;for(let f=0;f<be.STEPS;f++){const p=Math.exp(u+d*f/(be.STEPS-1)),v=p-h;h=p;const g=p-v/2,m=1+g*r,S=g*a,E=g*o,_=Math.hypot(m,S,E);if(_<be.SUBLIMATION_AU)continue;const b=E/_,w=_**-1.3*Math.exp(-2.6*Math.abs(b)),R=(c-g)/_;l+=w*this.scattering(R)*v/(_*_)}return l}scattering(t){let e=0;for(let n=0;n<be.LOBE_ASYMMETRY.length;n++){const i=be.LOBE_ASYMMETRY[n],r=1+i*i-2*i*t;e+=be.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return e}values=new Float32Array(be.LONGITUDE_STEPS*be.LATITUDE_STEPS);walked=0;get done(){return this.walked>=be.LATITUDE_STEPS}walk(t){const e=be.LONGITUDE_STEPS,n=Math.min(be.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=ks.latitudeOfRowCoord((this.walked+.5)/be.LATITUDE_STEPS);for(let r=0;r<e;r++){const a=ks.angleOfColumnCoord((r+.5)/e);this.values[this.walked*e+r]=this.radianceTowards(a,i)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:be.LONGITUDE_STEPS,height:be.LATITUDE_STEPS,data:n}}}class Zt{static get NANOLAMBERTS_PER_S10(){return Zt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Zt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(t){const e=Zt.TWILIGHT;for(let n=0;n<e.length-1;n++){const i=e[n],r=e[n+1];if(t<=i.sunAltitudeDeg&&t>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-t)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Zt.NANOLAMBERT_OFFSET-Zt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Zt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Zt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Zt.EXTINCTION_PER_AIR_MASS*Zt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Zt.toNanolamberts(Zt.moonlessMagPerArcsec2(t))-Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Zt.scatteringAt(90-t)*Zt.scatteredFraction(90);return Zt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,n,i){return Zt.scatteringAt(n)*Zt.moonOutput(t,e)*Zt.scatteredFraction(i)}static moonOutput(t,e){if(e<=0)return 0;const n=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Zt.EXTINCTION_PER_AIR_MASS*Zt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,n){const i=Zt.scatteredFraction(n),r=Zt.scatteringAt(t.separationDeg)*Zt.twilightOutput(t.altitudeDeg)*i,a=Zt.scatteringAt(e.separationDeg)*Zt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*i;return Zt.fromNanolamberts(Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class is{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=Rs.shared;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;repaint;constructor(){this.milkyWayTexels=this.maps.milkyWayTexels,this.milkyWayTexture=is.buildTexture(this.milkyWayTexels,Jt.LONGITUDE_STEPS,Jt.LATITUDE_STEPS,Ea),this.zodiacalTexels=this.maps.zodiacalTexels,this.zodiacalTexture=is.buildTexture(this.zodiacalTexels,be.LONGITUDE_STEPS,be.LATITUDE_STEPS,gn),this.material=new Ae({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new kt},uEclipticPole:{value:new C(0,1,0)},uSunLongitude:{value:new C(1,0,0)},uMoonDirection:{value:new C(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new C(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Zt.toNanolamberts(Zt.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new C(0,0,0)},uMilkyWayTint:{value:new C(...is.MILKY_WAY_TINT)},uZodiacalTint:{value:new C(...is.ZODIACAL_TINT)},uReady:{value:this.maps.done?1:0},uEncodeDestination:{value:1}},vertexShader:`
5195
5195
  varying vec3 vDirection;
5196
5196
  void main() {
5197
5197
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5306,7 +5306,7 @@ void main() {
5306
5306
  vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
5307
5307
  gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
5308
5308
  }
5309
- `,transparent:!0,blending:Qn,depthWrite:!1,side:ze,fog:!1}),this.object=new qt(new ln(is.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,n,i){const r=new Ur(t,e,n,vn,cn);return r.minFilter=ye,r.magFilter=ye,r.wrapS=i,r.wrapT=gn,r.needsUpdate=!0,r}set onReady(t){this.repaint=t}update(t){if(Zt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<is.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(t.galactic),n.uEclipticPole.value.copy(t.eclipticPole).normalize(),n.uSunLongitude.value.copy(t.sunLongitude).normalize(),n.uMoonDirection.value.copy(t.moon.direction).normalize(),n.uSunDirection.value.copy(t.sunDirection).normalize(),n.uMoonOutput.value=Zt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),n.uTwilightOutput.value=Zt.twilightOutput(t.sunAltitudeDeg),n.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?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 Rs{static instance;static get shared(){return Rs.instance??=new Rs}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(Jt.LONGITUDE_STEPS*Jt.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(be.LONGITUDE_STEPS*be.LATITUDE_STEPS*4);galaxy=new Jt;dust=new be;waiting=new Set;workHandle;published=!1;get done(){return this.published}request(t){if(this.published){t();return}if(this.waiting.add(t),this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const n=performance.now()+Rs.WORK_BUDGET_MS;for(;performance.now()<n&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}cancel(t){this.waiting.delete(t),!(this.waiting.size>0||this.workHandle===void 0)&&(cancelAnimationFrame(this.workHandle),this.workHandle=void 0)}publish(){Rs.fill(this.milkyWayTexels,this.galaxy.harvest()),Rs.fill(this.zodiacalTexels,this.dust.harvest()),this.published=!0;const t=[...this.waiting];this.waiting.clear();for(const e of t)e()}static fill(t,e){for(let n=0;n<e.data.length;n++)t[n*4]=ls.toHalfFloat(Zt.nanolambertsOfS10(e.data[n])),t[n*4+3]=ls.toHalfFloat(1)}}class Yn{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(t,e){return{centre:Yn.at(Yn.GALACTIC_CENTRE,t,e),rotation:Yn.at(Yn.GALACTIC_ROTATION,t,e),pole:Yn.at(Yn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Yn.at(Yn.ECLIPTIC_POLE,t,e)}static at(t,e,n){return Lc(t.raHours,t.decDeg,e,n,!1)}}const xb=`
5309
+ `,transparent:!0,blending:ti,depthWrite:!1,side:ze,fog:!1}),this.object=new qt(new ln(is.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,n,i){const r=new Ur(t,e,n,vn,cn);return r.minFilter=ye,r.magFilter=ye,r.wrapS=i,r.wrapT=gn,r.needsUpdate=!0,r}set onReady(t){this.repaint=t}update(t){if(Zt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<is.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(t.galactic),n.uEclipticPole.value.copy(t.eclipticPole).normalize(),n.uSunLongitude.value.copy(t.sunLongitude).normalize(),n.uMoonDirection.value.copy(t.moon.direction).normalize(),n.uSunDirection.value.copy(t.sunDirection).normalize(),n.uMoonOutput.value=Zt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),n.uTwilightOutput.value=Zt.twilightOutput(t.sunAltitudeDeg),n.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?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 Rs{static instance;static get shared(){return Rs.instance??=new Rs}static WORK_BUDGET_MS=6;milkyWayTexels=new Uint16Array(Jt.LONGITUDE_STEPS*Jt.LATITUDE_STEPS*4);zodiacalTexels=new Uint16Array(be.LONGITUDE_STEPS*be.LATITUDE_STEPS*4);galaxy=new Jt;dust=new be;waiting=new Set;workHandle;published=!1;get done(){return this.published}request(t){if(this.published){t();return}if(this.waiting.add(t),this.workHandle!==void 0)return;const e=()=>{this.workHandle=void 0;const n=performance.now()+Rs.WORK_BUDGET_MS;for(;performance.now()<n&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(e)};this.workHandle=requestAnimationFrame(e)}cancel(t){this.waiting.delete(t),!(this.waiting.size>0||this.workHandle===void 0)&&(cancelAnimationFrame(this.workHandle),this.workHandle=void 0)}publish(){Rs.fill(this.milkyWayTexels,this.galaxy.harvest()),Rs.fill(this.zodiacalTexels,this.dust.harvest()),this.published=!0;const t=[...this.waiting];this.waiting.clear();for(const e of t)e()}static fill(t,e){for(let n=0;n<e.data.length;n++)t[n*4]=ls.toHalfFloat(Zt.nanolambertsOfS10(e.data[n])),t[n*4+3]=ls.toHalfFloat(1)}}class Yn{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(t,e){return{centre:Yn.at(Yn.GALACTIC_CENTRE,t,e),rotation:Yn.at(Yn.GALACTIC_ROTATION,t,e),pole:Yn.at(Yn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Yn.at(Yn.ECLIPTIC_POLE,t,e)}static at(t,e,n){return Lc(t.raHours,t.decDeg,e,n,!1)}}const xb=`
5310
5310
  varying vec2 vUv;
5311
5311
  void main() {
5312
5312
  vUv = uv;
@@ -5742,7 +5742,7 @@ void main()
5742
5742
  // stays what it always was for the optional artifacts.
5743
5743
  gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
5744
5744
  }
5745
- `;let Po;function yb(){if(Po)return Po;const s=256,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,s,s);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[i,r,a,o]of n){const c=e.createRadialGradient(i*s,r*s,0,i*s,r*s,a*s);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,s,s)}return Po=new yi(t),Po}function Sb(){const s={uTime:{value:0},uResolution:{value:new Pt(1,1)},uLensPosition:{value:new Pt(0,0)},uColorGain:{value:new ct(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new ct(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:yb()}},t=new Ae({uniforms:s,vertexShader:xb,fragmentShader:_b,transparent:!0,depthWrite:!1,depthTest:!1,blending:Qn,fog:!1,name:"LensFlareShader"}),e=new qt(new Wi(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:s}}class ga{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new Da;quadCamera=new Hs(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new wn(this.width,this.height,{type:cn}),this.material=new Ae({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Pt(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
5745
+ `;let Po;function yb(){if(Po)return Po;const s=256,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,s,s);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[i,r,a,o]of n){const c=e.createRadialGradient(i*s,r*s,0,i*s,r*s,a*s);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,s,s)}return Po=new Si(t),Po}function Sb(){const s={uTime:{value:0},uResolution:{value:new Pt(1,1)},uLensPosition:{value:new Pt(0,0)},uColorGain:{value:new ct(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new ct(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:yb()}},t=new Ae({uniforms:s,vertexShader:xb,fragmentShader:_b,transparent:!0,depthWrite:!1,depthTest:!1,blending:ti,fog:!1,name:"LensFlareShader"}),e=new qt(new Wi(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:s}}class ga{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new Da;quadCamera=new Hs(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new wn(this.width,this.height,{type:cn}),this.material=new Ae({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Pt(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
5746
5746
  varying vec2 vNdc;
5747
5747
  void main() {
5748
5748
  vNdc = position.xy;
@@ -5782,7 +5782,7 @@ void main()
5782
5782
  vec3 colour = texture2D(uSource, src * 0.5 + 0.5).rgb;
5783
5783
  gl_FragColor = vec4(uEncodeOutput > 0.5 ? encodeSrgb(colour) : colour, 1.0);
5784
5784
  }
5785
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new qt(new Wi(2,2),this.material))}directionFor(t,e,n){const i=this.width/this.height,r=n/2*Math.PI/180,a=t*i*r,o=e*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(t,e,n){const i=Math.hypot(t.x,t.y,t.z);if(i===0||t.z>=0)return;const r=e/2*Math.PI/180,a=Math.acos(Math.min(1,-t.z/i)),o=Math.sin(a),c=o<1e-9?1:a/o,l=t.x/i*c,h=t.y/i*c;return{ndcX:l/(n*r),ndcY:h/r}}static cornerHalfAngleDeg(t,e){return t/2*Math.hypot(e,1)}static supports(t,e){return this.cornerHalfAngleDeg(t,e)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(t){this.material.uniforms.uEncodeOutput.value=t?1:0}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(t,e,n,i,r,a){const o=this.width/this.height;this.material.uniforms.uHalfFovRad.value=i/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(i,o);const c=n.fov;n.fov=this.sourceFovDeg(i,o),n.updateProjectionMatrix(),r?.();const l=t.getRenderTarget();t.setRenderTarget(this.target),t.render(e,n),a?.(),t.setRenderTarget(l),n.fov=c,n.updateProjectionMatrix(),t.render(this.quadScene,this.quadCamera)}sourceFovDeg(t,e){return Math.atan(this.sourceTanHalfFovY(t,e))*360/Math.PI}sourceTanHalfFovY(t,e){const n=ga.cornerHalfAngleDeg(t,e)*Math.PI/180;return Math.tan(n)/Math.hypot(e,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class va{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Da;quadCamera=new Hs(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e);const n=new Fs(this.width,this.height,ti);n.minFilter=We,n.magFilter=We,this.target=new wn(this.width,this.height,{type:cn,depthTexture:n}),this.material=new Ae({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Pt(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:va.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
5785
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new qt(new Wi(2,2),this.material))}directionFor(t,e,n){const i=this.width/this.height,r=n/2*Math.PI/180,a=t*i*r,o=e*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static ndcFor(t,e,n){const i=Math.hypot(t.x,t.y,t.z);if(i===0||t.z>=0)return;const r=e/2*Math.PI/180,a=Math.acos(Math.min(1,-t.z/i)),o=Math.sin(a),c=o<1e-9?1:a/o,l=t.x/i*c,h=t.y/i*c;return{ndcX:l/(n*r),ndcY:h/r}}static cornerHalfAngleDeg(t,e){return t/2*Math.hypot(e,1)}static supports(t,e){return this.cornerHalfAngleDeg(t,e)<=this.MAX_HALF_ANGLE_DEG}setEncodesOutput(t){this.material.uniforms.uEncodeOutput.value=t?1:0}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(t,e,n,i,r,a){const o=this.width/this.height;this.material.uniforms.uHalfFovRad.value=i/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(i,o);const c=n.fov;n.fov=this.sourceFovDeg(i,o),n.updateProjectionMatrix(),r?.();const l=t.getRenderTarget();t.setRenderTarget(this.target),t.render(e,n),a?.(),t.setRenderTarget(l),n.fov=c,n.updateProjectionMatrix(),t.render(this.quadScene,this.quadCamera)}sourceFovDeg(t,e){return Math.atan(this.sourceTanHalfFovY(t,e))*360/Math.PI}sourceTanHalfFovY(t,e){const n=ga.cornerHalfAngleDeg(t,e)*Math.PI/180;return Math.tan(n)/Math.hypot(e,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class va{static MAX_RADIUS_PX=24;static TAPS=32;target;quadScene=new Da;quadCamera=new Hs(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e);const n=new Fs(this.width,this.height,ei);n.minFilter=We,n.magFilter=We,this.target=new wn(this.width,this.height,{type:cn,depthTexture:n}),this.material=new Ae({uniforms:{uColour:{value:this.target.texture},uDepth:{value:n},uResolution:{value:new Pt(this.width,this.height)},uNear:{value:.1},uFar:{value:1e3},uApertureMm2:{value:0},uFocusDistance:{value:0},uFocalLengthMm:{value:50},uPixelsPerMm:{value:0},uMaxRadius:{value:va.MAX_RADIUS_PX},uEncodeOutput:{value:1}},vertexShader:`
5786
5786
  varying vec2 vUv;
5787
5787
  void main() {
5788
5788
  vUv = position.xy * 0.5 + 0.5;
@@ -5859,7 +5859,7 @@ void main()
5859
5859
  // values — and encoded only at the very end. See colorSpace.ts.
5860
5860
  gl_FragColor = vec4(forDestination(total / weight), colour.a);
5861
5861
  }
5862
- `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new qt(new Wi(2,2),this.material))}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(t,e,n,i){const r=this.material.uniforms;r.uApertureMm2.value=t*t/Math.max(.1,e),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=t,r.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(t){this.material.uniforms.uEncodeOutput.value=t?1:0}render(t,e,n,i){const r=this.material.uniforms;r.uNear.value=n.near,r.uFar.value=n.far;const a=t.getRenderTarget();t.setRenderTarget(this.target),t.clear(),t.render(e,n),i?.(),t.setRenderTarget(a),t.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Me{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(t,e){this.maxRatio=Me.clamp(t),this.ratio=this.maxRatio,this.timer=e?_c.create(e):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=Me.clamp(t),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(t,e){const n=this.timer?.poll();if(!(this.timer&&n===void 0))return n!==void 0?this.followGpu(t,n):this.followIntervals(t,e)}followGpu(t,e){if(e>Me.GPU_LATE_MS)return this.lower(t,Me.LOWER_COOLDOWN_MS);if(e<Me.GPU_ROOM_MS)return this.raise(t,Me.RAISE_COOLDOWN_MS)}followIntervals(t,e){if(!(e>0)||e>1e3)return;this.intervalMs=this.intervalMs===void 0?e:this.intervalMs*.9+e*.1;const n=this.intervalMs>Me.INTERVAL_LATE_MS;if(this.probe){if(n)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+Me.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=Me.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+Me.PROBE_EVERY_MS);return}if(n){const i=this.lower(t,Me.LOWER_COOLDOWN_MS);return i!==void 0&&(this.nextProbeMs=t+Me.PROBE_EVERY_MS),i}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=Me.RAISE_COOLDOWN_MS){const i=this.ratio,r=this.raise(t,0);return r!==void 0&&(this.probe={sinceMs:t,ratioBefore:i}),r}}lower(t,e){if(!(this.ratio<=Me.MIN_RATIO||t-this.lastChangeMs<e))return this.ratio=Me.clamp(this.ratio-Me.STEP),this.lastChangeMs=t,this.ratio}raise(t,e){if(!(this.ratio>=this.maxRatio||t-this.lastChangeMs<e))return this.ratio=Math.min(this.maxRatio,Me.clamp(this.ratio+Me.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(Me.MIN_RATIO,Math.round(t/Me.STEP)*Me.STEP):Me.MIN_RATIO}}class _c{constructor(t,e){this.gl=t,this.extension=e}static IN_FLIGHT_MAX=8;static create(t){if(!(t instanceof WebGL2RenderingContext))return;const e=t.getExtension("EXT_disjoint_timer_query_webgl2");return e?new _c(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=_c.IN_FLIGHT_MAX))try{const t=this.gl.createQuery();if(!t)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,t),this.active=t}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 t=this.gl;try{for(let e=0;e<this.pending.length;e++){const n=this.pending[e];if(!t.getQueryParameter(n,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const r=t.getQueryParameter(n,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}t.deleteQuery(n),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class te{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=te.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const n=t*Math.PI/180,i=e*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(t,e){const n=e*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(n)**2)/i}static parheliaAzimuthDeg(t,e=te.ICE_INDEX_RED){const n=te.minimumDeviationDeg(te.SIDE_PRISM_ANGLE_DEG,te.effectiveIndex(e,t));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(t,e=te.ICE_INDEX_RED){const n=te.parheliaAzimuthDeg(t,e);if(n===void 0)return;const i=t*Math.PI/180,r=Math.sin(i)**2,a=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=te.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=te.ICE_INDEX_RED){if(t<0||t>90-te.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(t*Math.PI/180),i=Math.sqrt(e*e-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return te.ringOf("halo22",te.SIDE_PRISM_ANGLE_DEG)}static halo46(){return te.ringOf("halo46",te.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const n=te.minimumDeviationDeg(e,te.ICE_INDEX_RED),i=te.minimumDeviationDeg(e,te.ICE_INDEX_BLUE);return{id:t,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(t,e,n=90,i=0){const r=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return r*a*o}static formsAt(t,e=0){if(t<=-e)return[];const n=[te.halo22(),te.halo46()],i=t>0?te.parheliaDistanceDeg(t):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:te.parheliaDistanceDeg(t,te.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:te.halo22().angleDeg}),t>0&&n.push({id:"parhelicCircle",angleDeg:t});const r=te.circumzenithalAltitudeDeg(t);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),t>te.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),t<te.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class bn{static get WATER_INDEX_RED(){return Ze.indexAt(Ze.RED_NM)}static get WATER_INDEX_BLUE(){return Ze.indexAt(Ze.BLUE_NM)}static radiusDeg(t,e){const n=(e*e-1)/(t*t-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(i)/e),a=2*(i-r)+(t-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return bn.bowOf("primary",2,0)}static secondary(){return bn.bowOf("secondary",3,0)}static bowOf(t,e,n){const i=bn.radiusDeg(e,bn.WATER_INDEX_RED),r=bn.radiusDeg(e,bn.WATER_INDEX_BLUE),a=(i+r)/2;return{id:t,radiusDeg:a,redRadiusDeg:i,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:bn.primary().redRadiusDeg,toDeg:bn.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[bn.bowOf("primary",2,t),bn.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-bn.FULL_MOON_MAGNITUDE)))}static strength(t,e,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e)));return i*r}}class Dn{constructor(t){this.radius=t;const e=Dn.SEGMENTS*Dn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const n=new we;n.setAttribute("position",new de(this.positions,3)),n.setAttribute("color",new de(this.colors,3)),n.setDrawRange(0,0),this.object=new qt(n,new zi({vertexColors:!0,transparent:!0,blending:Qn,depthWrite:!1,fog:!1,side:$n})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Dn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Dn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,n){this.head=t&&pn(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&pn(e.altitudeDeg,e.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,n=this.tip;if(!e||!n||this.brightness<=0){t.setDrawRange(0,0);return}const i=this.angleBetween(e,n);if(i<=0){t.setDrawRange(0,0);return}const r=i*Dn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,n,h),this.radius),o=h=>this.radius*(Dn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**Dn.FADE_POWER;let l=0;for(let h=1;h<Dn.POINTS;h++){const u=(h-1)/Dn.SEGMENTS,d=h/Dn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<Dn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),p=this.across(e,c,i,u),v=this.across(n,c,r,u),g=(m,S)=>m===0?S:0;t=this.push(t,d,g(h,a)),t=this.push(t,f,g(h,o)),t=this.push(t,p,g(u,a)),t=this.push(t,f,g(h,o)),t=this.push(t,v,g(u,o)),t=this.push(t,p,g(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.55,this.colors[i+1]=r*.75,this.colors[i+2]=r,t+1}slerp(t,e,n){const i=this.angleBetweenRadians(t,e);if(i<1e-9)return t;const r=Math.sin(i),a=Math.sin((1-n)*i)/r,o=Math.sin(n*i)/r;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const n=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class yn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(yn.ANCHOR_BLUE-yn.ANCHOR_RED)/(1/(yn.BLUE_NM*yn.BLUE_NM)-1/(yn.RED_NM*yn.RED_NM));static A=yn.ANCHOR_RED-yn.B/(yn.RED_NM*yn.RED_NM);static indexAt(t){return yn.A+yn.B/(t*t)}}class Ca{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,n,i,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-e,c=t,l=0):(o=0,c=-n,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-n*c,d=n*o-t*l,f=t*c-e*o,p=r/2,v=a/2;for(let g=0;g<6;g++){const m=i+g*Math.PI/3,S=Math.cos(m),E=Math.sin(m);this.normals[g*3]=o*S+u*E,this.normals[g*3+1]=c*S+d*E,this.normals[g*3+2]=l*S+f*E,this.offsets[g]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,n,i,r,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-n*l,f=n*c-t*h,p=t*l-e*c,v=c*i+d*r-t*this.radius*2,g=l*i+f*r-e*this.radius*2,m=h*i+p*r-n*this.radius*2;let S=-1,E=-1/0,_=1/0;for(let J=0;J<8;J++){const nt=this.normals[J*3],at=this.normals[J*3+1],Ht=this.normals[J*3+2],$t=nt*t+at*e+Ht*n,Bt=this.offsets[J]-(nt*v+at*g+Ht*m);if($t>1e-9){const K=Bt/$t;K<_&&(_=K)}else if($t<-1e-9){const K=Bt/$t;K>E&&(E=K,S=J)}else if(Bt<0)return 0}if(S<0||E>=_)return 0;let b=0;const w=this.normals[S*3],R=this.normals[S*3+1],M=this.normals[S*3+2],A=-(w*t+R*e+M*n),P=pc.reflectance(A,1,a);o[b].x=t+2*A*w,o[b].y=e+2*A*R,o[b].z=n+2*A*M,o[b].weight=P,b++;const D=1/a,I=Math.sqrt(Math.max(0,1-D*D*(1-A*A)));let F=D*t+(D*A-I)*w,H=D*e+(D*A-I)*R,O=D*n+(D*A-I)*M,V=v+t*E,k=g+e*E,Y=m+n*E,tt=1-P;for(let J=0;J<Ca.MAX_BOUNCES&&tt>Ca.MIN_WEIGHT;J++){let nt=-1,at=1/0;for(let B=0;B<8;B++){const Et=this.normals[B*3],It=this.normals[B*3+1],Tt=this.normals[B*3+2],xt=Et*F+It*H+Tt*O;if(xt<=1e-9)continue;const Nt=(this.offsets[B]-(Et*V+It*k+Tt*Y))/xt;Nt>1e-9&&Nt<at&&(at=Nt,nt=B)}if(nt<0)break;const Ht=this.normals[nt*3],$t=this.normals[nt*3+1],Bt=this.normals[nt*3+2],K=Ht*F+$t*H+Bt*O,rt=a*Math.sqrt(Math.max(0,1-K*K));if(V+=F*at,k+=H*at,Y+=O*at,rt<1){const B=Math.sqrt(Math.max(0,1-rt*rt)),Et=pc.reflectance(K,a,1);if(o[b].x=a*F-(a*K-B)*Ht,o[b].y=a*H-(a*K-B)*$t,o[b].z=a*O-(a*K-B)*Bt,o[b].weight=tt*(1-Et),b++,b>=o.length)return b;tt*=Et}const it=2*K;F-=it*Ht,H-=it*$t,O-=it*Bt}return b}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class xe{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 Ca;emergent=Array.from({length:Ca.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);radiance=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);scratch=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const i=xe.WORST_TILT_DEG*(xe.BEST_TILT_DEG/xe.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(t){const e=xe.AZIMUTH_BINS,n=xe.ALTITUDE_BINS,i=this.tally,r=xe.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(xe.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),g=-Math.sin(d),m=this.crystal.aimRadius,S=(this.random()*2-1)*m,E=(this.random()*2-1)*m,_=4*m*m,b=Jn.SAMPLES[this.random()*Jn.SAMPLES.length|0],w=this.crystal.trace(p,v,g,S,E,yn.indexAt(b.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const M=this.emergent[R],A=Math.hypot(M.x,M.y,M.z);if(A<1e-9||M.weight<=0)continue;const P=M.x/A,D=M.y/A,I=M.z/A;if(P*p+D*v+I*g>a)continue;const F=Math.asin(Math.max(-1,Math.min(1,-I))),H=Math.abs(Math.atan2(-D,-P)),O=Math.min(e-1,H/Math.PI*e|0),k=(Math.min(n-1,(F+Math.PI/2)/Math.PI*n|0)*e+O)*3,Y=M.weight*_*Jn.SAMPLES.length;i[k]+=Y*b.r,i[k+1]+=Y*b.g,i[k+2]+=Y*b.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=xe.AZIMUTH_BINS,e=xe.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,n,i){return this.begin(t,e,i),this.trace(n),this.harvest()}toRadiance(t,e){const n=2*Math.PI/t,i=Math.max(1,this.traced),r=4*xe.REFERENCE_MICRONS*xe.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(n*(c-o)*i*r);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const n=this.scratch,i=this.radiance;n.set(i);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?n[u+3]:n[u];i[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(i);const r=t*3;for(let a=0;a<e;a++){const o=a>0?-r:0,c=a+1<e?r:0,l=a*r;for(let h=l;h<l+r;h++)i[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const n of xe.POPULATIONS)if(e+=n.share,t<=e)return n;return xe.POPULATIONS[xe.POPULATIONS.length-1]}orient(t,e){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,r=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),t.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(r,a,o,i,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const n=this.gaussian()*t;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class li{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new xe;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=li.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const t=xe.AZIMUTH_BINS,e=xe.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new Ur(this.texels,t,e,vn,cn),this.texture.minFilter=ye,this.texture.magFilter=ye,this.texture.wrapS=gn,this.texture.wrapT=gn,this.texture.needsUpdate=!0,this.material=new Ae({uniforms:{uSource:{value:new C(0,1,0)},uUp:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new C},uMap:{value:this.texture},uGain:{value:li.GAIN}},vertexShader:`
5862
+ `,depthTest:!1,depthWrite:!1}),this.quadScene.add(new qt(new Wi(2,2),this.material))}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height)}setLens(t,e,n,i){const r=this.material.uniforms;r.uApertureMm2.value=t*t/Math.max(.1,e),r.uFocusDistance.value=Math.max(0,n),r.uFocalLengthMm.value=t,r.uPixelsPerMm.value=this.height/Math.max(.1,i)}setEncodesOutput(t){this.material.uniforms.uEncodeOutput.value=t?1:0}render(t,e,n,i){const r=this.material.uniforms;r.uNear.value=n.near,r.uFar.value=n.far;const a=t.getRenderTarget();t.setRenderTarget(this.target),t.clear(),t.render(e,n),i?.(),t.setRenderTarget(a),t.render(this.quadScene,this.quadCamera)}dispose(){this.target.depthTexture?.dispose(),this.target.dispose(),this.material.dispose()}}class Me{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(t,e){this.maxRatio=Me.clamp(t),this.ratio=this.maxRatio,this.timer=e?_c.create(e):void 0}get pixelRatio(){return this.ratio}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=Me.clamp(t),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(t,e){const n=this.timer?.poll();if(!(this.timer&&n===void 0))return n!==void 0?this.followGpu(t,n):this.followIntervals(t,e)}followGpu(t,e){if(e>Me.GPU_LATE_MS)return this.lower(t,Me.LOWER_COOLDOWN_MS);if(e<Me.GPU_ROOM_MS)return this.raise(t,Me.RAISE_COOLDOWN_MS)}followIntervals(t,e){if(!(e>0)||e>1e3)return;this.intervalMs=this.intervalMs===void 0?e:this.intervalMs*.9+e*.1;const n=this.intervalMs>Me.INTERVAL_LATE_MS;if(this.probe){if(n)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+Me.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=Me.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+Me.PROBE_EVERY_MS);return}if(n){const i=this.lower(t,Me.LOWER_COOLDOWN_MS);return i!==void 0&&(this.nextProbeMs=t+Me.PROBE_EVERY_MS),i}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=Me.RAISE_COOLDOWN_MS){const i=this.ratio,r=this.raise(t,0);return r!==void 0&&(this.probe={sinceMs:t,ratioBefore:i}),r}}lower(t,e){if(!(this.ratio<=Me.MIN_RATIO||t-this.lastChangeMs<e))return this.ratio=Me.clamp(this.ratio-Me.STEP),this.lastChangeMs=t,this.ratio}raise(t,e){if(!(this.ratio>=this.maxRatio||t-this.lastChangeMs<e))return this.ratio=Math.min(this.maxRatio,Me.clamp(this.ratio+Me.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(Me.MIN_RATIO,Math.round(t/Me.STEP)*Me.STEP):Me.MIN_RATIO}}class _c{constructor(t,e){this.gl=t,this.extension=e}static IN_FLIGHT_MAX=8;static create(t){if(!(t instanceof WebGL2RenderingContext))return;const e=t.getExtension("EXT_disjoint_timer_query_webgl2");return e?new _c(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=_c.IN_FLIGHT_MAX))try{const t=this.gl.createQuery();if(!t)return;this.gl.beginQuery(this.extension.TIME_ELAPSED_EXT,t),this.active=t}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 t=this.gl;try{for(let e=0;e<this.pending.length;e++){const n=this.pending[e];if(!t.getQueryParameter(n,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const r=t.getQueryParameter(n,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?r:this.smoothedMs*.8+r*.2}t.deleteQuery(n),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class te{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=te.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const n=t*Math.PI/180,i=e*Math.sin(n/2);return i>1?Number.NaN:(2*Math.asin(i)-n)*180/Math.PI}static effectiveIndex(t,e){const n=e*Math.PI/180,i=Math.cos(n);return i<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(n)**2)/i}static parheliaAzimuthDeg(t,e=te.ICE_INDEX_RED){const n=te.minimumDeviationDeg(te.SIDE_PRISM_ANGLE_DEG,te.effectiveIndex(e,t));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(t,e=te.ICE_INDEX_RED){const n=te.parheliaAzimuthDeg(t,e);if(n===void 0)return;const i=t*Math.PI/180,r=Math.sin(i)**2,a=Math.cos(i)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=te.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=te.ICE_INDEX_RED){if(t<0||t>90-te.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(t*Math.PI/180),i=Math.sqrt(e*e-n*n);if(!(i>=1))return Math.asin(i)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return te.ringOf("halo22",te.SIDE_PRISM_ANGLE_DEG)}static halo46(){return te.ringOf("halo46",te.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const n=te.minimumDeviationDeg(e,te.ICE_INDEX_RED),i=te.minimumDeviationDeg(e,te.ICE_INDEX_BLUE);return{id:t,angleDeg:(n+i)/2,redAngleDeg:n,blueAngleDeg:i}}static strength(t,e,n=90,i=0){const r=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=n>=0?1:i<=0?0:Math.max(0,1+n/i);return r*a*o}static formsAt(t,e=0){if(t<=-e)return[];const n=[te.halo22(),te.halo46()],i=t>0?te.parheliaDistanceDeg(t):void 0;i!==void 0&&n.push({id:"parhelia",angleDeg:i,redAngleDeg:i,blueAngleDeg:te.parheliaDistanceDeg(t,te.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:te.halo22().angleDeg}),t>0&&n.push({id:"parhelicCircle",angleDeg:t});const r=te.circumzenithalAltitudeDeg(t);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),t>te.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),t<te.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class bn{static get WATER_INDEX_RED(){return Ze.indexAt(Ze.RED_NM)}static get WATER_INDEX_BLUE(){return Ze.indexAt(Ze.BLUE_NM)}static radiusDeg(t,e){const n=(e*e-1)/(t*t-1);if(n<0||n>1)return Number.NaN;const i=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(i)/e),a=2*(i-r)+(t-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return bn.bowOf("primary",2,0)}static secondary(){return bn.bowOf("secondary",3,0)}static bowOf(t,e,n){const i=bn.radiusDeg(e,bn.WATER_INDEX_RED),r=bn.radiusDeg(e,bn.WATER_INDEX_BLUE),a=(i+r)/2;return{id:t,radiusDeg:a,redRadiusDeg:i,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:bn.primary().redRadiusDeg,toDeg:bn.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[bn.bowOf("primary",2,t),bn.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-bn.FULL_MOON_MAGNITUDE)))}static strength(t,e,n){if(n<=0)return 0;const i=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e)));return i*r}}class Dn{constructor(t){this.radius=t;const e=Dn.SEGMENTS*Dn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const n=new we;n.setAttribute("position",new de(this.positions,3)),n.setAttribute("color",new de(this.colors,3)),n.setDrawRange(0,0),this.object=new qt(n,new zi({vertexColors:!0,transparent:!0,blending:ti,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Dn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Dn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,n){this.head=t&&pn(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&pn(e.altitudeDeg,e.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,n=this.tip;if(!e||!n||this.brightness<=0){t.setDrawRange(0,0);return}const i=this.angleBetween(e,n);if(i<=0){t.setDrawRange(0,0);return}const r=i*Dn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,n,h),this.radius),o=h=>this.radius*(Dn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**Dn.FADE_POWER;let l=0;for(let h=1;h<Dn.POINTS;h++){const u=(h-1)/Dn.SEGMENTS,d=h/Dn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<Dn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),p=this.across(e,c,i,u),v=this.across(n,c,r,u),g=(m,S)=>m===0?S:0;t=this.push(t,d,g(h,a)),t=this.push(t,f,g(h,o)),t=this.push(t,p,g(u,a)),t=this.push(t,f,g(h,o)),t=this.push(t,v,g(u,o)),t=this.push(t,p,g(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.55,this.colors[i+1]=r*.75,this.colors[i+2]=r,t+1}slerp(t,e,n){const i=this.angleBetweenRadians(t,e);if(i<1e-9)return t;const r=Math.sin(i),a=Math.sin((1-n)*i)/r,o=Math.sin(n*i)/r;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const n=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class yn{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(yn.ANCHOR_BLUE-yn.ANCHOR_RED)/(1/(yn.BLUE_NM*yn.BLUE_NM)-1/(yn.RED_NM*yn.RED_NM));static A=yn.ANCHOR_RED-yn.B/(yn.RED_NM*yn.RED_NM);static indexAt(t){return yn.A+yn.B/(t*t)}}class Ca{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,n,i,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-e,c=t,l=0):(o=0,c=-n,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-n*c,d=n*o-t*l,f=t*c-e*o,p=r/2,v=a/2;for(let g=0;g<6;g++){const m=i+g*Math.PI/3,S=Math.cos(m),E=Math.sin(m);this.normals[g*3]=o*S+u*E,this.normals[g*3+1]=c*S+d*E,this.normals[g*3+2]=l*S+f*E,this.offsets[g]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=n,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-n,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,n,i,r,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-n*l,f=n*c-t*h,p=t*l-e*c,v=c*i+d*r-t*this.radius*2,g=l*i+f*r-e*this.radius*2,m=h*i+p*r-n*this.radius*2;let S=-1,E=-1/0,_=1/0;for(let J=0;J<8;J++){const nt=this.normals[J*3],at=this.normals[J*3+1],Ht=this.normals[J*3+2],$t=nt*t+at*e+Ht*n,Bt=this.offsets[J]-(nt*v+at*g+Ht*m);if($t>1e-9){const K=Bt/$t;K<_&&(_=K)}else if($t<-1e-9){const K=Bt/$t;K>E&&(E=K,S=J)}else if(Bt<0)return 0}if(S<0||E>=_)return 0;let b=0;const w=this.normals[S*3],R=this.normals[S*3+1],M=this.normals[S*3+2],A=-(w*t+R*e+M*n),P=pc.reflectance(A,1,a);o[b].x=t+2*A*w,o[b].y=e+2*A*R,o[b].z=n+2*A*M,o[b].weight=P,b++;const D=1/a,I=Math.sqrt(Math.max(0,1-D*D*(1-A*A)));let F=D*t+(D*A-I)*w,H=D*e+(D*A-I)*R,O=D*n+(D*A-I)*M,V=v+t*E,k=g+e*E,Y=m+n*E,tt=1-P;for(let J=0;J<Ca.MAX_BOUNCES&&tt>Ca.MIN_WEIGHT;J++){let nt=-1,at=1/0;for(let B=0;B<8;B++){const Et=this.normals[B*3],It=this.normals[B*3+1],Tt=this.normals[B*3+2],xt=Et*F+It*H+Tt*O;if(xt<=1e-9)continue;const Nt=(this.offsets[B]-(Et*V+It*k+Tt*Y))/xt;Nt>1e-9&&Nt<at&&(at=Nt,nt=B)}if(nt<0)break;const Ht=this.normals[nt*3],$t=this.normals[nt*3+1],Bt=this.normals[nt*3+2],K=Ht*F+$t*H+Bt*O,rt=a*Math.sqrt(Math.max(0,1-K*K));if(V+=F*at,k+=H*at,Y+=O*at,rt<1){const B=Math.sqrt(Math.max(0,1-rt*rt)),Et=pc.reflectance(K,a,1);if(o[b].x=a*F-(a*K-B)*Ht,o[b].y=a*H-(a*K-B)*$t,o[b].z=a*O-(a*K-B)*Bt,o[b].weight=tt*(1-Et),b++,b>=o.length)return b;tt*=Et}const it=2*K;F-=it*Ht,H-=it*$t,O-=it*Bt}return b}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class xe{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 Ca;emergent=Array.from({length:Ca.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);radiance=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);scratch=new Float32Array(xe.AZIMUTH_BINS*xe.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const i=xe.WORST_TILT_DEG*(xe.BEST_TILT_DEG/xe.WORST_TILT_DEG)**this.alignment;this.tilt=i*Math.PI/180}trace(t){const e=xe.AZIMUTH_BINS,n=xe.ALTITUDE_BINS,i=this.tally,r=xe.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(xe.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),g=-Math.sin(d),m=this.crystal.aimRadius,S=(this.random()*2-1)*m,E=(this.random()*2-1)*m,_=4*m*m,b=jn.SAMPLES[this.random()*jn.SAMPLES.length|0],w=this.crystal.trace(p,v,g,S,E,yn.indexAt(b.wavelengthNm),this.emergent);for(let R=0;R<w;R++){const M=this.emergent[R],A=Math.hypot(M.x,M.y,M.z);if(A<1e-9||M.weight<=0)continue;const P=M.x/A,D=M.y/A,I=M.z/A;if(P*p+D*v+I*g>a)continue;const F=Math.asin(Math.max(-1,Math.min(1,-I))),H=Math.abs(Math.atan2(-D,-P)),O=Math.min(e-1,H/Math.PI*e|0),k=(Math.min(n-1,(F+Math.PI/2)/Math.PI*n|0)*e+O)*3,Y=M.weight*_*jn.SAMPLES.length;i[k]+=Y*b.r,i[k+1]+=Y*b.g,i[k+2]+=Y*b.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=xe.AZIMUTH_BINS,e=xe.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,n,i){return this.begin(t,e,i),this.trace(n),this.harvest()}toRadiance(t,e){const n=2*Math.PI/t,i=Math.max(1,this.traced),r=4*xe.REFERENCE_MICRONS*xe.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(n*(c-o)*i*r);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const n=this.scratch,i=this.radiance;n.set(i);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?n[u+3]:n[u];i[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(i);const r=t*3;for(let a=0;a<e;a++){const o=a>0?-r:0,c=a+1<e?r:0,l=a*r;for(let h=l;h<l+r;h++)i[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const n of xe.POPULATIONS)if(e+=n.share,t<=e)return n;return xe.POPULATIONS[xe.POPULATIONS.length-1]}orient(t,e){const n=this.random()*2*Math.PI;let i=this.random()*2*Math.PI,r=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),t.orientation==="parry"&&(i=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(r,a,o,i,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),n=Math.max(1e-12,this.random()),i=1+Math.log(n+(1-n)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,i))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const n=this.gaussian()*t;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class hi{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new xe;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=hi.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const t=xe.AZIMUTH_BINS,e=xe.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new Ur(this.texels,t,e,vn,cn),this.texture.minFilter=ye,this.texture.magFilter=ye,this.texture.wrapS=gn,this.texture.wrapT=gn,this.texture.needsUpdate=!0,this.material=new Ae({uniforms:{uSource:{value:new C(0,1,0)},uUp:{value:new C(0,1,0)},uStrength:{value:0},uTint:{value:new C(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new C},uMap:{value:this.texture},uGain:{value:hi.GAIN}},vertexShader:`
5863
5863
  varying vec3 vDirection;
5864
5864
  void main() {
5865
5865
  vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
@@ -5910,11 +5910,11 @@ void main()
5910
5910
  // display fades at the edge of a fibre instead of ending on a cut line.
5911
5911
  gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
5912
5912
  }
5913
- `,transparent:!0,blending:Qn,depthWrite:!1,side:ze,fog:!1}),this.object=new qt(new ln(li.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,i,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<li.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=li.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<li.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(li.RAYS_PER_FRAME);const e=this.sky.tracedRays>=li.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=ls.toHalfFloat(e[i]),this.texels[n+1]=ls.toHalfFloat(e[i+1]),this.texels[n+2]=ls.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class km{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Ls{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:i,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new km(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,(i-20)/52)),f=Ls.MAX_DURATION_MS-d*(Ls.MAX_DURATION_MS-Ls.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,n),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,g)=>v.t-g.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class $e{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=$e.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=($e.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=$e.MAX_CONCURRENT*$e.SEGMENTS*$e.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new we;e.setAttribute("position",new de(this.positions,3)),e.setAttribute("color",new de(this.colors,3)),e.setDrawRange(0,0),this.object=new qt(e,new zi({vertexColors:!0,transparent:!0,blending:Qn,depthWrite:!1,fog:!1,side:$n})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Ls.aliveAt(this.meteors,t).slice(0,$e.MAX_CONCURRENT);let i=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=pn(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,g=E=>v*E**1.6,m=E=>this.onSphere(c,p,d+(u-d)*E),S=E=>$e.RADIUS*(($e.MIN_HALF_WIDTH_DEG+$e.BRIGHT_HALF_WIDTH_DEG*r.brightness*E)*Math.PI/180);for(let E=1;E<$e.POINTS;E++){const _=(E-1)/$e.SEGMENTS,b=E/$e.SEGMENTS;i=this.pushRibbon(i,m(_),m(b),S(_),S(b),g(_),g(b))}}e.setDrawRange(0,i),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=pn(e.altitudeDeg,e.azimuthDeg,1),[i,r]=this.basisAround(n),a=this.turn(i,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<$e.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),p=this.across(e,c,i,u),v=this.across(n,c,r,u),g=(m,S)=>m===0?S:0;t=this.push(t,d,g(h,a)),t=this.push(t,f,g(h,o)),t=this.push(t,p,g(u,a)),t=this.push(t,f,g(h,o)),t=this.push(t,v,g(u,o)),t=this.push(t,p,g(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.9,this.colors[i+1]=r*.95,this.colors[i+2]=r,t+1}turn(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:(t.x*r+e.x*a)*$e.RADIUS,y:(t.y*r+e.y*a)*$e.RADIUS,z:(t.z*r+e.z*a)*$e.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const Pl=Math.PI/180;function Fe(s,t,e,n,i=!1){const r=i?new zi({color:new ct(...e)}):new La({color:new ct(...e)}),a=new qt(t,r);return a.position.y=n,a.userData={emissive:i},a.castShadow=!i,a.receiveShadow=!i,s.add(a),a}const _f=.25,bb=.002,Eb=20;function wb(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const Bm=[.32,.32,.3],Hm=[1,.85,.5],Gm=[.25,.25,.25],Vm=[1,.97,.85],Ab=[.55,.68,.72],di=.03,fi=.05,Wm={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 mn(s,t){return s?.[t]}function pi(s,t,e,n,i,r,a,o){if(o===void 0)return;const c=new La({color:new ct(...Ab),transparent:!0,opacity:o/100}),l=new qt(new Vn(t,e,n),c);l.position.set(i,r,a),s.add(l)}const Fn=.05,Il=[.6,.58,.53],yf=[.5,.5,.48];function yr(s,t,e,n,i,r,a,o){const c=new La({color:new ct(...o),side:ze}),l=new qt(new Vn(t,e,n),c);l.position.set(i,r,a),s.add(l)}function Tb(s,t,e,n,i,r,a,o,c){const l=(n-r)/2,h=(p,v,g,m)=>{p<=0||(t?yr(s,p,v,Fn,g,o+m,a,c):yr(s,Fn,v,p,a,o+m,g,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...i].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const g=p.center-p.main/2-d;h(g,r,d+g/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function Xm(s,t,e,n,i,r,a,o,c,l){const h=(n+i)/2,u=i-n,d=(f,p,v,g)=>{f.length===0?p?yr(s,v,u,Fn,0,h,g,Il):yr(s,Fn,u,v,g,h,0,Il):Tb(s,p,v,u,f,r,g,h,Il)};d(a,!0,t*2,-e+Fn),d(o,!0,t*2,e-Fn),d(c,!1,e*2,-t+Fn),d(l,!1,e*2,t-Fn),yr(s,t*2,Fn,e*2,0,n+Fn,0,yf),yr(s,t*2,Fn,e*2,0,i-Fn,0,yf)}function Mu(s,t,e,n){switch(s){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-mi};case"front-right":return{x:t-n,z:-mi};case"behind-left":return{x:-(t-n),z:mi};case"behind-right":return{x:t-n,z:mi}}}function qm(s,t,e,n,i,r,a){const o=yu();o.scale.setScalar(n),o.rotation.y=Wm[t];const{x:c,z:l}=Mu(t,i,r,a);o.position.set(c,e,l),s.add(o)}const xu=6,_u=6,ss=3,na=1.4,ia=ss*.5,Ym=1.2,Km=.35,Rb=.75,Db=1.6;function Sf(s,t,e,n){const i=new on,r=Math.max(1,s+1),a=r*ss;Fe(i,new Vn(xu,a,_u),[.55,.54,.5],a/2);const o=xu/2,c=_u/2;for(let l=0;l<r;l++){const h=l*ss+ss/2;pi(i,na,ia,fi,0,h,-c-di,mn(t,"front")),pi(i,na,ia,fi,0,h,c+di,mn(t,"behind")),pi(i,fi,ia,na,-o-di,h,0,mn(t,"left")),pi(i,fi,ia,na,o+di,h,0,mn(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);qm(i,e,l*ss,.72,o,c,Ym);const h=u=>mn(t,u)!==void 0?[{main:na,center:0}]:[];Xm(i,o,c,l*ss,(l+1)*ss,ia,h("front"),h("behind"),h("left"),h("right"))}return i}function bf(){const s=new on;return Fe(s,new Vi(.15,.22,2,8),[.32,.22,.14],1),Fe(s,new Ia(1.4,3,8),[.16,.32,.14],3.5),s}const Ef=.275,Cb=.35,Pb=.9,Ib=34,Lb=8,Nb=1.4;function wf(){const s=new on,t=new ln(Ef,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,Cb/Ef,1);const e=je.repeatOnGrid(t,Ib,Pb,Lb,Nb),n=Fe(s,e,[.26,.28,.22],0);return n.castShadow=!1,n.userData.cropBasePositions=e.getAttribute("position").array.slice(),n.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),s}function Af(){const s=new on,t=new ln(1,7,3,0,Math.PI*2,0,Math.PI/2);return Fe(s,t,[.38,.36,.32],0),s}function Tf(s){const t=new on;return Fe(t,new Vi(.05,.08,5,8),[.28,.28,.3],2.5),Fe(t,new ln(.25,12,8),s?Hm:Bm,5.1,!0),t}const Ob=[.08,.08,.08],ns=.8,gr=1,ci=1.7,Ll=.6,_s=.4,Io=1.2,pr=.7,mi=.5,Ub=ci;function Rf(s,t,e){const n=new on;Fe(n,new Vn(1.8,1.4,4.2),[.45,.14,.14],.7),Fe(n,new Vn(ns*2,Ll,gr*2),[.4,.12,.12],ci);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Fe(n,new Vi(.4,.4,.3,12),Ob,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const i=s?Vm:Gm;for(const r of[-.7,.7])Fe(n,new ln(.15,8,6),i,.7,!0).position.set(r,.7,-2.1);if(pi(n,Io,_s,fi,0,ci,-gr-di,mn(t,"front")),pi(n,Io,_s,fi,0,ci,gr+di,mn(t,"behind")),pi(n,fi,_s,pr,-ns-di,ci,-mi,mn(t,"front-left")),pi(n,fi,_s,pr,-ns-di,ci,mi,mn(t,"behind-left")),pi(n,fi,_s,pr,ns+di,ci,-mi,mn(t,"front-right")),pi(n,fi,_s,pr,ns+di,ci,mi,mn(t,"behind-right")),e){qm(n,e,Rb,.5,ns,gr,Km);const r=(c,l)=>{const h=[];return mn(t,c)!==void 0&&h.push({main:pr,center:-mi}),mn(t,l)!==void 0&&h.push({main:pr,center:mi}),h},a=mn(t,"front")!==void 0?[{main:Io,center:0}]:[],o=mn(t,"behind")!==void 0?[{main:Io,center:0}]:[];Xm(n,ns,gr,ci-Ll/2,ci+Ll/2,_s,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const Df=new Map;function Cf(s,t){if(!s)return;const e=[[s.lengthM,t.lengthM],[s.heightM,t.heightM],[s.widthM,t.widthM]];for(const[n,i]of e)if(n!==void 0&&i>1e-6)return n/i}function Nl(s,t){return t>1e-6?s/t:1}const $m=[.95,.9,.82],Pf=[.72,.74,.78];function If(){const s=new on;Fe(s,new Vi(.25,.3,1.5,10),Pf,.75),Fe(s,new ln(.26,10,8),Pf,1.74);const t=Fe(s,new Ia(.07,.16,8),$m,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,s}function yu(){const s=new on;Fe(s,new Vi(.25,.3,1.5,10),[.3,.3,.35],.75),Fe(s,new ln(.22,10,8),[.62,.52,.46],1.72);const t=Fe(s,new Ia(.07,.16,8),$m,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,s}const Fb=17,Lf=18.5,Ol=[.16,.16,.18];function Nf(){const s=new on,t=Fe(s,new Vi(1.8,1.8,Lf*2,10),Ol,0);t.rotation.x=Math.PI/2,Fe(s,new Vn(Fb*2,.5,4.5),Ol,0);const e=Fe(s,new Vn(.4,5.5,4),Ol,3);return e.position.z=-Lf+2,s}class je{static groundUnderFootprint(t,e,n,i,r,a=0){const o=je.sizeOf(t);if(a>o.heightM)return r(e,n);const c=(i??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,g=e+Math.sin(c)*f+Math.cos(c)*v,m=n-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,r(g,m))}}return Number.isFinite(u)?u:r(e,n)}static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=t.kind==="vehicle"?Mu(e,ns,gr,Km):Mu(e,xu/2,_u/2,Ym),r=t.kind==="vehicle"?Ub:(t.occupiedFloor??0)*ss+Db,a=(t.headingDeg??0)-Wm[e]/Pl,o=this.scaleFor(t);return{x:n*o.x,z:i*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(je.BODY_NAME)??t}static repeatOnGrid(t,e,n,i,r){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*i,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*n)/2,v=-((i-1)*r)/2;let g=0;for(let S=0;S<i;S++)for(let E=0;E<e;E++,g++){const _=v+S*r,b=p+E*n;for(let w=0;w<l;w++){const R=(g*l+w)*3;u[R]=a.getX(w)+_,u[R+1]=a.getY(w),u[R+2]=a.getZ(w)+b,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[g*c.count+w]=c.getX(w)+g*l}const m=new we;return m.setAttribute("position",new Ee(u,3)),m.setAttribute("normal",new Ee(d,3)),m.setIndex(new ku(f,1)),m}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const n=new C;t.traverse(i=>{const r=i,a=r.userData.cropBasePositions,o=r.userData.cropVerticesPerClump;if(!r.isMesh||!a||!o)return;const c=r.geometry.getAttribute("position"),l=new Wt().copy(r.matrixWorld).invert();for(let h=0;h<c.count;h+=o){n.set(a[h*3],0,a[h*3+2]).applyMatrix4(r.matrixWorld),n.y=e(n.x,n.z),n.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+n.y)}c.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(n=>{const i=n,r=i.userData;if(!i.isMesh||r?.emissive)return;const a=i.material;a?.color&&a.color.set(e)})}static build(t,e){const n=t.kind==="building"?Sf(t.floors??Ad,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?bf():t.kind==="crop"?wf():t.kind==="mound"?Af():t.kind==="streetlight"?Tf(e):t.kind==="vehicle"?Rf(e,t.windows,t.witnessSide):t.kind==="aircraft"?Nf():t.kind==="entity"?If():yu();t.color&&this.paint(n,t.color);const i=this.scaleFor(t),r=new on;return n.name=je.BODY_NAME,n.scale.copy(i),r.add(n),t.headingDeg!==void 0&&(r.rotation.y=-t.headingDeg*Pl),this.addLights(r,t.lights),t.kind==="aircraft"&&this.exemptFromFog(r),r}static scaleFor(t){const e=t.sizeM;if(!e)return new C(1,1,1);const n=this.naturalSize(t.kind,t.floors);return new C(e.widthM===void 0?1:Nl(e.widthM,n.widthM),e.heightM===void 0?1:Nl(e.heightM,n.heightM),e.lengthM===void 0?1:Nl(e.lengthM,n.lengthM))}static naturalSize(t,e){const n=t==="building"?Math.max(1,(e??Ad)+1):0,i=`${t}:${n}`,r=Df.get(i);if(r)return r;const a=t==="building"?Sf(n-1,void 0,void 0,void 0):t==="tree"?bf():t==="crop"?wf():t==="mound"?Af():t==="streetlight"?Tf(!1):t==="vehicle"?Rf(!1,void 0,void 0):t==="aircraft"?Nf():t==="entity"?If():yu(),o=new ei().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),Df.set(i,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&xp(t.kind))}static applyModel(t,e,n,i={}){const r=this.bodyOf(t),a=new on;a.name=je.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*Pl,n.updateMatrixWorld(!0);const o=new ei().setFromObject(n),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=Cf(e.sizeM,c)??Cf(i.depictedSizeM,c)??1;n.scale.multiplyScalar(l);const h=o.getCenter(new C).multiplyScalar(l);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,n.traverse(u=>{u instanceof qt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(n),r.parent?(r.parent.add(a),r.removeFromParent()):t.add(a),this.dispose(r)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static exemptFromFog(t){t.traverse(e=>{if(!(e instanceof qt))return;const n=e.material;n.fog=!1,n.needsUpdate=!0})}static addLights(t,e){for(const n of e??[]){const i=wb(n.color),r=Fe(t,new ln(_f,8,6),i,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:i},r.visible=!1}}static setLights(t,e,n,i,r=0){if(!e||e.length===0)return;const a=new Map(e.map(c=>[c.id,c])),o=Math.max(1,i*bb/_f);for(const c of t.children){if(!(c instanceof qt))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?_p(h,n,n+r):Kg(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const p=r>0?u*Eb*(h.intensity??1):u;d.color.setRGB(f[0]*p,f[1]*p,f[2]*p)}c.scale.setScalar(o)}}static setLit(t,e,n){const i=e==="streetlight"?n?Hm:Bm:n?Vm:Gm;t.traverse(r=>{const a=r.userData;!(r instanceof qt)||!a.emissive||a.lightId||r.material.color.setRGB(...i)})}static dispose(t){t.traverse(e=>{if(!(e instanceof qt))return;e.geometry.dispose();const n=e.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const Ul="https://ufoathome.org/models/index.json";class zb{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??kb()}async entries(t){const e=await this.load();return t?e.filter(n=>n.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const n=await e.json();return Array.isArray(n?.models)?n.models.map(({file:i,...r})=>({...r,url:new URL(i,t).href})):void 0}catch{return}}}function kb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==Ul?[s,Ul]:[Ul]}const Bb=[{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 zb}];async function Hb(s){const{GLTFLoader:t}=await th(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:n}},[],import.meta.url),e=new t;return new Promise((n,i)=>{e.load(s,r=>n(r.scene),void 0,r=>i(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const Zm=2,Gb=5,Vb=2048;class Kn{constructor(t){this.scene=t}cloudLayers=[];cloudSignature="";setCloudLayers(t){const e=t.map(n=>n.mesh.uuid).join(",");if(e!==this.cloudSignature){this.cloudSignature=e,this.cloudLayers=t;for(const n of this.meshes.values())this.configureCloudMaterial(n.material)}}configureCloudMaterial(t){const e=this.cloudLayers,n=this.cloudSignature;t.customProgramCacheKey=()=>n,t.onBeforeCompile=i=>{if(!e.length)return;i.vertexShader=`varying vec3 cloudPoint;
5913
+ `,transparent:!0,blending:ti,depthWrite:!1,side:ze,fog:!1}),this.object=new qt(new ln(hi.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,i,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<hi.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=hi.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<hi.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(hi.RAYS_PER_FRAME);const e=this.sky.tracedRays>=hi.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=ls.toHalfFloat(e[i]),this.texels[n+1]=ls.toHalfFloat(e[i+1]),this.texels[n+2]=ls.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class km{constructor(t){this.state=t}next(){this.state=this.state+1831565813|0;let t=this.state;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}between(t,e){return t+this.next()*(e-t)}}class Ls{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:i,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new km(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,(i-20)/52)),f=Ls.MAX_DURATION_MS-d*(Ls.MAX_DURATION_MS-Ls.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,n),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,g)=>v.t-g.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class $e{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=$e.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=($e.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=$e.MAX_CONCURRENT*$e.SEGMENTS*$e.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new we;e.setAttribute("position",new de(this.positions,3)),e.setAttribute("color",new de(this.colors,3)),e.setDrawRange(0,0),this.object=new qt(e,new zi({vertexColors:!0,transparent:!0,blending:ti,depthWrite:!1,fog:!1,side:Zn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Ls.aliveAt(this.meteors,t).slice(0,$e.MAX_CONCURRENT);let i=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=pn(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,g=E=>v*E**1.6,m=E=>this.onSphere(c,p,d+(u-d)*E),S=E=>$e.RADIUS*(($e.MIN_HALF_WIDTH_DEG+$e.BRIGHT_HALF_WIDTH_DEG*r.brightness*E)*Math.PI/180);for(let E=1;E<$e.POINTS;E++){const _=(E-1)/$e.SEGMENTS,b=E/$e.SEGMENTS;i=this.pushRibbon(i,m(_),m(b),S(_),S(b),g(_),g(b))}}e.setDrawRange(0,i),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=pn(e.altitudeDeg,e.azimuthDeg,1),[i,r]=this.basisAround(n),a=this.turn(i,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<$e.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),p=this.across(e,c,i,u),v=this.across(n,c,r,u),g=(m,S)=>m===0?S:0;t=this.push(t,d,g(h,a)),t=this.push(t,f,g(h,o)),t=this.push(t,p,g(u,a)),t=this.push(t,f,g(h,o)),t=this.push(t,v,g(u,o)),t=this.push(t,p,g(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.9,this.colors[i+1]=r*.95,this.colors[i+2]=r,t+1}turn(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:(t.x*r+e.x*a)*$e.RADIUS,y:(t.y*r+e.y*a)*$e.RADIUS,z:(t.z*r+e.z*a)*$e.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const Pl=Math.PI/180;function Fe(s,t,e,n,i=!1){const r=i?new zi({color:new ct(...e)}):new La({color:new ct(...e)}),a=new qt(t,r);return a.position.y=n,a.userData={emissive:i},a.castShadow=!i,a.receiveShadow=!i,s.add(a),a}const _f=.25,bb=.002,Eb=20;function wb(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const Bm=[.32,.32,.3],Hm=[1,.85,.5],Gm=[.25,.25,.25],Vm=[1,.97,.85],Ab=[.55,.68,.72],fi=.03,pi=.05,Wm={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 mn(s,t){return s?.[t]}function mi(s,t,e,n,i,r,a,o){if(o===void 0)return;const c=new La({color:new ct(...Ab),transparent:!0,opacity:o/100}),l=new qt(new Vn(t,e,n),c);l.position.set(i,r,a),s.add(l)}const Fn=.05,Il=[.6,.58,.53],yf=[.5,.5,.48];function yr(s,t,e,n,i,r,a,o){const c=new La({color:new ct(...o),side:ze}),l=new qt(new Vn(t,e,n),c);l.position.set(i,r,a),s.add(l)}function Tb(s,t,e,n,i,r,a,o,c){const l=(n-r)/2,h=(p,v,g,m)=>{p<=0||(t?yr(s,p,v,Fn,g,o+m,a,c):yr(s,Fn,v,p,a,o+m,g,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...i].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const g=p.center-p.main/2-d;h(g,r,d+g/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function Xm(s,t,e,n,i,r,a,o,c,l){const h=(n+i)/2,u=i-n,d=(f,p,v,g)=>{f.length===0?p?yr(s,v,u,Fn,0,h,g,Il):yr(s,Fn,u,v,g,h,0,Il):Tb(s,p,v,u,f,r,g,h,Il)};d(a,!0,t*2,-e+Fn),d(o,!0,t*2,e-Fn),d(c,!1,e*2,-t+Fn),d(l,!1,e*2,t-Fn),yr(s,t*2,Fn,e*2,0,n+Fn,0,yf),yr(s,t*2,Fn,e*2,0,i-Fn,0,yf)}function Mu(s,t,e,n){switch(s){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-gi};case"front-right":return{x:t-n,z:-gi};case"behind-left":return{x:-(t-n),z:gi};case"behind-right":return{x:t-n,z:gi}}}function qm(s,t,e,n,i,r,a){const o=yu();o.scale.setScalar(n),o.rotation.y=Wm[t];const{x:c,z:l}=Mu(t,i,r,a);o.position.set(c,e,l),s.add(o)}const xu=6,_u=6,ss=3,na=1.4,ia=ss*.5,Ym=1.2,Km=.35,Rb=.75,Db=1.6;function Sf(s,t,e,n){const i=new on,r=Math.max(1,s+1),a=r*ss;Fe(i,new Vn(xu,a,_u),[.55,.54,.5],a/2);const o=xu/2,c=_u/2;for(let l=0;l<r;l++){const h=l*ss+ss/2;mi(i,na,ia,pi,0,h,-c-fi,mn(t,"front")),mi(i,na,ia,pi,0,h,c+fi,mn(t,"behind")),mi(i,pi,ia,na,-o-fi,h,0,mn(t,"left")),mi(i,pi,ia,na,o+fi,h,0,mn(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);qm(i,e,l*ss,.72,o,c,Ym);const h=u=>mn(t,u)!==void 0?[{main:na,center:0}]:[];Xm(i,o,c,l*ss,(l+1)*ss,ia,h("front"),h("behind"),h("left"),h("right"))}return i}function bf(){const s=new on;return Fe(s,new Vi(.15,.22,2,8),[.32,.22,.14],1),Fe(s,new Ia(1.4,3,8),[.16,.32,.14],3.5),s}const Ef=.275,Cb=.35,Pb=.9,Ib=34,Lb=8,Nb=1.4;function wf(){const s=new on,t=new ln(Ef,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,Cb/Ef,1);const e=je.repeatOnGrid(t,Ib,Pb,Lb,Nb),n=Fe(s,e,[.26,.28,.22],0);return n.castShadow=!1,n.userData.cropBasePositions=e.getAttribute("position").array.slice(),n.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),s}function Af(){const s=new on,t=new ln(1,7,3,0,Math.PI*2,0,Math.PI/2);return Fe(s,t,[.38,.36,.32],0),s}function Tf(s){const t=new on;return Fe(t,new Vi(.05,.08,5,8),[.28,.28,.3],2.5),Fe(t,new ln(.25,12,8),s?Hm:Bm,5.1,!0),t}const Ob=[.08,.08,.08],ns=.8,gr=1,li=1.7,Ll=.6,_s=.4,Io=1.2,pr=.7,gi=.5,Ub=li;function Rf(s,t,e){const n=new on;Fe(n,new Vn(1.8,1.4,4.2),[.45,.14,.14],.7),Fe(n,new Vn(ns*2,Ll,gr*2),[.4,.12,.12],li);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Fe(n,new Vi(.4,.4,.3,12),Ob,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const i=s?Vm:Gm;for(const r of[-.7,.7])Fe(n,new ln(.15,8,6),i,.7,!0).position.set(r,.7,-2.1);if(mi(n,Io,_s,pi,0,li,-gr-fi,mn(t,"front")),mi(n,Io,_s,pi,0,li,gr+fi,mn(t,"behind")),mi(n,pi,_s,pr,-ns-fi,li,-gi,mn(t,"front-left")),mi(n,pi,_s,pr,-ns-fi,li,gi,mn(t,"behind-left")),mi(n,pi,_s,pr,ns+fi,li,-gi,mn(t,"front-right")),mi(n,pi,_s,pr,ns+fi,li,gi,mn(t,"behind-right")),e){qm(n,e,Rb,.5,ns,gr,Km);const r=(c,l)=>{const h=[];return mn(t,c)!==void 0&&h.push({main:pr,center:-gi}),mn(t,l)!==void 0&&h.push({main:pr,center:gi}),h},a=mn(t,"front")!==void 0?[{main:Io,center:0}]:[],o=mn(t,"behind")!==void 0?[{main:Io,center:0}]:[];Xm(n,ns,gr,li-Ll/2,li+Ll/2,_s,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const Df=new Map;function Cf(s,t){if(!s)return;const e=[[s.lengthM,t.lengthM],[s.heightM,t.heightM],[s.widthM,t.widthM]];for(const[n,i]of e)if(n!==void 0&&i>1e-6)return n/i}function Nl(s,t){return t>1e-6?s/t:1}const $m=[.95,.9,.82],Pf=[.72,.74,.78];function If(){const s=new on;Fe(s,new Vi(.25,.3,1.5,10),Pf,.75),Fe(s,new ln(.26,10,8),Pf,1.74);const t=Fe(s,new Ia(.07,.16,8),$m,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,s}function yu(){const s=new on;Fe(s,new Vi(.25,.3,1.5,10),[.3,.3,.35],.75),Fe(s,new ln(.22,10,8),[.62,.52,.46],1.72);const t=Fe(s,new Ia(.07,.16,8),$m,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,s}const Fb=17,Lf=18.5,Ol=[.16,.16,.18];function Nf(){const s=new on,t=Fe(s,new Vi(1.8,1.8,Lf*2,10),Ol,0);t.rotation.x=Math.PI/2,Fe(s,new Vn(Fb*2,.5,4.5),Ol,0);const e=Fe(s,new Vn(.4,5.5,4),Ol,3);return e.position.z=-Lf+2,s}class je{static groundUnderFootprint(t,e,n,i,r,a=0){const o=je.sizeOf(t);if(a>o.heightM)return r(e,n);const c=(i??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,g=e+Math.sin(c)*f+Math.cos(c)*v,m=n-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,r(g,m))}}return Number.isFinite(u)?u:r(e,n)}static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=t.kind==="vehicle"?Mu(e,ns,gr,Km):Mu(e,xu/2,_u/2,Ym),r=t.kind==="vehicle"?Ub:(t.occupiedFloor??0)*ss+Db,a=(t.headingDeg??0)-Wm[e]/Pl,o=this.scaleFor(t);return{x:n*o.x,z:i*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(je.BODY_NAME)??t}static repeatOnGrid(t,e,n,i,r){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*i,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*n)/2,v=-((i-1)*r)/2;let g=0;for(let S=0;S<i;S++)for(let E=0;E<e;E++,g++){const _=v+S*r,b=p+E*n;for(let w=0;w<l;w++){const R=(g*l+w)*3;u[R]=a.getX(w)+_,u[R+1]=a.getY(w),u[R+2]=a.getZ(w)+b,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[g*c.count+w]=c.getX(w)+g*l}const m=new we;return m.setAttribute("position",new Ee(u,3)),m.setAttribute("normal",new Ee(d,3)),m.setIndex(new ku(f,1)),m}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const n=new C;t.traverse(i=>{const r=i,a=r.userData.cropBasePositions,o=r.userData.cropVerticesPerClump;if(!r.isMesh||!a||!o)return;const c=r.geometry.getAttribute("position"),l=new Wt().copy(r.matrixWorld).invert();for(let h=0;h<c.count;h+=o){n.set(a[h*3],0,a[h*3+2]).applyMatrix4(r.matrixWorld),n.y=e(n.x,n.z),n.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,a[u*3+1]+n.y)}c.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(n=>{const i=n,r=i.userData;if(!i.isMesh||r?.emissive)return;const a=i.material;a?.color&&a.color.set(e)})}static build(t,e){const n=t.kind==="building"?Sf(t.floors??wd,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?bf():t.kind==="crop"?wf():t.kind==="mound"?Af():t.kind==="streetlight"?Tf(e):t.kind==="vehicle"?Rf(e,t.windows,t.witnessSide):t.kind==="aircraft"?Nf():t.kind==="entity"?If():yu();t.color&&this.paint(n,t.color);const i=this.scaleFor(t),r=new on;return n.name=je.BODY_NAME,n.scale.copy(i),r.add(n),t.headingDeg!==void 0&&(r.rotation.y=-t.headingDeg*Pl),this.addLights(r,t.lights),t.kind==="aircraft"&&this.exemptFromFog(r),r}static scaleFor(t){const e=t.sizeM;if(!e)return new C(1,1,1);const n=this.naturalSize(t.kind,t.floors);return new C(e.widthM===void 0?1:Nl(e.widthM,n.widthM),e.heightM===void 0?1:Nl(e.heightM,n.heightM),e.lengthM===void 0?1:Nl(e.lengthM,n.lengthM))}static naturalSize(t,e){const n=t==="building"?Math.max(1,(e??wd)+1):0,i=`${t}:${n}`,r=Df.get(i);if(r)return r;const a=t==="building"?Sf(n-1,void 0,void 0,void 0):t==="tree"?bf():t==="crop"?wf():t==="mound"?Af():t==="streetlight"?Tf(!1):t==="vehicle"?Rf(!1,void 0,void 0):t==="aircraft"?Nf():t==="entity"?If():yu(),o=new ni().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),Df.set(i,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&Mp(t.kind))}static applyModel(t,e,n,i={}){const r=this.bodyOf(t),a=new on;a.name=je.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*Pl,n.updateMatrixWorld(!0);const o=new ni().setFromObject(n),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=Cf(e.sizeM,c)??Cf(i.depictedSizeM,c)??1;n.scale.multiplyScalar(l);const h=o.getCenter(new C).multiplyScalar(l);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,n.traverse(u=>{u instanceof qt&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(n),r.parent?(r.parent.add(a),r.removeFromParent()):t.add(a),this.dispose(r)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static exemptFromFog(t){t.traverse(e=>{if(!(e instanceof qt))return;const n=e.material;n.fog=!1,n.needsUpdate=!0})}static addLights(t,e){for(const n of e??[]){const i=wb(n.color),r=Fe(t,new ln(_f,8,6),i,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:i},r.visible=!1}}static setLights(t,e,n,i,r=0){if(!e||e.length===0)return;const a=new Map(e.map(c=>[c.id,c])),o=Math.max(1,i*bb/_f);for(const c of t.children){if(!(c instanceof qt))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?xp(h,n,n+r):Gg(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const p=r>0?u*Eb*(h.intensity??1):u;d.color.setRGB(f[0]*p,f[1]*p,f[2]*p)}c.scale.setScalar(o)}}static setLit(t,e,n){const i=e==="streetlight"?n?Hm:Bm:n?Vm:Gm;t.traverse(r=>{const a=r.userData;!(r instanceof qt)||!a.emissive||a.lightId||r.material.color.setRGB(...i)})}static dispose(t){t.traverse(e=>{if(!(e instanceof qt))return;e.geometry.dispose();const n=e.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const Ul="https://ufoathome.org/models/index.json";class zb{attribution="3D models re-hosted by UFO@home, each under its own author's licence";fetchImpl;indexUrls;loading;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??kb()}async entries(t){const e=await this.load();return t?e.filter(n=>n.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const n=await e.json();return Array.isArray(n?.models)?n.models.map(({file:i,...r})=>({...r,url:new URL(i,t).href})):void 0}catch{return}}}function kb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==Ul?[s,Ul]:[Ul]}const Bb=[{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 zb}];async function Hb(s){const{GLTFLoader:t}=await th(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:n}},[],import.meta.url),e=new t;return new Promise((n,i)=>{e.load(s,r=>n(r.scene),void 0,r=>i(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const Zm=2,Gb=5,Vb=2048;class Kn{constructor(t){this.scene=t}cloudLayers=[];cloudSignature="";setCloudLayers(t){const e=t.map(n=>n.mesh.uuid).join(",");if(e!==this.cloudSignature){this.cloudSignature=e,this.cloudLayers=t;for(const n of this.meshes.values())this.configureCloudMaterial(n.material)}}configureCloudMaterial(t){const e=this.cloudLayers,n=this.cloudSignature;t.customProgramCacheKey=()=>n,t.onBeforeCompile=i=>{if(!e.length)return;i.vertexShader=`varying vec3 cloudPoint;
5914
5914
  `+i.vertexShader,i.vertexShader=i.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
5915
5915
  cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let r=`varying vec3 cloudPoint;
5916
5916
  `,a="";e.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))i.uniforms[l+h]=u;r+=T3(l),a+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
5917
- `}),i.fragmentShader=r+i.fragmentShader,i.fragmentShader=i.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new C;up=new C;lookAt=new Wt;vertex=new C;centre=new C;right=new C;above=new C;set(t,e){this.placed=t,this.frame=e;const n=new Set(t.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of t){let r=this.meshes.get(i.sourceId);r||(r=new qt(new Wi(1,1,Kn.SEGMENTS,Kn.SEGMENTS),new zi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(Zm),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=Gb+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,e)}}place(t,e,n){const i=this.frame;if(i)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=n(Kn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<Kn.FURTHEST_NDC&&Math.abs(d.ndcY)<Kn.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,t,e,i,o,l,h,r.distanceM):this.flat(a,t,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(t,e,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=t.geometry.attributes.position,d=Kn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let g=0;g<=d;g++){const m=l+g/d*r.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(me.sizeMAt(c,i.projection.pxToDeg(r.width)),me.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(t,e,n,i,r){const a=t.geometry.attributes.position,o=Kn.SEGMENTS,c=me.sizeMAt(r,n.projection.pxToDeg(i.width)),l=me.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,r),this.lookAt.lookAt(e.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,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const n=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,n){const{shape:i}=e,r=Ql.paintExtent(i);this.extents.set(e.sourceId,r);const a=Kn.signatureOf(i,n);if(this.signatures.get(e.sourceId)===a&&t.material.map)return;this.signatures.set(e.sourceId,a);const o=Math.min(n.scale,Vb/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=t.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 Ql(f);if(p.setStarPoints(n.starPoints),p.setRoll(n.rollRad),p.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new yi(u);v.colorSpace=Pn,v.minFilter=ye,v.generateMipmaps=!1,t.material.map=v,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:n}=t;return JSON.stringify([t.kind,Math.round(n.width*10),Math.round(n.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function Wb(s,t){return JSON.stringify(s.cloudLayers)===JSON.stringify(t.cloudLayers)&&s.cloudCover===t.cloudCover&&s.cloudDarkness===t.cloudDarkness&&s.cloudBaseM===t.cloudBaseM&&s.highCloudCover===t.highCloudCover&&s.iceCrystalAlignment===t.iceCrystalAlignment&&s.lowerCloudCover===t.lowerCloudCover&&s.precipitationType===t.precipitationType&&s.precipitationIntensity===t.precipitationIntensity&&s.windDirectionDeg===t.windDirectionDeg&&s.windSpeed===t.windSpeed&&s.storm===t.storm}const Lo=900,Fl=1,Of=.5,ua=900,Xb=6371e3,qb=3e4;function Uf(s){const t=Math.sqrt(2*Xb*Math.max(s,0));return Math.max(ua,Math.min(t,qb))}const zl=.5,Ff=850,Yb=.03,No=850,kl=4,zf=1.5,kf=-1,Kb=6,Su=-4,Bf=.2,Oo=2600,$b=.97,Zb=.38,Hf=Su,Jb=3,jb=.15,Qb=.6,tE=40,eE=30,nE=[0,45,90,135,180,225,270,315],iE={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},sE=["en","fr"],Gf=880,Uo=40,Vf=60,rE=10,aE=1,oE=150,cE=55,lE=.5,hE=2.05,Wf=.265,Xf=[[0,0],...Array.from({length:8},(s,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Wf,Math.sin(e)*Wf]})],Bl=700,Hl=250/1e3,uE=12,qf=5,Gl=6,ys=[.92,.92,.95],Vl=[.15,.15,.19],Yf={snow:{fallSpeedMPerS:2,size:.3,color:new ct(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new ct(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},vr=0,Wl=0,dE=150,Kf=3e3,sa=20,fE=15,$f=vr,pE=40,Zf=1,mE=9;function Jf(s){return Zf+(mE-Zf)*s}const gE=new ct(.75,.82,.92),vE=10,ME=.5;function xE(s){return Ma(s/vE,ME,1)}const mr=200,jf=.18,Qf=.32,_E=.35,yE=new ct(.85,.9,.98),tp=5,ep=.85,np=.01;function Xl(s,t){return Math.round(s*(np+(1-np)*t))}const ip=230,sp=.7,rp=.05,SE=.6,bE=.7,EE=.15,ap=.35,wE=3,AE=1/12,TE=.5,op=8,cp=25,lp=.12,RE={Venus:new ct(1,.96,.85),Mars:new ct(1,.55,.4),Jupiter:new ct(.95,.87,.72),Saturn:new ct(.92,.86,.68)};class zn{renderer;scene=new Da;phenomena=new Kn(this.scene);camera;celestialGroup=new on;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=Bb[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 u2(16777215,0);celestialLightTarget=new Se;skyLight=new a2(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 gl;weather=pp;observerElevationM=0;groundRadius=ua;terrainRadius=ua;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new C;cloudFieldOffset=new C;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new C;rainLastVerticalFacing=-1;rainViewportSize=new Pt;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new C;sunVisible=!1;lensFlareScratch=new C;sunOcclusionRaycaster=new gl;sunOcclusionDirectionScratch=new C;sunOcclusionRightScratch=new C;sunOcclusionUpScratch=new C;ufoOcclusionRaycaster=new gl;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(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(t,e=a1(),n){this.renderer=new M3({canvas:t,antialias:!0}),this.resolution=new Me(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=da,this.camera=new En(60,t.width/Math.max(t.height,1),.1,Lo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*Hl,0,t.z*Hl);for(const n of[this.cloudUniforms,this.cirrusUniforms])n?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*_n,n=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*_n;if(t.headingDeg!==void 0?this.camera.rotation.set(n,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*_n,e,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Uf(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/ua),this.camera.far=Math.max(Lo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const i=tn(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=tn(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<oE*(i/ua))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:t,lng:e},this.terrainRadius=i;const o=++this.terrainBuildToken;cb(t,e,this.terrainProviders,i).then(({mesh:c,attribution:l})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,u=r?tn(t,e,r.lat,r.lng):void 0;h&&u&&Math.hypot(u.x,u.z)<=a&&(c.position.y=h.position.y+this.groundYOfPatch(h,u.x,u.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=aE,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(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=cE*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=Z3(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=xs(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=hE**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){this.cloudTransmissionMemo.clear(),!Wb(this.weather,t)&&(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=TE,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),je.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=je.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(t,e){const n=t.model;if(!(!n||!je.usesModel(t)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await Hb(r);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;je.applyModel(c,t,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${t.id}":`,i)}}updateDecorAnchoring(t,e,n=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=n;const i=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?tn(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&xp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=tn(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(i.x-=this.gaitOffset.eastM,i.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=je.occupantView(r),h=-(r.headingDeg??0)*_n,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+i.x,p=-r.northM+i.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*_n,-(l.headingDeg+this.indoorLookYawDeg)*_n,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=wu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.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 g=Math.hypot(d,f);h.visible=g<=dE}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*_n),l.kind==="crop"&&h.visible){const g=this.terrainMesh,m=[g?.geometry.uuid,d-(g?.position.x??0),f-(g?.position.z??0),h.position.y-(g?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==m&&(je.fitCropToGround(h,(S,E)=>this.groundYUnder(S,E)+u.altitudeM),h.userData.cropGroundKey=m)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Lo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,t-n.position.x,e-n.position.z):Wl}groundYOfPatch(t,e,n){const i=t.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return Wl;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=Ma((e-a)/(o-a)*(r-1),0,r-1),u=Ma((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Wl;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,g=(b,w)=>i.getY(b*r+w),m=g(f,d),S=g(f,d+1),E=g(f+1,d),_=g(f+1,d+1);return p+v<=1?m+(S-m)*p+(E-m)*v:_+(E-_)*(1-p)+(S-_)*(1-v)}groundUnderFootprint(t,e,n,i,r=0){return je.groundUnderFootprint(t,e,n,i,(a,o)=>this.groundYUnder(a,o),r)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t,e=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&je.setLights(i,n.lights,t,i.position.distanceTo(this.camera.position),e),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=Yg(n,t);je.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(t,e){const n=je.bodyOf(e),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new l2(16764006,tE,eE);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,e.add(r),this.streetlightLights.set(t,r)}setAstronomy(t){const e=Qh(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n);const i=mm(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,i),this.setBodyMesh("sun",t.sun,kl,new ct(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,i),this.buildPlanets(t.planets,i),this.buildComet(t.comet,i),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.buildSkyGlow(t,e.zenith),this.scene.fog instanceof lc?(this.scene.fog.color.setRGB(...n),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new lc(new ct(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=Qb;const i=t.sun.altitudeDeg>=Hf,r=!i&&t.moon.altitudeDeg>=Hf;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?t.sun:t.moon,{x:o,y:c,z:l}=pn(a.altitudeDeg,a.azimuthDeg,No);this.celestialLight.position.set(o,c,l);const h=xs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*_n));this.celestialLight.intensity=(i?Jb:jb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new $e,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=Ve.starPointsOf(t),n=Ve.flareArtifactsOf(t);e===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(t){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;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 t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,n=performance.now()+zn.COMPILE_WAIT_MS;return new Promise(i=>{const r=()=>{if(this.contextReleased)return i();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>n?i():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.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const n=this.resolution.update(t,e);n!==void 0&&this.applyPixelRatio(n)}this.drawIfDirty()}animate(t,e){const n=Math.min(e/1e3,AE);this.updateTwinkle(t/1e3),this.updatePrecipitation(t/1e3,n),this.updateRain(n),this.updateLightning(t/1e3,n),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const n=e?Math.max(1,Math.round(t)):1;if(n===this.exposureInstants&&(n===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=n,this.exposureInstantAt=e,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const e=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));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(t===void 0&&!r),t&&this.renderer.setRenderTarget(t),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i);return}e.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(!1),t&&this.renderer.setRenderTarget(t),e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const t=this.renderer.autoClear,e=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&zn.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(Fl),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(Zm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=e}decorDepthMaterial=new zi({colorWrite:!1});static markDecorDepth(t,e){t.traverse(n=>{if(!(n instanceof qt))return;const i=Array.isArray(n.material)?n.material[0]:n.material;e&&i.depthWrite!==!1&&i.blending!==Qn?n.layers.enable(Fl):n.layers.disable(Fl)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new Pt),e=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new R3(e,n)),this.exposureAccumulation.resize(e,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const n=1/this.exposureInstants;this.resolution.beginDrawing();const i=performance.now()+zn.EXPOSURE_BUDGET_MS,r=zn.exposureInstantsPerFrame(e.instantTarget.width*e.instantTarget.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,n),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i&&a<r);this.restateAt(t,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 t=new Da,e=new Hs(-1,1,1,-1,0,2),n=Uo/(Gf*Math.tan(Vf*_n/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new C).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new or(r.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(n/this.camera.aspect,n,1),t.add(c)}const i=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=i}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const t=[],e=new ei,n=new C;for(const i of this.decorObjects){if(!i.track?.length&&i.kind!=="aircraft"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r?.visible||(e.setFromObject(r),e.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[e.min.x,e.max.x])for(const u of[e.min.y,e.max.y])for(const d of[e.min.z,e.max.z]){n.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(n);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)&&t.push({x:a,y:c,width:o-a,height:l-c})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new Pt),n=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new va(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Pt);if(ga.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new ga(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){t.setFromCamera(new Pt(e,n),this.camera);return}const r=i.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new C)}directionAtScreenPoint(t,e,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(e.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return ga.ndcFor(e,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*_n);return{ndcX:e.x/-e.z/(i*r),ndcY:e.y/-e.z/r}}screenPointScratch=new C;screenPointQuaternion=new fs;screenPointSize=new Pt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(i,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Xf)this.isSunOccluded(e[0],e[1])||t++;return t/Xf.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const n=this.decorGroups.get(e.id);n&&t.push(n)}return t}isSunOccluded(t=0,e=0){const n=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,i,r))return!0;if(n.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(t,e,n,i=0){const r=this.groundMesh;if(r&&e.y<0){const g=(r.position.y-t.y)/e.y;if(g>i&&g<n){const m=t.x+e.x*g-r.position.x,S=t.z+e.z*g-r.position.z;if(Math.hypot(m,S)<=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=i,f=n;for(const[g,m,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const E=Math.min(S[0],S[1]),_=Math.max(S[0],S[1]);if(Math.abs(m)<1e-12){if(g<E||g>_)return!1;continue}const b=(E-g)/m,w=(_-g)/m;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let g=0;g<=v;g++){const m=d+(f-d)*g/v,S=t.x+e.x*m,E=t.y+e.y*m,_=t.z+e.z*m;if(E<=this.groundYUnder(S,_))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=Of;let i,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(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(t,e))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const n=this.raycaster.ray.direction,i=Math.cos(Yb*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(t,e)?void 0:r}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const n=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(n.origin,n.direction,1/0,Of)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())je.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const n=t&&e;if(t===this.animationsRunning&&n===this.framesDriven)return;const i=this.animationsRunning;this.animationsRunning=t,this.framesDriven=n,t&&!i?(this.nextLightningAtS=null,this.lastFrameTimeMs=void 0,this.resolution.reset()):!t&&this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new ln(Lo,32,16),n=e.attributes.position,i=e.getAttribute("color")??new Ee(new Float32Array(n.count*3),3);for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=P3(n.getX(a),n.getY(a),n.getZ(a)),l=k3(o,c,t.azimuthDeg,t.altitudeDeg);i.setXYZ(a,l[0],l[1],l[2])}if(i.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",i);const r=new zi({vertexColors:!0,side:ze,fog:!1,depthWrite:!1});this.skyMesh=new qt(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Uf(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new Hu(this.groundRadius,48),n=new La({color:new ct(zl,zl,zl),fog:!0});this.groundMesh=new qt(e,n),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 t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t){const e=`${t.altitudeDeg.toFixed(1)}:${t.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(";"),n=this.cloudTransmissionMemo.get(e);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const i=this.computeCloudTransmission(t);return this.cloudTransmissionMemo.set(e,i),i}cloudTransmissionMemo=new Map;computeCloudTransmission(t){const e=pn(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(e);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Pe.alphaAt(e,Math.abs(this.cloudLayerOffset()),i,this.cloudFieldOffset)*$b);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Pe.alphaAt(e,Oo,r)*Zb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,i,r){if(e.altitudeDeg<Su){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=pn(e.altitudeDeg,e.azimuthDeg,No),l=xs(e.altitudeDeg),h=this.cloudTransmission(e),u=new ct(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h);let d=this.bodyMeshes.get(t);d instanceof qt?d.material.color.copy(u):(this.disposeMesh(d),d=new qt(new ln(1,16,16),new zi({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(t,d)),d.scale.setScalar(n),d.position.set(a,o,c),this.setHitArea(t,a,o,c,n);const f=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,f,u),t==="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=Sb(),this.lensFlare.uniforms.uOpacity.value=lE,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(t.magnitude>e||t.altitudeDeg<Su){this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n);return}const{x:i,y:r,z:a}=pn(t.altitudeDeg,t.azimuthDeg,No),o=xs(t.altitudeDeg),c=new ct(o[0],o[1],o[2]),l=`${t.phase.phaseFraction<.5}:${Math.round(Ma(t.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(n);if(h instanceof or)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=hp(t.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new or(new oa({map:hp(t.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=kl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h)}h.position.set(i,r,a),this.setHitArea(n,i,r,a,kl),this.setGlare(n,i,r,a,t.magnitude,c)}setHitArea(t,e,n,i,r){let a=this.hitAreas.get(t);if(!a){const c=new oa({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new or(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,n,i);const o=r*Kb;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,i,r,a){const o=G3(r);if(o<=0){this.disposeGlare(t);return}const c=X3(o),l=this.glareSprites.get(t),h=l??new or(new oa({map:FE(),transparent:!0,blending:Qn,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=K3(o),h.position.set(e,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=wl(t.magnitude,e),r=Al(i);this.cometKey=n,this.setBodyMesh(n,t.position,zf*(.5+.5*i),new ct(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new Dn(No),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,i)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new li,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.highCloudCover(),i=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(i?.offset??this.cloudFieldOffset),n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Oo},0);return}const r=this.lowerCloudCover(),a=te.deckLitUntilDeg(te.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=te.strength(n,r,o.altitudeDeg,a)*(o===t?1:Bf),{x:l,y:h,z:u}=pn(o.altitudeDeg,o.azimuthDeg,1),d=xs(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:i?.cover??n,layerHeight:i?.layerHeight??Oo},i?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Ps,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=t.altitudeDeg>0,r=i?t:e,a=this.lowerCloudCover(),o=Bf*bn.moonlightShare(e.magnitude),c=bn.strength(n,a,r.altitudeDeg)*(i?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}=pn(r.altitudeDeg,r.azimuthDeg,1),d=xs(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new is,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=t.frame,r=Yn.galactic(n,i),a=zn.directionOf(r.centre),o=zn.directionOf(r.rotation),c=zn.directionOf(r.pole),l=new kt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=zn.directionOf(Yn.eclipticPole(n,i)),u=zn.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:zn.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Zt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new C(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:n,z:i}=pn(t.altitudeDeg,t.azimuthDeg,1);return new C(e,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of t){if(i.magnitude>e)continue;n.add(i.body);const r=wl(i.magnitude,e),a=Al(r),o=RE[i.body]??new ct(1,1,1),c=new ct(o.r*a,o.g*a,o.b*a),l=zf*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=t,a=new ma(i,r),o=ql(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>e)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(n.ra[l],n.dec[l]);if(u<kf)continue;const{x:f,y:p,z:v}=pn(u,d,Ff);c.push({x:f,y:p,z:v,brightness:wl(h,e),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of nb){if(l.mag>e)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<kf)continue;const{x:d,y:f,z:p}=pn(h,u,Ff);this.namedStars.push({star:l,direction:new C(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=vm.map((l,h)=>{const u=c.filter(E=>j3(E.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((E,_)=>{d[_*3]=E.x,d[_*3+1]=E.y,d[_*3+2]=E.z,f[_]=E.brightness,p[_]=E.phase,v[_]=E.speedFactor});const g=new we;g.setAttribute("position",new de(d,3));const m=new de(new Float32Array(u.length*3),3);g.setAttribute("color",m);let S=this.starTiers[h]?.points;if(S)S.geometry.dispose(),S.geometry=g;else{const E=new Zp({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Ts.apply(E),S=new Ko(g,E),this.celestialGroup.add(S)}return{points:S,colorAttribute:m,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let i=0;i<e.brightness.length;i++){const r=eS(e.brightness[i],{phase:e.phase[i],speedFactor:e.speedFactor[i]},t),a=Al(e.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new mc(this.celestialGroup,Bl,this.cloudRendering)),this.disposeCirrus(),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 t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,n=new ct(ys[0]+(Vl[0]-ys[0])*e,ys[1]+(Vl[1]-ys[1])*e,ys[2]+(Vl[2]-ys[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(n),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:i,uniforms:r}=Kh(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=$h(Bl);this.cloudMesh=new qt(a,i),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:n}=Kh(new ct(...ys),t,Oo,1);this.cirrusMaterial=e,this.cirrusUniforms=n,n.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new qt($h(Bl*1.04),e),this.cirrusMesh.renderOrder=qf-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 t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const n=e<0;t.scale.y=n?-1:1,t.renderOrder=n?mc.deckOrder(!0,0,1):qf}cloudLayerOffset(){const e=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Hl;return Math.sign(e||1)*Math.max(Math.abs(e),uE)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0&&!this.layeredClouds)return;const{x:i,y:r,z:a}=pn(t.altitudeDeg,t.azimuthDeg,1),o=xs(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*_n));this.layeredClouds?.setLighting(new C(i,r,a),new ct(o[0]*c,.96*o[1]*c,.88*o[2]*c),new ct(...e),new ct(...e));for(const l of n)l.sunDir.value.set(i,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.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 t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=Yf[t],n=e.poolSize,i=ql(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),p=new Float32Array(n);for(let E=0;E<n;E++){const _=i()*Math.PI*2,b=i()*e.radiusM;r[E*3]=Math.cos(_)*b,r[E*3+1]=vr+i()*(e.topYM-vr),r[E*3+2]=Math.sin(_)*b,a[E]=i()*Math.PI*2,o[E]=.7+i()*.6,c[E]=.6+i()*.8,l[E]=.4+i()*1.2}const v=new we;v.setAttribute("position",new de(r,3)),v.setDrawRange(0,Xl(n,this.weather.precipitationIntensity));const g={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new ct(...this.baseFogColor)},uTexture:{value:DE(t)},uNearFocusDistance:{value:tp},uHazeDistance:{value:e.radiusM*ep}},m=new Ae({uniforms:g,vertexShader:OE,fragmentShader:UE,transparent:!0,depthWrite:!1});this.precipitationUniforms=g;const S=new Ko(v,m);S.renderOrder=Gl,this.scene.add(S),this.precipitationPoints=S,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(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=Yf[n],r=this.weather.windDirectionDeg*_n,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.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,g=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,S=n==="snow"&&u&&d,E=n==="hail"&&f&&p&&v&&g&&m;for(let _=0,b=0;_<c.length;_+=3,b++){if(E&&f[b]>0){if(f[b]-=e,f[b]<=0){const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A,f[b]=0}else{const M=1-f[b]/v[b];c[_+1]=vr+Math.sin(Math.PI*M)*p[b],c[_]=zo(c[_]+(a+g[b])*e,i.radiusM),c[_+2]=zo(c[_+2]+(o+m[b])*e,i.radiusM)}continue}let w=0,R=0;if(S){const M=SE*u[b],A=bE*d[b];w=Math.sin(t*M*Math.PI*2+l[b])*A,R=Math.sin(t*M*Math.PI*2+l[b]+Math.PI/2)*A}if(c[_]+=(a+w)*e,c[_+1]-=i.fallSpeedMPerS*h[b]*e,c[_+2]+=(o+R)*e,c[_]=zo(c[_],i.radiusM),c[_+2]=zo(c[_+2],i.radiusM),c[_+1]<vr){if(E){p[b]=ap*(.2+Math.random()*1.6),v[b]=EE*(.5+Math.random()),f[b]=v[b];const P=Math.random()*Math.PI*2,D=wE*(p[b]/ap);g[b]=Math.cos(P)*D,m[b]=Math.sin(P)*D,c[_+1]=vr;continue}const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=Jf(this.weather.precipitationIntensity);this.rainSystem=Mb({count:Kf,radiusM:sa,heightM:fE,bottomYM:$f,overallSpeed:pE,color:gE,opacity:.85,visibleCount:Xl(Kf,this.weather.precipitationIntensity),speedStreak:xE(t),pixelSize:ip,seed:9001,nearFocusDistanceM:tp,hazeDistanceM:sa*ep,hazeColor:new ct(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Gl,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=ql(4242),e=new Float32Array(mr*3),n=new Float32Array(mr),i=new Float32Array(mr),r=new Float32Array(mr);for(let h=0;h<mr;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*sa;e[h*3]=Math.cos(u)*d,e[h*3+1]=$f,e[h*3+2]=Math.sin(u)*d,i[h]=Fo(jf,Qf),n[h]=t()*i[h],r[h]=n[h]/i[h]}const a=new we;a.setAttribute("position",new de(e,3));const o=new de(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Xl(mr,this.weather.precipitationIntensity));const c=new Ae({uniforms:{uMaxSize:{value:_E},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:yE},uTexture:{value:IE()}},vertexShader:LE,fragmentShader:NE,transparent:!0,depthWrite:!1}),l=new Ko(a,c);l.renderOrder=Gl,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:i,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 t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*_n;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-Jf(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*_n,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=sa,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+i*t),o(e.uniforms.uWindOffset.value.y+r*t)),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=sp+(1-sp)*(1-c),h=rp+(1-rp)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=ip*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=t,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*sa;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Fo(jf,Qf),i[l]=0}o[l]=i[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/lp;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+Fo(op,cp);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=lp,this.nextLightningAtS=t+Fo(op,cp),this.onLightningFlash?.())}}buildCompassLabels(){const t=Eu(navigator.languages,sE),e=iE[t];this.compassSprites=nE.map((n,i)=>{const r=e[i],a=new oa({map:zE(r),depthTest:!1,fog:!1}),o=new or(a),{x:c,y:l,z:h}=pn(0,n,Gf);return o.position.set(c,l,h),o.scale.set(Uo,Uo,1),o.renderOrder=rE,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Vf*Math.PI/360,n=Uo*Math.tan(t)/Math.tan(e);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const i=n.map;i&&i.dispose(),n.dispose()}}}const _n=Math.PI/180;function Ma(s,t,e){return Math.max(t,Math.min(e,s))}function Fo(s,t){return s+Math.random()*(t-s)}function zo(s,t){return(s%(t*2)+t*3)%(t*2)-t}let ko,Bo;function DE(s){switch(s){case"snow":return CE();case"hail":return PE()}}function CE(){if(ko)return ko;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),ko=new yi(t),ko}function PE(){if(Bo)return Bo;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Bo=new yi(t),Bo}let Ho;function IE(){if(Ho)return Ho;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Ho=new yi(t),Ho}const LE=`
5917
+ `}),i.fragmentShader=r+i.fragmentShader,i.fragmentShader=i.fragmentShader.replace("#include <opaque_fragment>",a+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new C;up=new C;lookAt=new Wt;vertex=new C;centre=new C;right=new C;above=new C;set(t,e){this.placed=t,this.frame=e;const n=new Set(t.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of t){let r=this.meshes.get(i.sourceId);r||(r=new qt(new Wi(1,1,Kn.SEGMENTS,Kn.SEGMENTS),new zi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(r.material),r.frustumCulled=!1,r.layers.set(Zm),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=Gb+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,e)}}place(t,e,n){const i=this.frame;if(i)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=n(Kn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<Kn.FURTHEST_NDC&&Math.abs(d.ndcY)<Kn.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,t,e,i,o,l,h,r.distanceM):this.flat(a,t,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(t,e,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=t.geometry.attributes.position,d=Kn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*r.height;for(let g=0;g<=d;g++){const m=l+g/d*r.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(me.sizeMAt(c,i.projection.pxToDeg(r.width)),me.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(t,e,n,i,r){const a=t.geometry.attributes.position,o=Kn.SEGMENTS,c=me.sizeMAt(r,n.projection.pxToDeg(i.width)),l=me.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,r),this.lookAt.lookAt(e.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,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const n=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,n){const{shape:i}=e,r=Ql.paintExtent(i);this.extents.set(e.sourceId,r);const a=Kn.signatureOf(i,n);if(this.signatures.get(e.sourceId)===a&&t.material.map)return;this.signatures.set(e.sourceId,a);const o=Math.min(n.scale,Vb/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=t.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 Ql(f);if(p.setStarPoints(n.starPoints),p.setRoll(n.rollRad),p.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new Si(u);v.colorSpace=Pn,v.minFilter=ye,v.generateMipmaps=!1,t.material.map=v,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:n}=t;return JSON.stringify([t.kind,Math.round(n.width*10),Math.round(n.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function Wb(s,t){return JSON.stringify(s.cloudLayers)===JSON.stringify(t.cloudLayers)&&s.cloudCover===t.cloudCover&&s.cloudDarkness===t.cloudDarkness&&s.cloudBaseM===t.cloudBaseM&&s.highCloudCover===t.highCloudCover&&s.iceCrystalAlignment===t.iceCrystalAlignment&&s.lowerCloudCover===t.lowerCloudCover&&s.precipitationType===t.precipitationType&&s.precipitationIntensity===t.precipitationIntensity&&s.windDirectionDeg===t.windDirectionDeg&&s.windSpeed===t.windSpeed&&s.storm===t.storm}const Lo=900,Fl=1,Of=.5,ua=900,Xb=6371e3,qb=3e4;function Uf(s){const t=Math.sqrt(2*Xb*Math.max(s,0));return Math.max(ua,Math.min(t,qb))}const zl=.5,Ff=850,Yb=.03,No=850,kl=4,zf=1.5,kf=-1,Kb=6,Su=-4,Bf=.2,Oo=2600,$b=.97,Zb=.38,Hf=Su,Jb=3,jb=.15,Qb=.6,tE=40,eE=30,nE=[0,45,90,135,180,225,270,315],iE={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},sE=["en","fr"],Gf=880,Uo=40,Vf=60,rE=10,aE=1,oE=150,cE=55,lE=.5,hE=2.05,Wf=.265,Xf=[[0,0],...Array.from({length:8},(s,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Wf,Math.sin(e)*Wf]})],Bl=700,Hl=250/1e3,uE=12,qf=5,Gl=6,ys=[.92,.92,.95],Vl=[.15,.15,.19],Yf={snow:{fallSpeedMPerS:2,size:.3,color:new ct(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new ct(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},vr=0,Wl=0,dE=150,Kf=3e3,sa=20,fE=15,$f=vr,pE=40,Zf=1,mE=9;function Jf(s){return Zf+(mE-Zf)*s}const gE=new ct(.75,.82,.92),vE=10,ME=.5;function xE(s){return Ma(s/vE,ME,1)}const mr=200,jf=.18,Qf=.32,_E=.35,yE=new ct(.85,.9,.98),tp=5,ep=.85,np=.01;function Xl(s,t){return Math.round(s*(np+(1-np)*t))}const ip=230,sp=.7,rp=.05,SE=.6,bE=.7,EE=.15,ap=.35,wE=3,AE=1/12,TE=.5,op=8,cp=25,lp=.12,RE={Venus:new ct(1,.96,.85),Mars:new ct(1,.55,.4),Jupiter:new ct(.95,.87,.72),Saturn:new ct(.92,.86,.68)};class zn{renderer;scene=new Da;phenomena=new Kn(this.scene);camera;celestialGroup=new on;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=Bb[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 u2(16777215,0);celestialLightTarget=new Se;skyLight=new a2(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 gl;weather=pp;observerElevationM=0;groundRadius=ua;terrainRadius=ua;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new C;cloudFieldOffset=new C;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new C;rainLastVerticalFacing=-1;rainViewportSize=new Pt;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new C;sunVisible=!1;lensFlareScratch=new C;sunOcclusionRaycaster=new gl;sunOcclusionDirectionScratch=new C;sunOcclusionRightScratch=new C;sunOcclusionUpScratch=new C;ufoOcclusionRaycaster=new gl;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(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(t,e=a1(),n){this.renderer=new M3({canvas:t,antialias:!0}),this.resolution=new Me(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=da,this.camera=new En(60,t.width/Math.max(t.height,1),.1,Lo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.cssSize.width=t,this.cssSize.height=e,this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setCloudRendering(t){t!==this.cloudRendering&&(this.cloudTransmissionMemo.clear(),this.cloudRendering=t,this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.buildClouds(),this.buildCirrus(),this.render())}setCloudOffset(t,e={}){this.cloudOffsetM.set(t.x,0,t.z),this.cloudLayerOffsetsM=e,this.layeredClouds?.setOffsets(t,e),this.cloudFieldOffset.set(t.x*Hl,0,t.z*Hl);for(const n of[this.cloudUniforms,this.cirrusUniforms])n?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*_n,n=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*_n;if(t.headingDeg!==void 0?this.camera.rotation.set(n,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*_n,e,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(Uf(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/ua),this.camera.far=Math.max(Lo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const i=tn(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=tn(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<oE*(i/ua))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:t,lng:e},this.terrainRadius=i;const o=++this.terrainBuildToken;cb(t,e,this.terrainProviders,i).then(({mesh:c,attribution:l})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,u=r?tn(t,e,r.lat,r.lng):void 0;h&&u&&Math.hypot(u.x,u.z)<=a&&(c.position.y=h.position.y+this.groundYOfPatch(h,u.x,u.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=aE,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(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=cE*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=Z3(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=xs(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=hE**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;if(this.compassSprites.some(e=>e.visible!==t)){for(const e of this.compassSprites)e.visible=t;this.developingExposure?this.exposureInstantsDone>0&&this.presentExposure():this.render()}}setWeather(t){this.cloudTransmissionMemo.clear(),!Wb(this.weather,t)&&(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=TE,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),je.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=je.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(t,e){const n=t.model;if(!(!n||!je.usesModel(t)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await Hb(r);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;je.applyModel(c,t,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${t.id}":`,i)}}updateDecorAnchoring(t,e,n=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=n;const i=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?tn(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Mp(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=tn(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(r?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(r?0:this.gaitOffset.northM)}r||(i.x-=this.gaitOffset.eastM,i.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=je.occupantView(r),h=-(r.headingDeg??0)*_n,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+i.x,p=-r.northM+i.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*_n,-(l.headingDeg+this.indoorLookYawDeg)*_n,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Eu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.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 g=Math.hypot(d,f);h.visible=g<=dE}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*_n),l.kind==="crop"&&h.visible){const g=this.terrainMesh,m=[g?.geometry.uuid,d-(g?.position.x??0),f-(g?.position.z??0),h.position.y-(g?.position.y??0),u.headingDeg,u.altitudeM].map(S=>typeof S=="number"?S.toFixed(4):S).join(":");h.userData.cropGroundKey!==m&&(je.fitCropToGround(h,(S,E)=>this.groundYUnder(S,E)+u.altitudeM),h.userData.cropGroundKey=m)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Lo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,t-n.position.x,e-n.position.z):Wl}groundYOfPatch(t,e,n){const i=t.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return Wl;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=Ma((e-a)/(o-a)*(r-1),0,r-1),u=Ma((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Wl;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),p=h-d,v=u-f,g=(b,w)=>i.getY(b*r+w),m=g(f,d),S=g(f,d+1),E=g(f+1,d),_=g(f+1,d+1);return p+v<=1?m+(S-m)*p+(E-m)*v:_+(E-_)*(1-p)+(S-_)*(1-v)}groundUnderFootprint(t,e,n,i,r=0){return je.groundUnderFootprint(t,e,n,i,(a,o)=>this.groundYUnder(a,o),r)}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t,e=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&je.setLights(i,n.lights,t,i.position.distanceTo(this.camera.position),e),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=Hg(n,t);je.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(t,e){const n=je.bodyOf(e),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new l2(16764006,tE,eE);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,e.add(r),this.streetlightLights.set(t,r)}setAstronomy(t){const e=Qh(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n);const i=mm(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,i),this.setBodyMesh("sun",t.sun,kl,new ct(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,i),this.buildPlanets(t.planets,i),this.buildComet(t.comet,i),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.buildSkyGlow(t,e.zenith),this.scene.fog instanceof lc?(this.scene.fog.color.setRGB(...n),this.scene.fog.near=this.groundRadius*.2,this.scene.fog.far=this.groundRadius):this.scene.fog=new lc(new ct(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=Qb;const i=t.sun.altitudeDeg>=Hf,r=!i&&t.moon.altitudeDeg>=Hf;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?t.sun:t.moon,{x:o,y:c,z:l}=pn(a.altitudeDeg,a.azimuthDeg,No);this.celestialLight.position.set(o,c,l);const h=xs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*_n));this.celestialLight.intensity=(i?Jb:jb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new $e,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=Ve.starPointsOf(t),n=Ve.flareArtifactsOf(t);e===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(t){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0}render(){this.restatingExposure||(this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;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 t=this.renderer.compile(this.scene,this.camera);if(!this.renderer.extensions.get("KHR_parallel_shader_compile"))return Promise.resolve();const e=this.renderer.properties,n=performance.now()+zn.COMPILE_WAIT_MS;return new Promise(i=>{const r=()=>{if(this.contextReleased)return i();for(const a of t){const o=e.get(a)?.currentProgram;(!o||o.isReady())&&t.delete(a)}t.size===0||performance.now()>n?i():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.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const n=this.resolution.update(t,e);n!==void 0&&this.applyPixelRatio(n)}this.drawIfDirty()}animate(t,e){const n=Math.min(e/1e3,AE);this.updateTwinkle(t/1e3),this.updatePrecipitation(t/1e3,n),this.updateRain(n),this.updateLightning(t/1e3,n),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=t/1e3),this.developingExposure||(this.frameDirty=!0)}setMaxPixelRatio(t){this.resolution.maximum=t,this.renderer.getPixelRatio()!==this.resolution.pixelRatio&&this.applyPixelRatio(this.resolution.pixelRatio)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const n=e?Math.max(1,Math.round(t)):1;if(n===this.exposureInstants&&(n===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=n,this.exposureInstantAt=e,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){if(this.onMapSubjectBounds){const r=this.mapSubjectBounds();t?this.exposureSubjectBounds.push(...r):this.onMapSubjectBounds(r)}const e=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));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(t===void 0&&!r),t&&this.renderer.setRenderTarget(t),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i);return}e.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(!1),t&&this.renderer.setRenderTarget(t),e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const t=this.renderer.autoClear,e=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&zn.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(Fl),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(Zm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=e}decorDepthMaterial=new zi({colorWrite:!1});static markDecorDepth(t,e){t.traverse(n=>{if(!(n instanceof qt))return;const i=Array.isArray(n.material)?n.material[0]:n.material;e&&i.depthWrite!==!1&&i.blending!==ti?n.layers.enable(Fl):n.layers.disable(Fl)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new Pt),e=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new R3(e,n)),this.exposureAccumulation.resize(e,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const n=1/this.exposureInstants;this.resolution.beginDrawing();const i=performance.now()+zn.EXPOSURE_BUDGET_MS,r=zn.exposureInstantsPerFrame(e.instantTarget.width*e.instantTarget.height);let a=0;do{this.restateAt(t,this.exposureInstantsDone);const o=this.compassSprites.map(c=>c.visible);for(const c of this.compassSprites)c.visible=!1;try{this.renderOnce(e.instantTarget)}finally{this.compassSprites.forEach((c,l)=>{c.visible=o[l]})}e.add(this.renderer,n),this.exposureInstantsDone++,a++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i&&a<r);this.restateAt(t,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 t=new Da,e=new Hs(-1,1,1,-1,0,2),n=Uo/(Gf*Math.tan(Vf*_n/2));for(const r of this.compassSprites){if(!r.visible)continue;const a=r.getWorldPosition(new C).sub(this.camera.position).normalize(),o=this.screenPointOf(a);if(!o)continue;const c=new or(r.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(n/this.camera.aspect,n,1),t.add(c)}const i=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=i}}onMapSubjectBounds;exposureSubjectBounds=[];mapSubjectBounds(){const t=[],e=new ni,n=new C;for(const i of this.decorObjects){if(!i.track?.length&&i.kind!=="aircraft"&&i.kind!=="vehicle")continue;const r=this.decorGroups.get(i.id);if(!r?.visible||(e.setFromObject(r),e.isEmpty()))continue;let a=1/0,o=-1/0,c=1/0,l=-1/0;for(const h of[e.min.x,e.max.x])for(const u of[e.min.y,e.max.y])for(const d of[e.min.z,e.max.z]){n.set(h,u,d).sub(this.camera.position).normalize();const f=this.screenPointOf(n);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)&&t.push({x:a,y:c,width:o-a,height:l-c})}return t}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new Pt),n=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new va(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Pt);if(ga.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new ga(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){t.setFromCamera(new Pt(e,n),this.camera);return}const r=i.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}pickCloudAt(t,e){return this.layeredClouds?.pickInstance(this.cloudDirectionAt(t,e))}cloudDirectionAt(t,e){return this.directionAtScreenPoint(t,e,new C)}directionAtScreenPoint(t,e,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(e.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return ga.ndcFor(e,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*_n);return{ndcX:e.x/-e.z/(i*r),ndcY:e.y/-e.z/r}}screenPointScratch=new C;screenPointQuaternion=new fs;screenPointSize=new Pt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(i,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of Xf)this.isSunOccluded(e[0],e[1])||t++;return t/Xf.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const n=this.decorGroups.get(e.id);n&&t.push(n)}return t}isSunOccluded(t=0,e=0){const n=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,i,r))return!0;if(n.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}groundBlocks(t,e,n,i=0){const r=this.groundMesh;if(r&&e.y<0){const g=(r.position.y-t.y)/e.y;if(g>i&&g<n){const m=t.x+e.x*g-r.position.x,S=t.z+e.z*g-r.position.z;if(Math.hypot(m,S)<=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=i,f=n;for(const[g,m,S]of[[t.x,e.x,l],[t.z,e.z,h]]){const E=Math.min(S[0],S[1]),_=Math.max(S[0],S[1]);if(Math.abs(m)<1e-12){if(g<E||g>_)return!1;continue}const b=(E-g)/m,w=(_-g)/m;d=Math.max(d,Math.min(b,w)),f=Math.min(f,Math.max(b,w))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let g=0;g<=v;g++){const m=d+(f-d)*g/v,S=t.x+e.x*m,E=t.y+e.y*m,_=t.z+e.z*m;if(E<=this.groundYUnder(S,_))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=Of;let i,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(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(t,e))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const n=this.raycaster.ray.direction,i=Math.cos(Yb*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(t,e)?void 0:r}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const n=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(n.origin,n.direction,1/0,Of)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())je.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;this.cancelFlush();const t=e=>{this.frame(e),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(t,e=!1){const n=t&&e;if(t===this.animationsRunning&&n===this.framesDriven)return;const i=this.animationsRunning;this.animationsRunning=t,this.framesDriven=n,t&&!i?(this.nextLightningAtS=null,this.lastFrameTimeMs=void 0,this.resolution.reset()):!t&&this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new ln(Lo,32,16),n=e.attributes.position,i=e.getAttribute("color")??new Ee(new Float32Array(n.count*3),3);for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=P3(n.getX(a),n.getY(a),n.getZ(a)),l=k3(o,c,t.azimuthDeg,t.altitudeDeg);i.setXYZ(a,l[0],l[1],l[2])}if(i.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",i);const r=new zi({vertexColors:!0,side:ze,fog:!1,depthWrite:!1});this.skyMesh=new qt(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=Uf(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new Hu(this.groundRadius,48),n=new La({color:new ct(zl,zl,zl),fog:!0});this.groundMesh=new qt(e,n),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 t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t){const e=`${t.altitudeDeg.toFixed(1)}:${t.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(";"),n=this.cloudTransmissionMemo.get(e);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const i=this.computeCloudTransmission(t);return this.cloudTransmissionMemo.set(e,i),i}cloudTransmissionMemo=new Map;computeCloudTransmission(t){const e=pn(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(e);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Pe.alphaAt(e,Math.abs(this.cloudLayerOffset()),i,this.cloudFieldOffset)*$b);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Pe.alphaAt(e,Oo,r)*Zb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,i,r){if(e.altitudeDeg<Su){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=pn(e.altitudeDeg,e.azimuthDeg,No),l=xs(e.altitudeDeg),h=this.cloudTransmission(e),u=new ct(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h);let d=this.bodyMeshes.get(t);d instanceof qt?d.material.color.copy(u):(this.disposeMesh(d),d=new qt(new ln(1,16,16),new zi({color:u,fog:!1})),this.celestialGroup.add(d),this.bodyMeshes.set(t,d)),d.scale.setScalar(n),d.position.set(a,o,c),this.setHitArea(t,a,o,c,n);const f=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,f,u),t==="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=Sb(),this.lensFlare.uniforms.uOpacity.value=lE,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(t.magnitude>e||t.altitudeDeg<Su){this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n);return}const{x:i,y:r,z:a}=pn(t.altitudeDeg,t.azimuthDeg,No),o=xs(t.altitudeDeg),c=new ct(o[0],o[1],o[2]),l=`${t.phase.phaseFraction<.5}:${Math.round(Ma(t.phase.illuminatedFraction,0,1)*500)}`;let h=this.bodyMeshes.get(n);if(h instanceof or)h.userData.phaseKey!==l&&(h.material.map?.dispose(),h.material.map=hp(t.phase),h.userData.phaseKey=l),h.material.color.copy(c);else{this.disposeMesh(h),h=new or(new oa({map:hp(t.phase),color:c,fog:!1})),h.userData.phaseKey=l;const u=kl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h)}h.position.set(i,r,a),this.setHitArea(n,i,r,a,kl),this.setGlare(n,i,r,a,t.magnitude,c)}setHitArea(t,e,n,i,r){let a=this.hitAreas.get(t);if(!a){const c=new oa({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});a=new or(c),this.celestialGroup.add(a),this.hitAreas.set(t,a)}a.position.set(e,n,i);const o=r*Kb;a.scale.set(o,o,1)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,i,r,a){const o=G3(r);if(o<=0){this.disposeGlare(t);return}const c=X3(o),l=this.glareSprites.get(t),h=l??new or(new oa({map:FE(),transparent:!0,blending:ti,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=K3(o),h.position.set(e,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=wl(t.magnitude,e),r=Al(i);this.cometKey=n,this.setBodyMesh(n,t.position,zf*(.5+.5*i),new ct(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new Dn(No),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,i)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new hi,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.highCloudCover(),i=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(i?.offset??this.cloudFieldOffset),n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Oo},0);return}const r=this.lowerCloudCover(),a=te.deckLitUntilDeg(te.DECK_HEIGHT_M),o=t.altitudeDeg>-a?t:e,c=te.strength(n,r,o.altitudeDeg,a)*(o===t?1:Bf),{x:l,y:h,z:u}=pn(o.altitudeDeg,o.azimuthDeg,1),d=xs(o.altitudeDeg);this.iceHalos.update({x:l,y:h,z:u},o.altitudeDeg,c,[d[0],d[1],d[2]],{cover:i?.cover??n,layerHeight:i?.layerHeight??Oo},i?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(t,e){this.rainbow||(this.rainbow=new Ps,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=t.altitudeDeg>0,r=i?t:e,a=this.lowerCloudCover(),o=Bf*bn.moonlightShare(e.magnitude),c=bn.strength(n,a,r.altitudeDeg)*(i?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}=pn(r.altitudeDeg,r.azimuthDeg,1),d=xs(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new is,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=t.frame,r=Yn.galactic(n,i),a=zn.directionOf(r.centre),o=zn.directionOf(r.rotation),c=zn.directionOf(r.pole),l=new kt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=zn.directionOf(Yn.eclipticPole(n,i)),u=zn.directionOf(t.sun),d=u.clone().addScaledVector(h,-u.dot(h)).normalize();this.skyGlow.update({galactic:l,eclipticPole:h,sunLongitude:d,sunDirection:u,sunAltitudeDeg:t.sun.altitudeDeg,moon:{direction:zn.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Zt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new C(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:n,z:i}=pn(t.altitudeDeg,t.azimuthDeg,1);return new C(e,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of t){if(i.magnitude>e)continue;n.add(i.body);const r=wl(i.magnitude,e),a=Al(r),o=RE[i.body]??new ct(1,1,1),c=new ct(o.r*a,o.g*a,o.b*a),l=zf*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=t,a=new ma(i,r),o=ql(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>e)break;const{altitudeDeg:u,azimuthDeg:d}=a.position(n.ra[l],n.dec[l]);if(u<kf)continue;const{x:f,y:p,z:v}=pn(u,d,Ff);c.push({x:f,y:p,z:v,brightness:wl(h,e),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const l of nb){if(l.mag>e)continue;const{altitudeDeg:h,azimuthDeg:u}=a.position(l.raHours,l.decDeg);if(h<kf)continue;const{x:d,y:f,z:p}=pn(h,u,Ff);this.namedStars.push({star:l,direction:new C(d,f,p).normalize(),altitudeDeg:h})}this.starTiers=vm.map((l,h)=>{const u=c.filter(E=>j3(E.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((E,_)=>{d[_*3]=E.x,d[_*3+1]=E.y,d[_*3+2]=E.z,f[_]=E.brightness,p[_]=E.phase,v[_]=E.speedFactor});const g=new we;g.setAttribute("position",new de(d,3));const m=new de(new Float32Array(u.length*3),3);g.setAttribute("color",m);let S=this.starTiers[h]?.points;if(S)S.geometry.dispose(),S.geometry=g;else{const E=new Zp({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Ts.apply(E),S=new Ko(g,E),this.celestialGroup.add(S)}return{points:S,colorAttribute:m,brightness:f,phase:p,speedFactor:v}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let i=0;i<e.brightness.length;i++){const r=eS(e.brightness[i],{phase:e.phase[i],speedFactor:e.speedFactor[i]},t),a=Al(e.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new mc(this.celestialGroup,Bl,this.cloudRendering)),this.disposeCirrus(),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 t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,n=new ct(ys[0]+(Vl[0]-ys[0])*e,ys[1]+(Vl[1]-ys[1])*e,ys[2]+(Vl[2]-ys[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(n),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:i,uniforms:r}=Kh(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,r.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=$h(Bl);this.cloudMesh=new qt(a,i),this.faceCloudDeck(this.cloudMesh,this.cloudLayerOffset()),this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type!=="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.lowerCloudCover??this.weather.cloudCover}highCloudCover(){return this.weather.cloudLayers?1-this.weather.cloudLayers.filter(t=>t.type==="cirrus").reduce((t,e)=>t*(1-e.coverage),1):this.weather.highCloudCover}buildCirrus(){const t=this.weather.highCloudCover??0;if(this.layeredClouds||t<=0){this.disposeCirrus();return}if(this.cirrusMesh&&this.cirrusUniforms){this.cirrusUniforms.coverage.value=t,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const{material:e,uniforms:n}=Kh(new ct(...ys),t,Oo,1);this.cirrusMaterial=e,this.cirrusUniforms=n,n.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new qt($h(Bl*1.04),e),this.cirrusMesh.renderOrder=qf-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 t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&this.faceCloudDeck(this.cloudMesh,t)}faceCloudDeck(t,e){const n=e<0;t.scale.y=n?-1:1,t.renderOrder=n?mc.deckOrder(!0,0,1):qf}cloudLayerOffset(){const e=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*Hl;return Math.sign(e||1)*Math.max(Math.abs(e),uE)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0&&!this.layeredClouds)return;const{x:i,y:r,z:a}=pn(t.altitudeDeg,t.azimuthDeg,1),o=xs(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*_n));this.layeredClouds?.setLighting(new C(i,r,a),new ct(o[0]*c,.96*o[1]*c,.88*o[2]*c),new ct(...e),new ct(...e));for(const l of n)l.sunDir.value.set(i,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.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 t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=Yf[t],n=e.poolSize,i=ql(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),p=new Float32Array(n);for(let E=0;E<n;E++){const _=i()*Math.PI*2,b=i()*e.radiusM;r[E*3]=Math.cos(_)*b,r[E*3+1]=vr+i()*(e.topYM-vr),r[E*3+2]=Math.sin(_)*b,a[E]=i()*Math.PI*2,o[E]=.7+i()*.6,c[E]=.6+i()*.8,l[E]=.4+i()*1.2}const v=new we;v.setAttribute("position",new de(r,3)),v.setDrawRange(0,Xl(n,this.weather.precipitationIntensity));const g={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new ct(...this.baseFogColor)},uTexture:{value:DE(t)},uNearFocusDistance:{value:tp},uHazeDistance:{value:e.radiusM*ep}},m=new Ae({uniforms:g,vertexShader:OE,fragmentShader:UE,transparent:!0,depthWrite:!1});this.precipitationUniforms=g;const S=new Ko(v,m);S.renderOrder=Gl,this.scene.add(S),this.precipitationPoints=S,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(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=Yf[n],r=this.weather.windDirectionDeg*_n,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.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,g=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,S=n==="snow"&&u&&d,E=n==="hail"&&f&&p&&v&&g&&m;for(let _=0,b=0;_<c.length;_+=3,b++){if(E&&f[b]>0){if(f[b]-=e,f[b]<=0){const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A,f[b]=0}else{const M=1-f[b]/v[b];c[_+1]=vr+Math.sin(Math.PI*M)*p[b],c[_]=zo(c[_]+(a+g[b])*e,i.radiusM),c[_+2]=zo(c[_+2]+(o+m[b])*e,i.radiusM)}continue}let w=0,R=0;if(S){const M=SE*u[b],A=bE*d[b];w=Math.sin(t*M*Math.PI*2+l[b])*A,R=Math.sin(t*M*Math.PI*2+l[b]+Math.PI/2)*A}if(c[_]+=(a+w)*e,c[_+1]-=i.fallSpeedMPerS*h[b]*e,c[_+2]+=(o+R)*e,c[_]=zo(c[_],i.radiusM),c[_+2]=zo(c[_+2],i.radiusM),c[_+1]<vr){if(E){p[b]=ap*(.2+Math.random()*1.6),v[b]=EE*(.5+Math.random()),f[b]=v[b];const P=Math.random()*Math.PI*2,D=wE*(p[b]/ap);g[b]=Math.cos(P)*D,m[b]=Math.sin(P)*D,c[_+1]=vr;continue}const M=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[_]=Math.cos(M)*A,c[_+1]=i.topYM,c[_+2]=Math.sin(M)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=Jf(this.weather.precipitationIntensity);this.rainSystem=Mb({count:Kf,radiusM:sa,heightM:fE,bottomYM:$f,overallSpeed:pE,color:gE,opacity:.85,visibleCount:Xl(Kf,this.weather.precipitationIntensity),speedStreak:xE(t),pixelSize:ip,seed:9001,nearFocusDistanceM:tp,hazeDistanceM:sa*ep,hazeColor:new ct(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Gl,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=ql(4242),e=new Float32Array(mr*3),n=new Float32Array(mr),i=new Float32Array(mr),r=new Float32Array(mr);for(let h=0;h<mr;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*sa;e[h*3]=Math.cos(u)*d,e[h*3+1]=$f,e[h*3+2]=Math.sin(u)*d,i[h]=Fo(jf,Qf),n[h]=t()*i[h],r[h]=n[h]/i[h]}const a=new we;a.setAttribute("position",new de(e,3));const o=new de(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Xl(mr,this.weather.precipitationIntensity));const c=new Ae({uniforms:{uMaxSize:{value:_E},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:yE},uTexture:{value:IE()}},vertexShader:LE,fragmentShader:NE,transparent:!0,depthWrite:!1}),l=new Ko(a,c);l.renderOrder=Gl,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:i,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 t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*_n;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-Jf(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*_n,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=sa,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+i*t),o(e.uniforms.uWindOffset.value.y+r*t)),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=sp+(1-sp)*(1-c),h=rp+(1-rp)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=ip*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=t,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*sa;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Fo(jf,Qf),i[l]=0}o[l]=i[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/lp;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+Fo(op,cp);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=lp,this.nextLightningAtS=t+Fo(op,cp),this.onLightningFlash?.())}}buildCompassLabels(){const t=wu(navigator.languages,sE),e=iE[t];this.compassSprites=nE.map((n,i)=>{const r=e[i],a=new oa({map:zE(r),depthTest:!1,fog:!1}),o=new or(a),{x:c,y:l,z:h}=pn(0,n,Gf);return o.position.set(c,l,h),o.scale.set(Uo,Uo,1),o.renderOrder=rE,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Vf*Math.PI/360,n=Uo*Math.tan(t)/Math.tan(e);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const i=n.map;i&&i.dispose(),n.dispose()}}}const _n=Math.PI/180;function Ma(s,t,e){return Math.max(t,Math.min(e,s))}function Fo(s,t){return s+Math.random()*(t-s)}function zo(s,t){return(s%(t*2)+t*3)%(t*2)-t}let ko,Bo;function DE(s){switch(s){case"snow":return CE();case"hail":return PE()}}function CE(){if(ko)return ko;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),ko=new Si(t),ko}function PE(){if(Bo)return Bo;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Bo=new Si(t),Bo}let Ho;function IE(){if(Ho)return Ho;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Ho=new Si(t),Ho}const LE=`
5918
5918
  uniform float uMaxSize;
5919
5919
  uniform float uScale;
5920
5920
  attribute float aLife;
@@ -5979,5 +5979,5 @@ void main() {
5979
5979
  float blur = max(vNearBlur, vHaze);
5980
5980
  gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
5981
5981
  }
5982
- `;let Go;function FE(){if(Go)return Go;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Go=new yi(t),Go}function hp(s){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),i=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.fill();const l=Ma(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,u=i*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,i,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,i,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,i,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,i,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new yi(e)}function zE(s){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(s,64,68),new yi(t)}function ql(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const Yl=7.5,Kl=9;class hi{static cache=new Map;static load(t){let e=hi.cache.get(t);return e||(e=fetch(t).then(n=>n.arrayBuffer()).then(n=>hi.parse(n)),hi.cache.set(t,e)),e}static upTo(t,e){const n=t.filter((a,o)=>o===0||t[o-1].magnitudeLimit<e);if(n.length<=1)return hi.load(t[0].url);const i=n.map(a=>a.url).join(`
5983
- `);let r=hi.cache.get(i);return r||(r=Promise.all(n.map(a=>hi.load(a.url))).then(a=>a.reduce((o,c)=>hi.concat(o,c))),hi.cache.set(i,r)),r}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*n,e),dec:new Float32Array(t,1*n,e),mag:new Float32Array(t,2*n,e),ci:new Float32Array(t,3*n,e)}}static concat(t,e){const n=(i,r)=>{const a=new Float32Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),a};return{count:t.count+e.count,ra:n(t.ra,e.ra),dec:n(t.dec,e.dec),mag:n(t.mag,e.mag),ci:n(t.ci,e.ci)}}}const kE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,BE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,HE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,GE=20,VE=1;class WE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const i=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=i==="hail"?Math.min(1,e*1.3+.2):i==="rain"?e:0,i!==this.ambientKey){this.ambientKey=i;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(kE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/GE,1);const r=n>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(BE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:i}=this.requested;this.setAmbient(e,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(HE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,i){if(e!==n()){t?.source.stop();return}i(t)}async startLoop(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Pi{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[i,r]=this.perifocalAxes(),a=Math.sqrt(Pi.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),i=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Pi.stumpffC(i),o=e-n*n*n/Math.sqrt(Pi.SUN_GM_AU3_PER_DAY2)*Pi.stumpffS(i);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(Pi.SUN_GM_AU3_PER_DAY2)*Math.abs(t),i=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Pi.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;i(r)<n;)r*=2;let a=0;for(let o=0;o<Pi.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;i(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:i*a-r*o*c,y:r*a+i*o*c,z:o*l},{x:-i*o-r*a*c,y:-r*o+i*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const Jm=[{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(t){const e=this.julianDayOf(t);return Jm.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(t,e,n){const i=ke(e),r=this.earthPositionAt(i),a=this.apparentPositionOf(t,2451545+i.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,i,e,n),u=this.horizontalOf(o,i,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const i=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(i,t.peakMagnitude)}static tailEndAt(t,e,n,i,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/i,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const i=this.orbitOf(t);let r=i.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=i.positionAt(e-o)}return r}static horizontalOf(t,e,n,i){const r=Jo(KS(),new ge(t.x,t.y,t.z,e)),a=Jo($S(e),r),o=AS(e,new Qu(i.lat,i.lng,i.elevationM)),c=new ge(a.x-o.x,a.y-o.y,a.z-o.z,e),l=Um(c);return Lc(l.ra,l.dec,n,i)}static earthPositionAt(t){return Jo(YS(),hs(St.Earth,t))}static julianDayOf(t){return 2451545+ke(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new Pi(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const qE=[{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}],yc=6.5;class $l{static activeAt(t){return qE.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),i=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,i),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,i=yc){if(e<=0)return 0;const r=yc-i;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return Lc(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class Ie{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=ke(t),i=new Ju(0,ES(t).elon-90,1),r=Jo(ZS(n),Om(i,n)),a=Um(r);return Lc(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=yc){const n=Ie.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),i=yc-e;return(Ie.QUIET_RATE_PER_HOUR+n)/Math.pow(Ie.POPULATION_INDEX,i)}static schedule(t){const e=new km(t.seed^1542469173);return Ls.schedule(t).map(n=>{const i=Ie.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=Ie.turnAround(i,e.between(0,360)),o={x:i.x*Math.cos(r)+a.x*Math.sin(r),y:i.y*Math.cos(r)+a.y*Math.sin(r),z:i.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:Ie.toHorizontal(o),bearingDeg:Ie.bearingFrom(o,i)}})}static turnAround(t,e){const[n,i]=Ie.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+i.x*Math.sin(r),y:n.y*Math.cos(r)+i.y*Math.sin(r),z:n.z*Math.cos(r)+i.z*Math.sin(r)}}static bearingFrom(t,e){const[n,i]=Ie.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=Ie.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*i.x+a.y*i.y+a.z*i.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Ie.normalise(Ie.cross(t,e));return[n,Ie.normalise(Ie.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=Ie.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Ie.turnAround(e,t.bearingDeg),i=t.fromRadiantDeg*Math.PI/180;return Ie.toHorizontal({x:e.x*Math.cos(i)+n.x*Math.sin(i),y:e.y*Math.cos(i)+n.y*Math.sin(i),z:e.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,i=Math.cos(e);return{x:i*Math.sin(n),y:Math.sin(e),z:-i*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class YE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=me.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=me.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:me.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:me.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Ns{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Ns.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const n=Ns.degOver(t)/e;return n<1?1:Math.min(Ns.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class fn{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 Ns.DEG_PER_SECOND*3600}static graspOf(t,e={}){const n=e.exposureSeconds??t.exposureSeconds,i=e.fNumber??t.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return fn.EYE;const r=e.focalLengthMm??t.frame?.focalLengthMm??fn.UNKNOWN_CAMERA_FOCAL_MM,a=r/i,o=fn.resolutionArcsec(t,r,a);return{apertureMm:a,exposureSeconds:Math.min(n,fn.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,n){const r=(t.detailUm??fn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*fn.ARCSEC_PER_RADIAN,a=1.22*fn.WAVELENGTH_M/(n/1e3)*fn.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(t){return t/fn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const n=fn.graspOf(t,e),i=fn.EYE,r=(n.apertureMm/i.apertureMm)**2,a=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(t,e){const n=e.fieldOfViewDeg===void 0?void 0:Ve.focalLengthMmFor(t,e.fieldOfViewDeg);return fn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:n,exposureSeconds:e.exposureSeconds})}}class Ii{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(t,e,n,i,r){if(!(i>0))return 1;const a=r>0?Ii.travelDegOver(t,e,n,n+i*1e3)/r/Ii.PIXELS_PER_INSTANT:0,o=Ii.flashesOver(t,i)*Ii.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Ii.MAX_INSTANTS,c)}static travelDegOver(t,e,n,i){let r=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Ii.directionAt(a,e,n),c=Ii.directionAt(a,e,i),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(t,e){let n=0;for(const i of t)for(const r of i.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*e}static directionAt(t,e,n){const i=wu(t,n),r=i.eastM,a=i.altitudeM-e,o=i.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}}}const up=111320,ra=Math.PI/180,KE=1.02,$E=1;class xa{static of(t,e){const n=xa.sightings(t,e);if(n.length<2)return;const i=xa.baseline(n);if(!i)return;const{near:r,far:a,closedM:o}=i,c=Math.tan(a.widthDeg/2*ra)===0?0:Math.tan(r.widthDeg/2*ra)/Math.tan(a.widthDeg/2*ra);if(c<KE)return;const l=o/(c-1),h=me.sizeMAt(l,r.widthDeg),u=n.map(d=>({t:d.t,m:me.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(t,e){return t.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===e)?.shape,r=i?.angular?.widthDeg,a=Qe(t,n.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:n.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??a.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(t){let e;for(const n of t)for(const i of t){if(n.t>=i.t)continue;const r=xa.closedAlongSight(n,i),[a,o,c]=r>=0?[i,n,r]:[n,i,-r];c<$E||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const n=(e.lat-t.lat)*up,i=(e.lng-t.lng)*up*Math.cos(t.lat*ra),r=(t.sightAzimuthDeg??0)*ra;return n*Math.cos(r)+i*Math.sin(r)}}class dn{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:dn.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:dn.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:dn.atLeastNearest(t.derivedM),basis:"derived"};const e=dn.largest(t.range?.minM,t.crossing?.behindM),n=dn.smallest(t.range?.maxM,t.crossing?.inFrontM),i=e===void 0?void 0:e*dn.MARGIN,r=n===void 0?void 0:n/dn.MARGIN;return i!==void 0&&r!==void 0?{distanceM:dn.atLeastNearest(i<=r?Math.sqrt(i*r):i),basis:"bounded"}:i!==void 0?{distanceM:dn.atLeastNearest(i),basis:"bounded"}:r!==void 0&&r<dn.CONVENTIONAL_M?{distanceM:dn.atLeastNearest(r),basis:"bounded"}:{distanceM:dn.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(dn.NEAREST_M,t)}static largest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.min(...e)}}Tp();const ZE={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"}},JE=["en","fr"],jE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},QE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},dp="comet:",tw={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"}},ew=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,nw=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,iw=-18,sw={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Zl={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class rw extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",Sr,br]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new C;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new WE;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(i,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=Eu(ec.preferencesFor(this),JE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(t,this.said.read(u.title)||tw[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,p=d.altitudeDeg,v=(p<0?QE:jE)[c];this.showHoverTooltip(t,v.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(p)))));return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(dp)?t.slice(dp.length):void 0;return(n?Jm.find(r=>r.id===n):void 0)?.name[e]??ZE[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Ha(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${ag}</style>${rg}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new zn(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(eh),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",e=>this.lookToward(e.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=e=>this.ufoElement.setMapSubjectBounds(e),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new rs(ec.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 t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,n){if(t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&n!==e){const i=Number(n);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(i)&&i>0?i:Math.min(window.devicePixelRatio||1,2))}(t===Sr||t===br)&&n!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[Sr,br])this.ufoElement.toggleAttribute(t,this.hasAttribute(t))}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=Qe(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="witness"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=tn(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const r=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((r-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){this.sightingData=await gp.json(t)}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=me.CANVAS_HEIGHT_PX,n=Ve.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=[{magnitudeLimit:Yl,url:this.getAttribute("star-catalog-src")??ew},{magnitudeLimit:Kl,url:this.getAttribute("deep-star-catalog-src")??nw}],e=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=e>Yl?Kl:Yl;const i=await hi.upTo(t,e);n===this.starCatalogRequest&&(this.starCatalog=i,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Kl||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=fn.gainFor(t.instrument,{fNumber:Qe(t,0)?.fNumber,fieldOfViewDeg:Bn.fovOf(t,0),exposureSeconds:t.exposure});return mm(iw,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=this.exposureSeconds(),n=this.degreesPerPixelAt(t),i=Ns.instants(e,n),r=Math.max(i,this.ufoElement.exposureTimes(t).length,Ii.instants(this.ufoElement.sighting.decor,Qe(this.ufoElement.sighting,t)?.elevationM??0,t,e,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=e*1e3;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t+a*o/r,{sky:Math.floor(o*i/r)!==Math.floor((o-1)*i/r),stepMs:a/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Bn.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const n=this.ufoElement.sighting;this.setWeather(Ha(n,t)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,t),this.sceneRenderer.setDecor(n.decor);const i=Qe(n,t),r=Qe(n,0),a=Ha(n,0),o=Object.fromEntries(jo(Ha(n,t)).map(E=>[E.id,ld(t,n.weatherTrack,a,r,i,E.id)]));if(this.sceneRenderer.setCloudOffset(ld(t,n.weatherTrack,a,r,i),o),this.sceneRenderer.setObserverPose(i??Zl),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(fn.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:Bn.fovOf(n,t),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Ge.of(n)?.offsetAt(t)??Ge.STILL),this.sceneRenderer.updateDecorAnchoring(Qe(n,0),i,t),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(t),e&&!e.sky)return;const c=i?.lat??Zl.lat,l=i?.lng??Zl.lng,h=vf(n.event.time??{},l,n.event.utcOffsetHours);if(!h){this.sceneRenderer.setAstronomy(sw);return}const u=new Date(h.getTime()+t),d={lat:c,lng:l,elevationM:i?.elevationM??0},f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Ns.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(u.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(d.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const g={...Dl("Sun",u,d),magnitude:Cl("Sun",u)},m={...Dl("Moon",u,d),phase:jS(u),magnitude:Cl("Moon",u)},S=JS.map(E=>({body:E,position:Dl(E,u,d),magnitude:Cl(E,u)}));this.sceneRenderer.setAstronomy({sun:g,moon:m,planets:S,comet:this.cometAt(u,d),stars:this.starCatalog?{catalog:this.starCatalog,date:u,observer:d}:void 0,frame:{date:u,observer:d}}),this.ufoElement.setSunAltitude(g.altitudeDeg)}cometAt(t,e){const n=XE.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const n=e.timeline,i=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of n.sourceIds){const v=n.getInterpolatedShapeAt(t,p);if(!v)continue;const g={...v,bounds:{...v.bounds,x:v.bounds.x+r.x,y:v.bounds.y+r.y}};o.set(p,g);const m=v.aim?this.sceneRenderer.screenPointOf(Kn.directionOf(v.aim,this.directionScratch)):{ndcX:(g.bounds.x+g.bounds.width/2)/i.width*2-1,ndcY:-((g.bounds.y+g.bounds.height/2)/i.height*2-1)},S=m!==void 0&&Math.abs(m.ndcX)<=1&&Math.abs(m.ndcY)<=1,E=S?this.sceneRenderer.decorDistancesAt(m.ndcX,m.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const _=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(_,E);const w=xa.of(e,p);c.set(p,dn.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&_>0?me.distanceMAt(w.widthM,_):void 0,range:b.distanceRangeAt(_),crossing:E}))}for(const[p,v]of o)for(const[g,m]of o){if(g===p||m.transparency>=1||m.bounds.width*m.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=m.bounds.x&&v.bounds.y>=m.bounds.y&&v.bounds.x+v.bounds.width<=m.bounds.x+m.bounds.width&&v.bounds.y+v.bounds.height<=m.bounds.y+m.bounds.height))continue;const E=c.get(g);E&&c.set(p,{distanceM:E.distanceM*.999,basis:E.basis});break}this.depths=c;const h=n.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=(Qe(e,t)?.rollDeg??0)+(Ge.of(e)?.offsetAt(t)??Ge.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:Ve.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(i)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,i=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?vf(n,e.lng,t.event.utcOffsetHours):void 0;if(!i||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(e.lat*1e3),c=Ie.schedule({ratePerHour:Ie.observedRatePerHour(Ie.apexPosition(i,r).altitudeDeg),durationMs:a,velocityKmS:Ie.TYPICAL_VELOCITY_KM_S,seed:o}),l=$l.activeAt(i).map(u=>{const d=$l.radiantPosition(u.shower,i,r);return{entry:u,position:d,rate:$l.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=Ls.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(t){const e=this.ufoElement.sighting,n=e.instrument,i=n.frame,r=Qe(e,t),a=r?.fNumber??n.fNumber;if(!i||a===void 0)return;const o=Ve.focalLengthMmFor(n,Bn.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Oi.of(e.instrument,me.CANVAS_HEIGHT_PX,Bn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new YE,this.sizeEstimates.set(t,e)),e}}const fp="rr0-scene";function aw(){Tp(),customElements.get(fp)||customElements.define(fp,rw)}aw();export{Pv as $,uw as A,de as B,ct as C,u2 as D,qt as E,vw as F,fw as G,$p as H,dw as I,pw as J,Ko as K,Oa as L,mw as M,Ya as N,Se as O,l2 as P,fs as Q,Ea as R,Pn as S,ow as T,on as U,Pt as V,En as W,hw as X,Hs as Y,Kp as Z,gw as _,lw as a,sc as a0,Gh as a1,hc as a2,en as a3,em as a4,Gu as a5,Vu as a6,jt as a7,us as a8,Na as a9,ei as aa,Hi as ab,cw as b,_w as c,ac as d,xw as e,Wt as f,C as g,d0 as h,Mw as i,yw as j,Tv as k,Ds as l,Bc as m,I1 as n,ye as o,We as p,uh as q,gn as r,Zp as s,Gi as t,Fv as u,Wv as v,$n as w,zi as x,ce as y,we as z};
5982
+ `;let Go;function FE(){if(Go)return Go;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Go=new Si(t),Go}function hp(s){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),i=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.fill();const l=Ma(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,u=i*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,i,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,i,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,i,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,i,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new Si(e)}function zE(s){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(s,64,68),new Si(t)}function ql(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const Yl=7.5,Kl=9;class ui{static cache=new Map;static load(t){let e=ui.cache.get(t);return e||(e=fetch(t).then(n=>n.arrayBuffer()).then(n=>ui.parse(n)),ui.cache.set(t,e)),e}static upTo(t,e){const n=t.filter((a,o)=>o===0||t[o-1].magnitudeLimit<e);if(n.length<=1)return ui.load(t[0].url);const i=n.map(a=>a.url).join(`
5983
+ `);let r=ui.cache.get(i);return r||(r=Promise.all(n.map(a=>ui.load(a.url))).then(a=>a.reduce((o,c)=>ui.concat(o,c))),ui.cache.set(i,r)),r}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*n,e),dec:new Float32Array(t,1*n,e),mag:new Float32Array(t,2*n,e),ci:new Float32Array(t,3*n,e)}}static concat(t,e){const n=(i,r)=>{const a=new Float32Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),a};return{count:t.count+e.count,ra:n(t.ra,e.ra),dec:n(t.dec,e.dec),mag:n(t.mag,e.mag),ci:n(t.ci,e.ci)}}}const kE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,BE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,HE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,GE=20,VE=1;class WE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const i=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=i==="hail"?Math.min(1,e*1.3+.2):i==="rain"?e:0,i!==this.ambientKey){this.ambientKey=i;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(kE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/GE,1);const r=n>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(BE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:i}=this.requested;this.setAmbient(e,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(HE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,i){if(e!==n()){t?.source.stop();return}i(t)}async startLoop(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ii{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[i,r]=this.perifocalAxes(),a=Math.sqrt(Ii.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),i=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Ii.stumpffC(i),o=e-n*n*n/Math.sqrt(Ii.SUN_GM_AU3_PER_DAY2)*Ii.stumpffS(i);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(Ii.SUN_GM_AU3_PER_DAY2)*Math.abs(t),i=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ii.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;i(r)<n;)r*=2;let a=0;for(let o=0;o<Ii.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;i(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:i*a-r*o*c,y:r*a+i*o*c,z:o*l},{x:-i*o-r*a*c,y:-r*o+i*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const Jm=[{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(t){const e=this.julianDayOf(t);return Jm.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(t,e,n){const i=ke(e),r=this.earthPositionAt(i),a=this.apparentPositionOf(t,2451545+i.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,i,e,n),u=this.horizontalOf(o,i,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const i=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(i,t.peakMagnitude)}static tailEndAt(t,e,n,i,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/i,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const i=this.orbitOf(t);let r=i.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=i.positionAt(e-o)}return r}static horizontalOf(t,e,n,i){const r=Jo(KS(),new ge(t.x,t.y,t.z,e)),a=Jo($S(e),r),o=AS(e,new Qu(i.lat,i.lng,i.elevationM)),c=new ge(a.x-o.x,a.y-o.y,a.z-o.z,e),l=Um(c);return Lc(l.ra,l.dec,n,i)}static earthPositionAt(t){return Jo(YS(),hs(St.Earth,t))}static julianDayOf(t){return 2451545+ke(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new Ii(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const qE=[{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}],yc=6.5;class $l{static activeAt(t){return qE.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),i=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,i),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,i=yc){if(e<=0)return 0;const r=yc-i;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return Lc(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class Ie{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=ke(t),i=new Ju(0,ES(t).elon-90,1),r=Jo(ZS(n),Om(i,n)),a=Um(r);return Lc(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=yc){const n=Ie.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),i=yc-e;return(Ie.QUIET_RATE_PER_HOUR+n)/Math.pow(Ie.POPULATION_INDEX,i)}static schedule(t){const e=new km(t.seed^1542469173);return Ls.schedule(t).map(n=>{const i=Ie.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=Ie.turnAround(i,e.between(0,360)),o={x:i.x*Math.cos(r)+a.x*Math.sin(r),y:i.y*Math.cos(r)+a.y*Math.sin(r),z:i.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:Ie.toHorizontal(o),bearingDeg:Ie.bearingFrom(o,i)}})}static turnAround(t,e){const[n,i]=Ie.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+i.x*Math.sin(r),y:n.y*Math.cos(r)+i.y*Math.sin(r),z:n.z*Math.cos(r)+i.z*Math.sin(r)}}static bearingFrom(t,e){const[n,i]=Ie.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=Ie.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*i.x+a.y*i.y+a.z*i.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Ie.normalise(Ie.cross(t,e));return[n,Ie.normalise(Ie.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=Ie.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Ie.turnAround(e,t.bearingDeg),i=t.fromRadiantDeg*Math.PI/180;return Ie.toHorizontal({x:e.x*Math.cos(i)+n.x*Math.sin(i),y:e.y*Math.cos(i)+n.y*Math.sin(i),z:e.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,i=Math.cos(e);return{x:i*Math.sin(n),y:Math.sin(e),z:-i*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class YE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=me.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=me.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:me.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:me.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Ns{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Ns.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const n=Ns.degOver(t)/e;return n<1?1:Math.min(Ns.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class fn{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 Ns.DEG_PER_SECOND*3600}static graspOf(t,e={}){const n=e.exposureSeconds??t.exposureSeconds,i=e.fNumber??t.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return fn.EYE;const r=e.focalLengthMm??t.frame?.focalLengthMm??fn.UNKNOWN_CAMERA_FOCAL_MM,a=r/i,o=fn.resolutionArcsec(t,r,a);return{apertureMm:a,exposureSeconds:Math.min(n,fn.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,n){const r=(t.detailUm??fn.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*fn.ARCSEC_PER_RADIAN,a=1.22*fn.WAVELENGTH_M/(n/1e3)*fn.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(t){return t/fn.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const n=fn.graspOf(t,e),i=fn.EYE,r=(n.apertureMm/i.apertureMm)**2,a=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(t,e){const n=e.fieldOfViewDeg===void 0?void 0:Ve.focalLengthMmFor(t,e.fieldOfViewDeg);return fn.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:n,exposureSeconds:e.exposureSeconds})}}const up=111320,ra=Math.PI/180,KE=1.02,$E=1;class xa{static of(t,e){const n=xa.sightings(t,e);if(n.length<2)return;const i=xa.baseline(n);if(!i)return;const{near:r,far:a,closedM:o}=i,c=Math.tan(a.widthDeg/2*ra)===0?0:Math.tan(r.widthDeg/2*ra)/Math.tan(a.widthDeg/2*ra);if(c<KE)return;const l=o/(c-1),h=me.sizeMAt(l,r.widthDeg),u=n.map(d=>({t:d.t,m:me.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(t,e){return t.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===e)?.shape,r=i?.angular?.widthDeg,a=Qe(t,n.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:n.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??a.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(t){let e;for(const n of t)for(const i of t){if(n.t>=i.t)continue;const r=xa.closedAlongSight(n,i),[a,o,c]=r>=0?[i,n,r]:[n,i,-r];c<$E||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const n=(e.lat-t.lat)*up,i=(e.lng-t.lng)*up*Math.cos(t.lat*ra),r=(t.sightAzimuthDeg??0)*ra;return n*Math.cos(r)+i*Math.sin(r)}}class dn{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:dn.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:dn.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:dn.atLeastNearest(t.derivedM),basis:"derived"};const e=dn.largest(t.range?.minM,t.crossing?.behindM),n=dn.smallest(t.range?.maxM,t.crossing?.inFrontM),i=e===void 0?void 0:e*dn.MARGIN,r=n===void 0?void 0:n/dn.MARGIN;return i!==void 0&&r!==void 0?{distanceM:dn.atLeastNearest(i<=r?Math.sqrt(i*r):i),basis:"bounded"}:i!==void 0?{distanceM:dn.atLeastNearest(i),basis:"bounded"}:r!==void 0&&r<dn.CONVENTIONAL_M?{distanceM:dn.atLeastNearest(r),basis:"bounded"}:{distanceM:dn.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(dn.NEAREST_M,t)}static largest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.min(...e)}}Tp();const ZE={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"}},JE=["en","fr"],jE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},QE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},dp="comet:",tw={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"}},ew=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,nw=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,iw=-18,sw={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Zl={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class rw extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass","max-pixel-ratio",Sr,br]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new C;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new WE;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(i,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=wu(ec.preferencesFor(this),JE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(t,this.said.read(u.title)||tw[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,p=d.altitudeDeg,v=(p<0?QE:jE)[c];this.showHoverTooltip(t,v.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(p)))));return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(dp)?t.slice(dp.length):void 0;return(n?Jm.find(r=>r.id===n):void 0)?.name[e]??ZE[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(Ha(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.ufoElement.playbackState==="playing"&&this.sceneRenderer.frame(performance.now())};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing",e=t||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(e,t),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${ag}</style>${rg}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new zn(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(eh),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",e=>this.lookToward(e.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=e=>this.ufoElement.setMapSubjectBounds(e),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new rs(ec.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 t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose(),queueMicrotask(()=>{this.isConnected||this.sceneRenderer.releaseContext()})}attributeChangedCallback(t,e,n){if(t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="max-pixel-ratio"&&n!==e){const i=Number(n);this.sceneRenderer.setMaxPixelRatio(Number.isFinite(i)&&i>0?i:Math.min(window.devicePixelRatio||1,2))}(t===Sr||t===br)&&n!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[Sr,br])this.ufoElement.toggleAttribute(t,this.hasAttribute(t))}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=Qe(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="witness"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=tn(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const r=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((r-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setCloudRendering(t){this.sceneRenderer.setCloudRendering(t)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickCloudAt(t,e){return this.sceneRenderer.pickCloudAt(t,e)}cloudDirectionAt(t,e){return this.sceneRenderer.cloudDirectionAt(t,e)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){this.sightingData=await gp.json(t)}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.applyFrameFormat(),this.lastTimeMs=0,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=me.CANVAS_HEIGHT_PX,n=Ve.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=[{magnitudeLimit:Yl,url:this.getAttribute("star-catalog-src")??ew},{magnitudeLimit:Kl,url:this.getAttribute("deep-star-catalog-src")??nw}],e=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=e>Yl?Kl:Yl;const i=await ui.upTo(t,e);n===this.starCatalogRequest&&(this.starCatalog=i,this.sceneRenderer.compileNextFrameOffThread(),this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Kl||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=fn.gainFor(t.instrument,{fNumber:Qe(t,0)?.fNumber,fieldOfViewDeg:Bn.fovOf(t,0),exposureSeconds:t.exposure});return mm(iw,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=$n.windowEndingAt(t,this.exposureSeconds()),n=e.seconds,i=this.degreesPerPixelAt(t),r=Ns.instants(n,i),a=Math.max(r,this.ufoElement.exposureTimes(t).length,$n.instants(this.ufoElement.sighting.decor,Qe(this.ufoElement.sighting,t)?.elevationM??0,e.fromMs,n,i));if(a<=1){this.sceneRenderer.setExposure(1);return}this.sceneRenderer.setExposure(a,o=>this.applySceneAt(e.fromMs+e.ms*o/(a-1),{sky:Math.floor(o*r/a)!==Math.floor((o-1)*r/a),stepMs:e.ms/a}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Bn.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const n=this.ufoElement.sighting;this.setWeather(Ha(n,t)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,t),this.sceneRenderer.setDecor(n.decor);const i=Qe(n,t),r=Qe(n,0),a=Ha(n,0),o=Object.fromEntries(jo(Ha(n,t)).map(E=>[E.id,ld(t,n.weatherTrack,a,r,i,E.id)]));if(this.sceneRenderer.setCloudOffset(ld(t,n.weatherTrack,a,r,i),o),this.sceneRenderer.setObserverPose(i??Zl),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(fn.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:Bn.fovOf(n,t),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Ge.of(n)?.offsetAt(t)??Ge.STILL),this.sceneRenderer.updateDecorAnchoring(Qe(n,0),i,t),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(t),e&&!e.sky)return;const c=i?.lat??Zl.lat,l=i?.lng??Zl.lng,h=vf(n.event.time??{},l,n.event.utcOffsetHours);if(!h){this.sceneRenderer.setAstronomy(sw);return}const u=new Date(h.getTime()+t),d={lat:c,lng:l,elevationM:i?.elevationM??0},f=Math.max(1,Math.round(.25*this.degreesPerPixelAt(t)/Ns.DEG_PER_SECOND*1e3)),p=Math.max(1e-8,this.degreesPerPixelAt(t)*.1),v=`${Math.floor(u.getTime()/f)}|${Math.round(c/p)}|${Math.round(l/p)}|${Math.round(d.elevationM)}|${this.starCatalog?this.starCatalogDepth:0}`;if(v===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=v;const g={...Dl("Sun",u,d),magnitude:Cl("Sun",u)},m={...Dl("Moon",u,d),phase:jS(u),magnitude:Cl("Moon",u)},S=JS.map(E=>({body:E,position:Dl(E,u,d),magnitude:Cl(E,u)}));this.sceneRenderer.setAstronomy({sun:g,moon:m,planets:S,comet:this.cometAt(u,d),stars:this.starCatalog?{catalog:this.starCatalog,date:u,observer:d}:void 0,frame:{date:u,observer:d}}),this.ufoElement.setSunAltitude(g.altitudeDeg)}cometAt(t,e){const n=XE.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const n=e.timeline,i=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const p of n.sourceIds){const v=n.getInterpolatedShapeAt(t,p);if(!v)continue;const g={...v,bounds:{...v.bounds,x:v.bounds.x+r.x,y:v.bounds.y+r.y}};o.set(p,g);const m=v.aim?this.sceneRenderer.screenPointOf(Kn.directionOf(v.aim,this.directionScratch)):{ndcX:(g.bounds.x+g.bounds.width/2)/i.width*2-1,ndcY:-((g.bounds.y+g.bounds.height/2)/i.height*2-1)},S=m!==void 0&&Math.abs(m.ndcX)<=1&&Math.abs(m.ndcY)<=1,E=S?this.sceneRenderer.decorDistancesAt(m.ndcX,m.ndcY,p):{};l.add(p),(S||v.aim)&&l.delete(p);const _=v.angular?.widthDeg??a.pxToDeg(v.bounds.width),b=this.sizeEstimateOf(p);b.add(_,E);const w=xa.of(e,p);c.set(p,dn.resolve({hypothesisM:this.distanceHypotheses.get(p),derivedM:w&&_>0?me.distanceMAt(w.widthM,_):void 0,range:b.distanceRangeAt(_),crossing:E}))}for(const[p,v]of o)for(const[g,m]of o){if(g===p||m.transparency>=1||m.bounds.width*m.bounds.height<=v.bounds.width*v.bounds.height||!(v.bounds.x>=m.bounds.x&&v.bounds.y>=m.bounds.y&&v.bounds.x+v.bounds.width<=m.bounds.x+m.bounds.width&&v.bounds.y+v.bounds.height<=m.bounds.y+m.bounds.height))continue;const E=c.get(g);E&&c.set(p,{distanceM:E.distanceM*.999,basis:E.basis});break}this.depths=c;const h=n.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=(Qe(e,t)?.rollDeg??0)+(Ge.of(e)?.offsetAt(t)??Ge.STILL).rollDeg;this.sceneRenderer.setPhenomena(u,{projection:a,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:Ve.starPointsOf(e.instrument),rollRad:f*Math.PI/180})}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(i)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,i=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?vf(n,e.lng,t.event.utcOffsetHours):void 0;if(!i||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(e.lat*1e3),c=Ie.schedule({ratePerHour:Ie.observedRatePerHour(Ie.apexPosition(i,r).altitudeDeg),durationMs:a,velocityKmS:Ie.TYPICAL_VELOCITY_KM_S,seed:o}),l=$l.activeAt(i).map(u=>{const d=$l.radiantPosition(u.shower,i,r);return{entry:u,position:d,rate:$l.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=Ls.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(t){const e=this.ufoElement.sighting,n=e.instrument,i=n.frame,r=Qe(e,t),a=r?.fNumber??n.fNumber;if(!i||a===void 0)return;const o=Ve.focalLengthMmFor(n,Bn.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Oi.of(e.instrument,me.CANVAS_HEIGHT_PX,Bn.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new YE,this.sizeEstimates.set(t,e)),e}}const fp="rr0-scene";function aw(){Tp(),customElements.get(fp)||customElements.define(fp,rw)}aw();export{Pv as $,uw as A,de as B,ct as C,u2 as D,qt as E,vw as F,fw as G,$p as H,dw as I,pw as J,Ko as K,Oa as L,mw as M,Ya as N,Se as O,l2 as P,fs as Q,Ea as R,Pn as S,ow as T,on as U,Pt as V,En as W,hw as X,Hs as Y,Kp as Z,gw as _,lw as a,sc as a0,Gh as a1,hc as a2,en as a3,em as a4,Gu as a5,Vu as a6,jt as a7,us as a8,Na as a9,ni as aa,Hi as ab,cw as b,_w as c,ac as d,xw as e,Wt as f,C as g,d0 as h,Mw as i,yw as j,Tv as k,Ds as l,Bc as m,I1 as n,ye as o,We as p,uh as q,gn as r,Zp as s,Gi as t,Fv as u,Wv as v,Zn as w,zi as x,ce as y,we as z};