@rr0/ufoathome 0.65.2 → 0.65.3
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.
|
@@ -693,15 +693,15 @@ input[type=range] {
|
|
|
693
693
|
pointer-events: none;
|
|
694
694
|
white-space: nowrap;
|
|
695
695
|
}
|
|
696
|
-
`,Uo=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class ri{static get default(){return Uo[0]}static byId(t){return Uo.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:ri.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:ri.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*ri.aspectOf(t))}static availableAt(t){return t===void 0?Uo:Uo.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return 2*Math.atan(i.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const i=e??t.fNumber;if(i===void 0||t.apertureBlades===void 0)return 0;const n=t.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??ri.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class mo{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.witnessTrack.allKeyframes){const{lat:n,lng:s,headingDeg:r}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:r})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new mo(e)}get moved(){return this.spanM>mo.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(li(e,t.east,e,t.west).x),Math.abs(li(t.north,i,t.south,i).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:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:ps(0,-s,i,n).lat,south:ps(0,s,i,n).lat,east:ps(s,0,i,n).lng,west:ps(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class si{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=mo.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const r=e.points[s-1],o=e.points[s],c=(o.t-r.t)/1e3;if(c<=0)continue;const l=li(o.lat,o.lng,r.lat,r.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=si.stepHzFor(f);i.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const r=i[s-1],o=i[s+1];i[s].rampsIn=r===void 0||r.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new si(i,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<si.SLOWEST_WALK_M_PER_S||t>si.FASTEST_WALK_M_PER_S?0:si.REFERENCE_STEP_HZ*Math.pow(t/si.REFERENCE_SPEED_M_PER_S,si.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return si.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),r=si.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*e.speedMPerS/si.REFERENCE_SPEED_M_PER_S;return{eastM:r*e.northUnit,northM:-r*e.eastUnit,upM:si.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:si.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:si.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,r=t.endMs-e,o=Math.min(t.rampsIn?s/n:1,t.rampsOut?r/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Re{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/Re.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}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 U1(a,t,e){if(!a||!t)return e<1?a:t;const i=((t.azimuthDeg-a.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((a.azimuthDeg+i*e)%360+360)%360,altitudeDeg:a.altitudeDeg+(t.altitudeDeg-a.altitudeDeg)*e}}function F1(a,t,e){const{bounds:i}=a;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Gi(a,t,e){return a+(t-a)*e}function I0(a){const t=/^#([0-9a-f]{6})$/i.exec(a);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function k1(a){return`#${a.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function z1(a,t,e){const i=I0(a),n=I0(t);return!i||!n?e<1?a:t:k1([Gi(i[0],n[0],e),Gi(i[1],n[1],e),Gi(i[2],n[2],e)])}function B1(a,t,e){const i={x:Gi(a.bounds.x,t.bounds.x,e),y:Gi(a.bounds.y,t.bounds.y,e),width:Gi(a.bounds.width,t.bounds.width,e),height:Gi(a.bounds.height,t.bounds.height,e)},n=Gi(a.angle,t.angle,e),s=Gi(a.transparency,t.transparency,e),r=Gi(a.haloScale,t.haloScale,e),o=Gi(a.blur??0,t.blur??0,e),c=Gi(a.brightness??0,t.brightness??0,e),l=z1(a.color,t.color,e),h=Re.lerpAngular(a.angular,t.angular,e),u=U1(a.aim,t.aim,e);return a.kind==="polygon"&&t.kind==="polygon"&&a.points.length===t.points.length?{...a,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u,points:a.points.map((d,f)=>({x:Gi(d.x,t.points[f].x,e),y:Gi(d.y,t.points[f].y,e)}))}:{...e<1?a:t,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u}}class _l{keyframes=[];order=[];groups=[];addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?B1(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){if(n?.has(s[r]))continue;const o=this.getInterpolatedShapeAt(t,s[r]);if(o&&F1(o,e,i))return{sourceId:s[r],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}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(i=>i.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(n=>n.includes(t));if(e===-1)return;const i=this.groups[e].filter(n=>n!==t);i.length<2?this.groups.splice(e,1):this.groups[e]=i}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 _l;for(const i of t.keyframes)e.addKeyframe(i.t,i.shapes);if(t.order){const i=e.order.filter(n=>!t.order.includes(n));e.order=[...t.order,...i]}return t.groups&&(e.groups=t.groups.map(i=>i.filter(n=>e.order.includes(n))).filter(i=>i.length>=2)),e}}function H1(a,t,e){return Math.max(t,Math.min(e,a))}function G1(a,t,e){const i=((t-a)%360+540)%360-180;return((a+i*e)%360+360)%360}function Da(a,t,e){return a+(t-a)*e}function V1(a,t,e){return{lat:a.lat===void 0||t.lat===void 0?void 0:Da(a.lat,t.lat,e),lng:a.lng===void 0||t.lng===void 0?void 0:Da(a.lng,t.lng,e),elevationM:Da(a.elevationM,t.elevationM,e),headingDeg:a.headingDeg===void 0||t.headingDeg===void 0?void 0:G1(a.headingDeg,t.headingDeg,e),pitchDeg:Da(a.pitchDeg,t.pitchDeg,e),rollDeg:Da(a.rollDeg??0,t.rollDeg??0,e),fovDeg:Da(a.fovDeg,t.fovDeg,e),fNumber:a.fNumber,focusDistanceM:a.focusDistanceM}}class go{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,pose:e}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?V1(i.pose,n.pose,H1((t-i.t)/(n.t-i.t),0,1)):i.pose:n?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new go;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose);return e}}function Ie(a,t,e){return a+(t-a)*e}function Cd(a,t,e){const i=((t-a)%360+540)%360-180;return((a+i*e)%360+360)%360}function W1(a,t,e){return Math.max(t,Math.min(e,a))}function X1(a=[],t=[],e){if(!(!a.length&&!t.length))return[...new Set([...a.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=a.find(c=>c.id===i),s=t.find(c=>c.id===i),r=n??{...s,density:0},o=s??{...n,density:0};return{...r,eastM:Ie(r.eastM,o.eastM,e),northM:Ie(r.northM,o.northM,e),baseM:Ie(r.baseM,o.baseM,e),thicknessM:Ie(r.thicknessM,o.thicknessM,e),widthM:Ie(r.widthM,o.widthM,e),depthM:Ie(r.depthM,o.depthM,e),rotationDeg:Cd(r.rotationDeg,o.rotationDeg,e),density:Ie(r.density,o.density,e),darkness:Ie(r.darkness??0,o.darkness??0,e)}})}function q1(a,t,e){if(a.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=$c(a),n=$c(t);return e>=1?n.map(r=>({...r})):[...new Set([...i.map(r=>r.id),...n.map(r=>r.id)])].map(r=>{const o=i.find(u=>u.id===r),c=n.find(u=>u.id===r),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:X1(o?.instances,c?.instances,e),baseM:Ie(l.baseM,h.baseM,e),thicknessM:Ie(l.thicknessM,h.thicknessM,e),coverage:Ie(l.coverage,h.coverage,e),sizeM:Ie(l.sizeM,h.sizeM,e),density:Ie(l.density,h.density,e),darkness:Ie(l.darkness??a.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:Ie(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:Ie(l.windSpeed??a.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Cd(l.windDirectionDeg??a.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function Y1(a,t,e){return{cloudLayers:q1(a,t,e),cloudCover:Ie(a.cloudCover,t.cloudCover,e),cloudDarkness:Ie(a.cloudDarkness,t.cloudDarkness,e),highCloudCover:a.highCloudCover===void 0||t.highCloudCover===void 0?void 0:Ie(a.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:a.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:Ie(a.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:a.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:Ie(a.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:a.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:Ie(a.cloudBaseM,t.cloudBaseM,e),relativeHumidity:a.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:Ie(a.relativeHumidity,t.relativeHumidity,e),precipitationType:e<1?a.precipitationType:t.precipitationType,precipitationIntensity:Ie(a.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Cd(a.windDirectionDeg,t.windDirectionDeg,e),windSpeed:Ie(a.windSpeed,t.windSpeed,e),storm:e<1?a.storm:t.storm}}class vo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?Y1(i.weather,n.weather,W1((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new vo;for(const i of t.keyframes)e.addKeyframe(i.t,i.weather);return e}}class Mo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Mo;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const K1=100,$1={kind:"none",volume:0,pitchHz:K1};class dn{constructor(t){this.entries=t}static empty(){return new dn(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 dn(new Map);return{recording:dn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i=structuredClone(t);for(const n of e.paths()){const s=e.at(n),r=n.split("."),o=dn.holderOf(i,r);if(!o)continue;const c=r[r.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return dn.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),dn.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>dn.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,dn.stripValue(s,[...e,n],i)])):t}static holderOf(t,e){let i=t;for(const n of e.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function au(a){if(a.year!==void 0)return Date.UTC(a.year,(a.month??1)-1,a.day??1,a.hour??0,a.minute??0,a.second??0)}function P0(a){return(((a.day??0)*24+(a.hour??0))*60+(a.minute??0))*6e4+(a.second??0)*1e3}const Z1=["year","month","day","hour","minute"],J1=["day","hour","minute"];function L0(a,t){return t.filter(e=>a[e]!==void 0).join(",")}function j1(a){if(a.durationSeconds!==void 0)return a.durationSeconds*1e3;if(!a.time||!a.endTime)return;const t=a.time.year!==void 0&&a.endTime.year!==void 0,e=t?Z1:J1,i=L0(a.time,e);if(!(i===""||i!==L0(a.endTime,e)))return t?au(a.endTime)-au(a.time):P0(a.endTime)-P0(a.time)}class Sl{constructor(t,e,i,n,s,r,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=t,this.timeline=e,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=s,this.witness=r,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=dn.empty();testimony;interpretation;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ri.byId(this.instrumentId)}static create(t,e,i){return new Sl({eventType:"sighting",time:t,place:e},new _l,new go,new vo,new Mo,i)}}const Q1=0,t2=0;function ai(a,t){const e=a.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const i=a.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:Q1,headingDeg:void 0,pitchDeg:t2,fovDeg:ri.fieldOfViewDeg(a.instrument)}}function Qs(a,t){return a.weatherTrack.getInterpolatedWeatherAt(t)??a.weather??Om}function e2(a,t){return a.soundTrack.getInterpolatedSoundAt(t)??$1}class i2{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 i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const km=["nw","n","ne","e","se","s","sw","w"],n2=24,Fo=8,s2=3,a2=8;function ko(a,t,e){const i=a.x-t.x,n=a.y-t.y,s=Math.cos(e),r=Math.sin(e);return{x:t.x+i*s-n*r,y:t.y+i*r+n*s}}function Dr(a){return{x:a.x+a.width/2,y:a.y+a.height/2}}const r2={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class ji{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,r={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-n2}},o=Dr(t.bounds),c={};for(const l of Object.keys(r))c[l]=ko(r[l],o,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...km,"rotate"]){const s=ji.handlePointsFor(t);for(const r of n)if(Math.hypot(e.x-s[r].x,e.y-s[r].y)<=i)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((ji.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Dr(t),r=ko(n,s,-e),{x:o,y:c,width:l,height:h}=t,u=r2[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(r.x,p-Fo)),u.right&&(p=Math.max(r.x,d+Fo)),u.top&&(f=Math.min(r.y,v-Fo)),u.bottom&&(v=Math.max(r.y,f+Fo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,r=ji.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:r};const o=n===0?1:r.width/n,c=s===0?1:r.height/s;return{...t,bounds:r,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const i=Dr(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),n=Math.max(...t.map(r=>r.x+r.width)),s=Math.max(...t.map(r=>r.y+r.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Dr(t.bounds);return t.points.map(i=>ko({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=a2){const n=ji.vertexPointsFor(t);let s,r=i;return n.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=r&&(r=l,s=c)}),s}static toLocalPoint(t,e){const i=Dr(t.bounds),n=ko(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?ji.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),r=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+r,width:o-s,height:c-r},h=n.map(u=>({x:u.x-s,y:u.y-r}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=ji.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,r=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=ji.distanceToSegment(i,l,h);u<r&&(r=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:o}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,r=n*n+s*s,o=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/r)),c=e.x+o*n,l=e.y+o*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=s2?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const ru=6,zo=ru/2,N0=20,O0=24,U0=9,F0=6,k0=7,z0=6,Un=4;class xo{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:i,width:n,height:s}=t.bounds,r=e+n/2,o=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+U0*f),z0*f)-d:0,v=f>0?d*(1+k0*f)-d:0,m=3*O0*(t.blur??0)+1.5*N0*t.haloScale,g=Math.max(p,v,0)+m+2;return{x:r-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),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(${(O0*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),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:i,y:n,width:s,height:r}=t.bounds,o=i+s/2,c=n+r/2,l=Math.max(s,r)/2,h=Math.max(l*(1+U0*e),z0*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<=F0;d++){const f=d/F0,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+k0*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,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(t.color,e*.55)),g.addColorStop(.35,this.withAlpha(t.color,e*.22)),g.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=r=>Math.round(r+(255-r)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,r=n/2,o=s/2;this.ctx.ellipse(e+r,i+o,r,o,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=N0*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(ji.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of ji.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Un,Un,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(ji.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const r=xo.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Un+2,Un+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=r,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=r,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,Un,Un,0,0,2*Math.PI),n.fill()),n.strokeStyle=r,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Un+2,Un+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+Un+5,s.picture.y-Un-2,r)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const r=this.ctx;r.save(),r.font=`${s}px system-ui, sans-serif`,r.textBaseline="top";const o=r.measureText(t).width;r.fillStyle="rgba(0, 0, 0, 0.6)",r.fillRect(e-3,i-2,o+6,s+4),r.fillStyle=n,r.fillText(t,e,i),r.restore()}paintGroupHandles(t){this.paintHandleFrame(ji.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 i of km){const n=t[i];this.ctx.fillRect(n.x-zo,n.y-zo,ru,ru)}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,zo+1,zo+1,0,0,2*Math.PI),this.ctx.fill())}}const B0=.05,H0=.08,G0=2,V0=3,o2=14,c2=.02;class l2{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 i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):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 i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,B0);for(const{param:s,ratio:r}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*r,i.sampleRate/2-1),n,B0)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const r=t.createGain();return r.gain.value=0,i.connect(s),n.connect(s),s.connect(r).connect(t.destination),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),r=t.createGain();return r.gain.value=0,n.connect(s).connect(i.frequency),i.connect(r).connect(t.destination),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(t.destination),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const r=t.createBufferSource();r.buffer=this.crackleEnvelope(t),r.loop=!0;const o=t.createGain();return o.gain.value=0,r.connect(o).connect(s.gain),i.connect(n).connect(s).connect(t.destination),i.start(),r.start(),{key:e,nodes:[n,s,o],sources:[i,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const r=n.createBufferSource();r.buffer=s,r.loop=!0;const o=n.createGain();o.gain.value=0,r.connect(o).connect(n.destination),r.start(),this.voice={key:e,nodes:[o],sources:[r],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 i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*G0),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*G0),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let r=0;r<i.length;r++)n=(n+.02*(Math.random()*2-1))/1.02,i[r]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let r=0;r<i.length;r++)i[r]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*V0),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(c2*t.sampleRate)),s=Math.round(V0*o2);for(let r=0;r<s;r++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,H0/3);const n=i+H0;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const r of t.nodes)r.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const r of t.nodes)r.disconnect()}}}}function Jc(a){return[...a].sort((t,e)=>t.t-e.t)}function W0(a,t){let e;for(const i of Jc(a)){if(i.t>t)break;e=i}return e}const zl=Math.PI/180,Bo=180/Math.PI;class ms{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*zl/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new ms(t.projection,e,i)}degToPx(t){const e=t*zl;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Bo:2*Math.atan(t/(2*this.focalPx))*Bo}angleDegToRadiusPx(t){const e=t*zl;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*Bo:Math.atan(t/this.focalPx)*Bo}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(Re.angularWidthDeg(t))}}class Wi{static fovOf(t,e){return ai(t,e)?.fovDeg??ri.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>({...e,angular:i.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,i)=>{if(!e.angular)return e;const{width:n,height:s}=i.toBoundsSize(e.angular),r={x:e.bounds.x+(e.bounds.width-n)/2,y:e.bounds.y+(e.bounds.height-s)/2,width:n,height:s};if(e.kind!=="polygon")return{...e,bounds:r};const o=e.bounds.width===0?1:n/e.bounds.width,c=e.bounds.height===0?1:s/e.bounds.height;return{...e,bounds:r,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<Wi.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<Wi.UNMOVED_PX)return e;const r=this.aimFrom(t,i,n,e.bounds);return r?{...e,aim:r}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,ai(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),r=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e})}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(t),o=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,o)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:ri.frameWidthPx(t.instrument,Re.CANVAS_HEIGHT_PX)/2,y:Re.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Wi.OFF_CANVAS_DEG?Math.sign(e)*Wi.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=ri.frameWidthPx(e,Re.CANVAS_HEIGHT_PX)/2,s=ri.frameWidthPx(t.instrument,Re.CANVAS_HEIGHT_PX)/2,r=Re.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=i?.get(o.t)??c,h=ms.of(e,Re.CANVAS_HEIGHT_PX,l),u=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-r,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,_={...f,x:s+p*g-f.width/2,y:r+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:_}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=ai(t,n.t),r=this.fovOf(t,n.t),o=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,r);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:e(c.shape,o,s)})))}}}function h2(a){return dn.restore(u2(a),a.provenance)}function u2(a){return Wi.toAngular(a),Wi.toAim(a),{version:1,id:a.id,time:a.event.time,endTime:a.event.endTime,durationSeconds:a.event.durationSeconds,utcOffsetHours:a.event.utcOffsetHours,timeZone:a.event.timeZone,place:a.event.place,witness:a.witness,testimony:a.testimony,description:a.event.description,tags:a.event.tags,timeline:a.timeline.toJSON(),witnessTrack:a.witnessTrack.toJSON(),weatherTrack:a.weatherTrack.toJSON(),soundTrack:a.soundTrack.toJSON(),weather:a.weather,decor:a.decor,milestones:a.milestones.length>0?a.milestones:void 0,references:a.references.length>0?a.references:void 0,roads:a.roads.length>0?a.roads:void 0,weatherSource:a.weatherSource,instrument:a.instrumentId,exposureSeconds:a.exposureSeconds,interpretation:a.interpretation}}function d2(a){const{recording:t,provenance:e}=dn.strip(a),i=f2(t);return i.provenance=e,i}function f2(a){const t=new Sl({eventType:"sighting",time:a.time,endTime:a.endTime,durationSeconds:a.durationSeconds,utcOffsetHours:a.utcOffsetHours,timeZone:a.timeZone,place:a.place,description:a.description,tags:a.tags},_l.fromJSON(a.timeline),a.witnessTrack?go.fromJSON(a.witnessTrack):new go,a.weatherTrack?vo.fromJSON(a.weatherTrack):new vo,a.soundTrack?Mo.fromJSON(a.soundTrack):new Mo,a.witness&&{id:a.witness.id,title:a.witness.title,lastName:a.witness.lastName,firstNames:a.witness.firstNames},a.id,a.weather,a.decor??[],a.weatherSource,a.instrument,a.exposureSeconds??a.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),Jc(a.milestones??[]),a.references??[],a.roads??[]);return t.testimony=a.testimony,t.interpretation=a.interpretation,Wi.toBounds(t),Wi.toPosition(t),t}const X0=2;function zm(a){return a==="building"||a==="vehicle"}function p2(a,t){const e=a.litKeyframes;if(!e||e.length===0)return a.lit??!1;let i=e[0];for(const n of e){if(n.t>t)break;i=n}return i.lit}function m2(a,t){return a.pattern.kind==="steady"?!0:Bm(a,t,t+1)>.5}function Bm(a,t,e){if(a.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:s=0}=a.pattern,r=Math.min(Math.max(n,0),1);if(r===0||i<=0)return 0;const o=6e4/i,c=t/o+s,l=e/o+s;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),r)<r?1:0;const h=u=>Math.floor(u)*r+Math.min(u-Math.floor(u),r);return(h(l)-h(c))/(l-c)}function Id(a,t){const e=a.track,i={eastM:a.eastM,northM:a.northM,altitudeM:0,headingDeg:a.headingDeg};if(!e||e.length===0)return i;if(e.length===1||t<=e[0].t)return q0(e[0],a);const n=e[e.length-1];if(t>=n.t)return q0(n,a);for(let s=0;s<e.length-1;s++){const r=e[s],o=e[s+1];if(t<r.t||t>o.t)continue;const c=o.t-r.t,l=c===0?0:(t-r.t)/c;return{eastM:r.eastM+(o.eastM-r.eastM)*l,northM:r.northM+(o.northM-r.northM)*l,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*l,headingDeg:r.headingDeg??a.headingDeg}}return i}function q0(a,t){return{eastM:a.eastM,northM:a.northM,altitudeM:a.altitudeM??0,headingDeg:a.headingDeg??t.headingDeg}}class En{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const r=s>0?En.travelDegOver(t,e,i,i+n*1e3)/s/En.PIXELS_PER_INSTANT:0,o=En.flashesOver(t,n)*En.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,o));return c<2?1:Math.min(En.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const r of t){if(!r.track||r.track.length<2)continue;const o=En.directionAt(r,e,i),c=En.directionAt(r,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Id(t,i),s=n.eastM,r=n.altitudeM-e,o=n.northM,c=Math.hypot(s,r,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:o/c}}}function jc(a,t){for(const e of a){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class ao{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class zs{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[zs.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>zs.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has(zs.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},r=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>zs.base(o)===zs.base(i))??i;return n===void 0?delete s[r]:s[r]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const g2=["en","fr"],v2={en:()=>Kc(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(a=>a.ufoMessages_en),fr:()=>Kc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(a=>a.ufoMessages_fr)};function M2(a){return v2[a]()}const Hm={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},x2=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Hm},Symbol.toStringTag,{value:"Module"})),Gm=Math.PI/180,y2=180/Math.PI,_2=256,Vm=19,S2=1.25;function Wm(a,t){return 156543.03392*Math.cos(a*Gm)/2**t}function Xm(a,t){return Wm(a,t)*_2}function w2(a,t){let e=0;for(;e<Vm&&Xm(a,e+1)>=t;)e++;return e}function qm(a,t){return Xm(a,t)}function b2(a,t){const e=t*S2;let i=0;for(;i<Vm&&Wm(a,i)>e;)i++;return i}function kc(a){const t=a*Gm;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function Ym(a,t,e){const i=2**e;return{x:(a+180)/360*i,y:kc(t)*i}}function Km(a,t,e){const i=kc(a.north),n=kc(a.south);return{x:(t-a.west)/(a.east-a.west),y:(kc(e)-i)/(n-i)}}function E2(a,t,e){const{x:i,y:n}=Ym(a,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function A2(a){const t=2**a.z,e=a.x/t*360-180,i=(a.x+1)/t*360-180,n=Y0(a.y,t);return{south:Y0(a.y+1,t),north:n,west:e,east:i}}function Y0(a,t){const e=a/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*y2}function $m(a,t,e,i){const n=E2(a,t,e),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:e});const o=r.map(A2),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:r,bounds:c}}class oa{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 i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-t,s.y-e);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(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,i){const n=Km(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.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 i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.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(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*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,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.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:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:oa.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,oa.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.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=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintWitness(t,e){const{ctx:i}=this,n=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:n.x,y:n.y,radius:8});const s=t.markers.some(r=>{if(!r.current)return!1;const o=li(r.lat,r.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=oa.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?oa.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+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,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(t.south+t.north)/2,c=Math.abs(li(r,t.east,r,t.west).x)/this.width,l=oa.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>e?(i.push(n),n=s):n=r}return n&&i.push(n),i}}const on=256,K0=3,T2=32768;class R2{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 i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(li(i,t.east,i,t.west).x),r=Math.abs(li(t.north,n,t.south,n).z),o=w2(i,Math.max(s,r)),{tiles:c}=$m(n,i,o,K0),l=K0*on,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 m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const o=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=on,c.height=on;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,on,on),u=(t.x-e.x)*on,d=(t.y-e.y)*on;for(let f=0;f<on;f++)for(let p=0;p<on;p++){const v=(f*on+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-T2,g=u+p,_=d+f;i[_*n+g]=m}}sampleAt(t,e,i,n,s,r){const{x:o,y:c}=Ym(e,t,i),l=(o-n.x)*on,h=(c-n.y)*on,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),v=l-u,m=h-d,g=s[d*r+u],_=s[d*r+f],w=s[p*r+u],M=s[p*r+f],S=g+(_-g)*v,b=w+(M-w)*v;return S+(b-S)*m}}const zc=256,D2=5;async function C2(a,t,e,i){const n=(a.south+a.north)/2,s=(a.west+a.east)/2,r=Math.abs(li(n,a.east,n,a.west).x),o=Math.abs(li(a.north,s,a.south,s).z),c=Math.max(r,o),{zoom:l,gridSize:h}=I2(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=$m(s,n,l,h),f=h*zc,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const S=e(M),b=await i(S);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${S}`);const T=await createImageBitmap(await b.blob());v.drawImage(T,(M.x-m.x)*zc,(M.y-m.y)*zc)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const _=document.createElement("canvas");_.width=g,_.height=g;const w=_.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,g,g),{source:_,width:g,height:g,bounds:d}}function I2(a,t,e){let i=b2(a,t/Math.max(1,e)),n=$0(a,i,t);for(;n>D2&&i>0;)i--,n=$0(a,i,t);return{zoom:i,gridSize:n,mPerPixel:qm(a,i)/zc}}function $0(a,t,e){const i=Math.ceil(e/2/qm(a,t));return Math.max(3,2*i+1)}class P2{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 C2(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Sn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Sn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Sn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Sn.surfaceOf(s),widthM:Sn.widthOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return e}queued(t){const e=Sn.queue.then(t,t);return Sn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Sn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Sn.WIDTH_M[t.highway]??Sn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const Bl="https://ufoathome.org/roads/index.json";class Pd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Pd.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.65.2")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==Bl?[e,Bl]:[Bl]).map(i=>i+t)}}function L2(){return{elevation:new R2,imagery:Zm(),roads:N2()}}function Zm(){return new P2}function N2(){return new Pd({fallback:new Sn})}const O2=new Set,cr="show-witness-map",lr="hide-milestones";class Ki extends HTMLElement{static get observedAttributes(){return["src",cr,lr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;witnessMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Sl.create();sightingAudio=new l2;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=Hm;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),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.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 i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.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>${O1}</style>${N1}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new xo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new oa(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",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.seekSnapArmed=!0,this.nameMarkUnder(e)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",e=>this.nameMarkUnder(e)),this.seekInput.addEventListener("pointerleave",()=>this.seekInput.removeAttribute("title")),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.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const 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,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===cr&&this.applyWitnessMapDefault(),t===lr&&this.setMilestonesShown(!this.hasAttribute(lr))}async loadFromSrc(t){this.sightingData=await Fm.json(t)}get sightingData(){return h2(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=d2(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(n=>this.highlightedSourceIds.has(n))||(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.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.witnessMapButton];if(t)for(const i of e)t.appendChild(i);else for(const i of e)this.toolbar.appendChild(i)}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState));const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Jc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),o=r?`${s} — ${r}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n}))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=Ki.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const o=Number(r.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?W0(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=En.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ki.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ki.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ki.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ki.EXPOSURE_STEP_PX),s=Math.min(Ki.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let o=0;o<s;o++)r.push(e.fromMs+e.ms*o/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,o]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}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=ri.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 i=this.playbackState!=="playing"?this.highlightedSourceIds:O2;this.canvasRenderer.setStarPoints(ri.starPointsOf(this.sighting.instrument));const n=(ai(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));if(this.selectionShown&&i.size>1){const o=ji.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepWitnessMapClear(),this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(e2(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 i2(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));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 i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!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(cr)&&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=mo.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(Ki.WITNESS_MAP_MIN_SPAN_M,Ki.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 i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Zm(),e=this.witnessMapBounds;try{const i=await t.getImageryTexture(e,{width:Ki.WITNESS_MAP_IMAGERY_PX,height:Ki.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=i,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],i=(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},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=Ki.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],r))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const 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 i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=ai(this.currentSighting,t),i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?W0(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Jc(this.currentSighting.milestones):[]){const o=ai(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===s})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position: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?ms.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(ri.aspectOf(i)):void 0,markers:n,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=ai(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Id(i,t),{lat:s,lng:r}=ps(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.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,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=ai(this.currentSighting,this.currentTime),s=ms.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return si.of(this.currentSighting)?.offsetAt(t)??si.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 zs(ao.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=jc(ao.preferencesFor(this),g2);t!=="en"&&this.applyMessages(await M2(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 i of[this.timeStartLabel,this.timeEndLabel])i.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=j1(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?au(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Ho(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?J0(Z0(this.realStartMs+i)):Ho(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ho(this.currentSighting.timeline.duration):this.canShowClockTime?J0(Z0(this.realStartMs+this.realDurationMs)):Ho(this.realDurationMs)}}function Z0(a){const t=new Date(a);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function J0(a){if(a.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return a.second?`${t(a.hour)}:${t(a.minute??0)}:${t(a.second)}`:`${t(a.hour)}:${t(a.minute??0)}`}function Ho(a){const t=Math.round(a/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const ou="rr0-ufo";function Jm(){customElements.get(ou)||customElements.define(ou,Ki)}/**
|
|
696
|
+
`,Uo=[{id:"eye",name:{en:"Naked eye",fr:"Œil nu"},flare:0,projection:"equidistant",stabilization:.97},{id:"rectilinear-lens",name:{en:"Camera, unknown device",fr:"Appareil, modèle inconnu"},projection:"rectilinear",fNumber:8,fNumberRange:{min:2,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:8},apertureBlades:6},{id:"instamatic-126",name:{en:"Instamatic, 126 film",fr:"Instamatic, film 126"},projection:"rectilinear",frame:{widthMm:28,heightMm:28,focalLengthMm:43},fNumber:11,exposureSeconds:1/90,years:{from:1963,to:1988},apertureBlades:5,detailUm:20},{id:"slr-35mm-50",name:{en:"35 mm SLR, 50 mm lens",fr:"Reflex 35 mm, objectif 50 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:50},fNumber:8,fNumberRange:{min:2,max:16},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},years:{from:1959},apertureBlades:6,detailUm:20},{id:"slr-35mm-zoom",name:{en:"35 mm SLR, 70-210 mm zoom",fr:"Reflex 35 mm, zoom 70-210 mm"},projection:"rectilinear",frame:{widthMm:36,heightMm:24,focalLengthMm:135,focalRangeMm:{minMm:70,maxMm:210}},fNumber:8,fNumberRange:{min:4,max:22},exposureSeconds:1/250,exposureRangeSeconds:{min:1/1e3,max:3600},apertureBlades:8,years:{from:1975},detailUm:20},{id:"phone-landscape",name:{en:"Phone, held sideways",fr:"Téléphone, tenu couché"},projection:"rectilinear",frame:{widthMm:7.6,heightMm:5.7,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4},{id:"phone-portrait",name:{en:"Phone, held upright",fr:"Téléphone, tenu debout"},projection:"rectilinear",frame:{widthMm:5.7,heightMm:7.6,focalLengthMm:5.7},fNumber:1.8,exposureSeconds:1/120,exposureRangeSeconds:{min:1/8e3,max:10},years:{from:2007},apertureBlades:void 0,detailUm:1.4}];class ri{static get default(){return Uo[0]}static byId(t){return Uo.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:ri.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:ri.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*ri.aspectOf(t))}static availableAt(t){return t===void 0?Uo:Uo.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const i=t.frame;if(!(!i||e<=0))return 2*Math.atan(i.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const i=t.frame;if(!(!i||e<=0||e>=180))return i.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const i=e??t.fNumber;if(i===void 0||t.apertureBlades===void 0)return 0;const n=t.fNumberRange;return!n||n.max<=n.min?1:Math.max(0,Math.min(1,(i-n.min)/(n.max-n.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??ri.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}class mo{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const i of t.witnessTrack.allKeyframes){const{lat:n,lng:s,headingDeg:r}=i.pose;n===void 0||s===void 0||e.push({t:i.t,lat:n,lng:s,headingDeg:r})}if(e.length===0){const i=t.event.place?.[0];if(!i)return;e.push({t:0,lat:i.lat,lng:i.lng})}return new mo(e)}get moved(){return this.spanM>mo.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,i=(t.west+t.east)/2;return Math.max(Math.abs(li(e,t.east,e,t.west).x),Math.abs(li(t.north,i,t.south,i).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:i,lng:n}=this.center,s=Math.max(this.spanM*(1+e),t)/2;return{north:ps(0,-s,i,n).lat,south:ps(0,s,i,n).lat,east:ps(s,0,i,n).lng,west:ps(-s,0,i,n).lng}}get box(){const t=this.points.map(i=>i.lat),e=this.points.map(i=>i.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class si{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=mo.of(t);if(!e||e.points.length<2)return;const i=[];let n=0;for(let s=1;s<e.points.length;s++){const r=e.points[s-1],o=e.points[s],c=(o.t-r.t)/1e3;if(c<=0)continue;const l=li(o.lat,o.lng,r.lat,r.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,p=si.stepHzFor(f);i.push({startMs:r.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:p,stepsBefore:n,rampsIn:!0,rampsOut:!0}),n+=p*c}for(let s=0;s<i.length;s++){const r=i[s-1],o=i[s+1];i[s].rampsIn=r===void 0||r.stepHz===0,i[s].rampsOut=o===void 0||o.stepHz===0}if(i.some(s=>s.stepHz>0))return new si(i,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<si.SLOWEST_WALK_M_PER_S||t>si.FASTEST_WALK_M_PER_S?0:si.REFERENCE_STEP_HZ*Math.pow(t/si.REFERENCE_SPEED_M_PER_S,si.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return si.STILL;const i=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,n=2*Math.PI*i,s=this.amplitudeAt(e,t),r=si.SWAY_M*s*Math.cos(n/2),o=s*this.rotationPassed*e.speedMPerS/si.REFERENCE_SPEED_M_PER_S;return{eastM:r*e.northUnit,northM:-r*e.eastUnit,upM:si.RISE_M_PER_M_PER_S*e.speedMPerS*s*Math.cos(n),rollDeg:si.HEAD_ROLL_DEG*o*Math.cos(n/2),pitchDeg:-1.25*o*Math.cos(n),yawDeg:si.HEAD_YAW_DEG*o*Math.cos(n/2)}}amplitudeAt(t,e){const i=1e3/t.stepHz,n=Math.min(i,(t.endMs-t.startMs)/2);if(n<=0)return 1;const s=e-t.startMs,r=t.endMs-e,o=Math.min(t.rampsIn?s/n:1,t.rampsOut?r/n:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class Re{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/Re.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,i){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*i,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*i}}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 U1(a,t,e){if(!a||!t)return e<1?a:t;const i=((t.azimuthDeg-a.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((a.azimuthDeg+i*e)%360+360)%360,altitudeDeg:a.altitudeDeg+(t.altitudeDeg-a.altitudeDeg)*e}}function F1(a,t,e){const{bounds:i}=a;return t>=i.x&&t<=i.x+i.width&&e>=i.y&&e<=i.y+i.height}function Gi(a,t,e){return a+(t-a)*e}function I0(a){const t=/^#([0-9a-f]{6})$/i.exec(a);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function k1(a){return`#${a.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function z1(a,t,e){const i=I0(a),n=I0(t);return!i||!n?e<1?a:t:k1([Gi(i[0],n[0],e),Gi(i[1],n[1],e),Gi(i[2],n[2],e)])}function B1(a,t,e){const i={x:Gi(a.bounds.x,t.bounds.x,e),y:Gi(a.bounds.y,t.bounds.y,e),width:Gi(a.bounds.width,t.bounds.width,e),height:Gi(a.bounds.height,t.bounds.height,e)},n=Gi(a.angle,t.angle,e),s=Gi(a.transparency,t.transparency,e),r=Gi(a.haloScale,t.haloScale,e),o=Gi(a.blur??0,t.blur??0,e),c=Gi(a.brightness??0,t.brightness??0,e),l=z1(a.color,t.color,e),h=Re.lerpAngular(a.angular,t.angular,e),u=U1(a.aim,t.aim,e);return a.kind==="polygon"&&t.kind==="polygon"&&a.points.length===t.points.length?{...a,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u,points:a.points.map((d,f)=>({x:Gi(d.x,t.points[f].x,e),y:Gi(d.y,t.points[f].y,e)}))}:{...e<1?a:t,bounds:i,angle:n,transparency:s,haloScale:r,blur:o,brightness:c,color:l,angular:h,aim:u}}class _l{keyframes=[];order=[];groups=[];addKeyframe(t,e){const i=this.findInsertIndex(t);if(this.keyframes[i]?.t===t){const n=new Set(e.map(s=>s.sourceId));this.keyframes[i]={t,shapes:[...this.keyframes[i].shapes.filter(s=>!n.has(s.sourceId)),...e]}}else this.keyframes.splice(i,0,{t,shapes:[...e]});for(const n of e)this.order.includes(n.sourceId)||this.order.push(n.sourceId)}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),i=this.keyframes[e];return i?.t===t?i:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(i=>i.sourceId===e)?.shape}getLatestShapeAt(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return n.shape}}getInterpolatedShapeAt(t,e){const i=this.findShapeAtOrBefore(t,e);if(i?.t===t)return i.shape;const n=this.findShapeAtOrAfter(t,e);return i?n?B1(i.shape,n.shape,(t-i.t)/(n.t-i.t)):i.shape:n?.shape}findShapeAtOrBefore(t,e){let i=this.findInsertIndex(t);for(this.keyframes[i]?.t!==t&&(i-=1);i>=0;i--){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}findShapeAtOrAfter(t,e){for(let i=this.findInsertIndex(t);i<this.keyframes.length;i++){const n=this.keyframes[i].shapes.find(s=>s.sourceId===e);if(n)return{t:this.keyframes[i].t,shape:n.shape}}}hitTest(t,e,i,n){const s=this.sourceIds;for(let r=s.length-1;r>=0;r--){if(n?.has(s[r]))continue;const o=this.getInterpolatedShapeAt(t,s[r]);if(o&&F1(o,e,i))return{sourceId:s[r],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const i=this.keyframes[e].shapes.filter(n=>n.sourceId!==t);i.length===0?this.keyframes.splice(e,1):i.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:i})}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(i=>i.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(n=>n.includes(t));if(e===-1)return;const i=this.groups[e].filter(n=>n!==t);i.length<2?this.groups.splice(e,1):this.groups[e]=i}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 _l;for(const i of t.keyframes)e.addKeyframe(i.t,i.shapes);if(t.order){const i=e.order.filter(n=>!t.order.includes(n));e.order=[...t.order,...i]}return t.groups&&(e.groups=t.groups.map(i=>i.filter(n=>e.order.includes(n))).filter(i=>i.length>=2)),e}}function H1(a,t,e){return Math.max(t,Math.min(e,a))}function G1(a,t,e){const i=((t-a)%360+540)%360-180;return((a+i*e)%360+360)%360}function Da(a,t,e){return a+(t-a)*e}function V1(a,t,e){return{lat:a.lat===void 0||t.lat===void 0?void 0:Da(a.lat,t.lat,e),lng:a.lng===void 0||t.lng===void 0?void 0:Da(a.lng,t.lng,e),elevationM:Da(a.elevationM,t.elevationM,e),headingDeg:a.headingDeg===void 0||t.headingDeg===void 0?void 0:G1(a.headingDeg,t.headingDeg,e),pitchDeg:Da(a.pitchDeg,t.pitchDeg,e),rollDeg:Da(a.rollDeg??0,t.rollDeg??0,e),fovDeg:Da(a.fovDeg,t.fovDeg,e),fNumber:a.fNumber,focusDistanceM:a.focusDistanceM}}class go{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,pose:e}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.pose;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?V1(i.pose,n.pose,H1((t-i.t)/(n.t-i.t),0,1)):i.pose:n?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new go;for(const i of t.keyframes)e.addKeyframe(i.t,i.pose);return e}}function Ie(a,t,e){return a+(t-a)*e}function Cd(a,t,e){const i=((t-a)%360+540)%360-180;return((a+i*e)%360+360)%360}function W1(a,t,e){return Math.max(t,Math.min(e,a))}function X1(a=[],t=[],e){if(!(!a.length&&!t.length))return[...new Set([...a.map(i=>i.id),...t.map(i=>i.id)])].map(i=>{const n=a.find(c=>c.id===i),s=t.find(c=>c.id===i),r=n??{...s,density:0},o=s??{...n,density:0};return{...r,eastM:Ie(r.eastM,o.eastM,e),northM:Ie(r.northM,o.northM,e),baseM:Ie(r.baseM,o.baseM,e),thicknessM:Ie(r.thicknessM,o.thicknessM,e),widthM:Ie(r.widthM,o.widthM,e),depthM:Ie(r.depthM,o.depthM,e),rotationDeg:Cd(r.rotationDeg,o.rotationDeg,e),density:Ie(r.density,o.density,e),darkness:Ie(r.darkness??0,o.darkness??0,e)}})}function q1(a,t,e){if(a.cloudLayers===void 0&&t.cloudLayers===void 0)return;const i=$c(a),n=$c(t);return e>=1?n.map(r=>({...r})):[...new Set([...i.map(r=>r.id),...n.map(r=>r.id)])].map(r=>{const o=i.find(u=>u.id===r),c=n.find(u=>u.id===r),l=o??{...c,coverage:0},h=c??{...o,coverage:0};return{...l,instances:X1(o?.instances,c?.instances,e),baseM:Ie(l.baseM,h.baseM,e),thicknessM:Ie(l.thicknessM,h.thicknessM,e),coverage:Ie(l.coverage,h.coverage,e),sizeM:Ie(l.sizeM,h.sizeM,e),density:Ie(l.density,h.density,e),darkness:Ie(l.darkness??a.cloudDarkness,h.darkness??t.cloudDarkness,e),iceCrystalAlignment:l.iceCrystalAlignment===void 0||h.iceCrystalAlignment===void 0?void 0:Ie(l.iceCrystalAlignment,h.iceCrystalAlignment,e),windSpeed:l.windSpeed===void 0&&h.windSpeed===void 0?void 0:Ie(l.windSpeed??a.windSpeed,h.windSpeed??t.windSpeed,e),windDirectionDeg:l.windDirectionDeg===void 0&&h.windDirectionDeg===void 0?void 0:Cd(l.windDirectionDeg??a.windDirectionDeg,h.windDirectionDeg??t.windDirectionDeg,e)}})}function Y1(a,t,e){return{cloudLayers:q1(a,t,e),cloudCover:Ie(a.cloudCover,t.cloudCover,e),cloudDarkness:Ie(a.cloudDarkness,t.cloudDarkness,e),highCloudCover:a.highCloudCover===void 0||t.highCloudCover===void 0?void 0:Ie(a.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:a.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:Ie(a.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:a.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:Ie(a.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:a.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:Ie(a.cloudBaseM,t.cloudBaseM,e),relativeHumidity:a.relativeHumidity===void 0||t.relativeHumidity===void 0?void 0:Ie(a.relativeHumidity,t.relativeHumidity,e),precipitationType:e<1?a.precipitationType:t.precipitationType,precipitationIntensity:Ie(a.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Cd(a.windDirectionDeg,t.windDirectionDeg,e),windSpeed:Ie(a.windSpeed,t.windSpeed,e),storm:e<1?a.storm:t.storm}}class vo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,weather:e}:this.keyframes.splice(i,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,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.weather;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return i?n?Y1(i.weather,n.weather,W1((t-i.t)/(n.t-i.t),0,1)):i.weather:n?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new vo;for(const i of t.keyframes)e.addKeyframe(i.t,i.weather);return e}}class Mo{keyframes=[];addKeyframe(t,e){const i=this.findInsertIndex(t);this.keyframes[i]?.t===t?this.keyframes[i]={t,sound:e}:this.keyframes.splice(i,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),i=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(i?.t===t)return i.sound;const n=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!i)return n?.sound;if(!n)return i.sound;const s=(t-i.t)/(n.t-i.t);return this.lerp(i.sound,n.sound,Math.max(0,Math.min(1,s)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new Mo;for(const i of t.keyframes)e.addKeyframe(i.t,i.sound);return e}lerp(t,e,i){return{kind:i<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*i,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*i,src:i<1?t.src:e.src}}findInsertIndex(t){let e=0,i=this.keyframes.length;for(;e<i;){const n=e+i>>>1;this.keyframes[n].t<t?e=n+1:i=n}return e}}const K1=100,$1={kind:"none",volume:0,pitchHz:K1};class dn{constructor(t){this.entries=t}static empty(){return new dn(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 dn(new Map);return{recording:dn.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const i=structuredClone(t);for(const n of e.paths()){const s=e.at(n),r=n.split("."),o=dn.holderOf(i,r);if(!o)continue;const c=r[r.length-1],l=o[c];l!==void 0&&(s.of!==void 0&&JSON.stringify(s.of)!==JSON.stringify(l)||(o[c]={value:l,...s.basis==="stated"?{}:{basis:s.basis},...s.rationale===void 0?{}:{rationale:s.rationale}}))}return i}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,i){return dn.isWrapper(t)?(i.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),dn.stripValue(t.value,e,i)):Array.isArray(t)?t.map((n,s)=>dn.stripValue(n,[...e,String(s)],i)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([n,s])=>[n,dn.stripValue(s,[...e,n],i)])):t}static holderOf(t,e){let i=t;for(const n of e.slice(0,-1)){if(typeof i!="object"||i===null)return;i=i[n]}return typeof i=="object"&&i!==null?i:void 0}}function au(a){if(a.year!==void 0)return Date.UTC(a.year,(a.month??1)-1,a.day??1,a.hour??0,a.minute??0,a.second??0)}function P0(a){return(((a.day??0)*24+(a.hour??0))*60+(a.minute??0))*6e4+(a.second??0)*1e3}const Z1=["year","month","day","hour","minute"],J1=["day","hour","minute"];function L0(a,t){return t.filter(e=>a[e]!==void 0).join(",")}function j1(a){if(a.durationSeconds!==void 0)return a.durationSeconds*1e3;if(!a.time||!a.endTime)return;const t=a.time.year!==void 0&&a.endTime.year!==void 0,e=t?Z1:J1,i=L0(a.time,e);if(!(i===""||i!==L0(a.endTime,e)))return t?au(a.endTime)-au(a.time):P0(a.endTime)-P0(a.time)}class Sl{constructor(t,e,i,n,s,r,o,c,l=[],h,u,d,f=[],p=[],v=[]){this.event=t,this.timeline=e,this.witnessTrack=i,this.weatherTrack=n,this.soundTrack=s,this.witness=r,this.id=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f,this.references=p,this.roads=v}provenance=dn.empty();testimony;interpretation;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ri.byId(this.instrumentId)}static create(t,e,i){return new Sl({eventType:"sighting",time:t,place:e},new _l,new go,new vo,new Mo,i)}}const Q1=0,t2=0;function ai(a,t){const e=a.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const i=a.event.place?.[0];if(i)return{lat:i.lat,lng:i.lng,elevationM:Q1,headingDeg:void 0,pitchDeg:t2,fovDeg:ri.fieldOfViewDeg(a.instrument)}}function Qs(a,t){return a.weatherTrack.getInterpolatedWeatherAt(t)??a.weather??Om}function e2(a,t){return a.soundTrack.getInterpolatedSoundAt(t)??$1}class i2{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 i of this.timeline.sourceIds){const n=this.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}this.onFrame(t,e)}}const km=["nw","n","ne","e","se","s","sw","w"],n2=24,Fo=8,s2=3,a2=8;function ko(a,t,e){const i=a.x-t.x,n=a.y-t.y,s=Math.cos(e),r=Math.sin(e);return{x:t.x+i*s-n*r,y:t.y+i*r+n*s}}function Dr(a){return{x:a.x+a.width/2,y:a.y+a.height/2}}const r2={nw:{left:!0,top:!0},n:{top:!0},ne:{right:!0,top:!0},e:{right:!0},se:{right:!0,bottom:!0},s:{bottom:!0},sw:{left:!0,bottom:!0},w:{left:!0}};class ji{static handlePointsFor(t){const{x:e,y:i,width:n,height:s}=t.bounds,r={nw:{x:e,y:i},n:{x:e+n/2,y:i},ne:{x:e+n,y:i},e:{x:e+n,y:i+s/2},se:{x:e+n,y:i+s},s:{x:e+n/2,y:i+s},sw:{x:e,y:i+s},w:{x:e,y:i+s/2},rotate:{x:e+n/2,y:i-n2}},o=Dr(t.bounds),c={};for(const l of Object.keys(r))c[l]=ko(r[l],o,t.angle);return c}static hitTestHandle(t,e,i=8,n=[...km,"rotate"]){const s=ji.handlePointsFor(t);for(const r of n)if(Math.hypot(e.x-s[r].x,e.y-s[r].y)<=i)return r}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const n=((ji.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,s=["ew","nwse","ns","nesw"];return s[Math.round(n)%s.length]}static resizeBounds(t,e,i,n){const s=Dr(t),r=ko(n,s,-e),{x:o,y:c,width:l,height:h}=t,u=r2[i];let d=o,f=c,p=o+l,v=c+h;return u.left&&(d=Math.min(r.x,p-Fo)),u.right&&(p=Math.max(r.x,d+Fo)),u.top&&(f=Math.min(r.y,v-Fo)),u.bottom&&(v=Math.max(r.y,f+Fo)),{x:d,y:f,width:p-d,height:v-f}}static resizeShape(t,e,i){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:n,height:s}=t.bounds,r=ji.resizeBounds(t.bounds,t.angle,e,i);if(t.kind==="oval")return{...t,bounds:r};const o=n===0?1:r.width/n,c=s===0?1:r.height/s;return{...t,bounds:r,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const i=Dr(t.bounds),n=Math.atan2(e.y-i.y,e.x-i.x)+Math.PI/2;return{...t,angle:n}}static groupBoundsFor(t){const e=Math.min(...t.map(r=>r.x)),i=Math.min(...t.map(r=>r.y)),n=Math.max(...t.map(r=>r.x+r.width)),s=Math.max(...t.map(r=>r.y+r.height));return{x:e,y:i,width:n-e,height:s-i}}static vertexPointsFor(t){const e=Dr(t.bounds);return t.points.map(i=>ko({x:t.bounds.x+i.x,y:t.bounds.y+i.y},e,t.angle))}static hitTestVertex(t,e,i=a2){const n=ji.vertexPointsFor(t);let s,r=i;return n.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=r&&(r=l,s=c)}),s}static toLocalPoint(t,e){const i=Dr(t.bounds),n=ko(e,i,-t.angle);return{x:n.x-t.bounds.x,y:n.y-t.bounds.y}}static moveVertex(t,e,i){const n=t.points.map((u,d)=>d===e?ji.toLocalPoint(t,i):u),s=Math.min(...n.map(u=>u.x)),r=Math.min(...n.map(u=>u.y)),o=Math.max(...n.map(u=>u.x)),c=Math.max(...n.map(u=>u.y)),l={x:t.bounds.x+s,y:t.bounds.y+r,width:o-s,height:c-r},h=n.map(u=>({x:u.x-s,y:u.y-r}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const i=ji.toLocalPoint(t,e),{points:n}=t;let s=n.length-1,r=1/0;for(let c=0;c<n.length;c++){const l=n[c],h=n[(c+1)%n.length],u=ji.distanceToSegment(i,l,h);u<r&&(r=u,s=c)}const o=[...n.slice(0,s+1),i,...n.slice(s+1)];return{...t,points:o}}static distanceToSegment(t,e,i){const n=i.x-e.x,s=i.y-e.y,r=n*n+s*s,o=r===0?0:Math.max(0,Math.min(1,((t.x-e.x)*n+(t.y-e.y)*s)/r)),c=e.x+o*n,l=e.y+o*s;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=s2?t:{...t,points:t.points.filter((i,n)=>n!==e)}}}const ru=6,zo=ru/2,N0=20,O0=24,U0=9,F0=6,k0=7,z0=6,Un=4;class xo{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:i,width:n,height:s}=t.bounds,r=e+n/2,o=i+s/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(n,s)/2,h=c?l:n/2,u=c?l:s/2,d=Math.max(n,s)/2,f=t.brightness??0,p=f>0?Math.max(d*(1+U0*f),z0*f)-d:0,v=f>0?d*(1+k0*f)-d:0,m=3*O0*(t.blur??0)+1.5*N0*t.haloScale,g=Math.max(p,v,0)+m+2;return{x:r-h-g,y:o-u-g,width:2*(h+g),height:2*(u+g)}}paintInto(t,e,i,n=!1){this.ctx.save(),this.ctx.scale(i,i),this.ctx.translate(-e.x,-e.y);const s=t.selected?{...t,selected:!1}:t;n?this.paintGhost(s,1.5):this.paintShape(s),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(${(O0*e).toFixed(2)}px)`);const i=t.brightness??0;i>0&&this.paintDazzle(t,i),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:i,y:n,width:s,height:r}=t.bounds,o=i+s/2,c=n+r/2,l=Math.max(s,r)/2,h=Math.max(l*(1+U0*e),z0*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<=F0;d++){const f=d/F0,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+k0*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,m=c+Math.sin(p)*d,g=this.ctx.createLinearGradient(o,c,v,m);g.addColorStop(0,this.withAlpha(t.color,e*.55)),g.addColorStop(.35,this.withAlpha(t.color,e*.22)),g.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=g,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,m),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const i=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!i)return t.color;const n=Number.parseInt(i[1],16),s=r=>Math.round(r+(255-r)*e);return`rgb(${s(n>>16&255)}, ${s(n>>8&255)}, ${s(n&255)})`}withAlpha(t,e){const i=Math.max(0,Math.min(1,e)),n=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!n)return t;const s=Number.parseInt(n[1],16);return`rgba(${s>>16&255}, ${s>>8&255}, ${s&255}, ${i.toFixed(3)})`}paintBase(t){this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.tracePath(t),this.ctx.fill()}paintGhost(t,e){this.ctx.save(),this.tracePath(t),this.ctx.setLineDash([e*3,e*2]),this.ctx.lineWidth=e,this.ctx.strokeStyle=t.color,this.ctx.stroke(),this.ctx.restore()}tracePath(t){if(this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:i,width:n,height:s}=t.bounds,r=n/2,o=s/2;this.ctx.ellipse(e+r,i+o,r,o,t.angle,0,2*Math.PI)}else{const{x:e,y:i,width:n,height:s}=t.bounds;this.ctx.save(),this.ctx.translate(e+n/2,i+s/2),this.ctx.rotate(t.angle),this.ctx.translate(-n/2,-s/2),t.points.forEach((r,o)=>{o===0?this.ctx.moveTo(r.x,r.y):this.ctx.lineTo(r.x,r.y)}),this.ctx.closePath(),this.ctx.restore()}}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=N0*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(ji.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of ji.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,Un,Un,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(ji.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintPictureFrame(t,e,i){const n=this.ctx;if(n.save(),t&&t.length===4){n.strokeStyle="#39f",n.lineWidth=1.5,n.setLineDash([6,4]),n.beginPath(),n.moveTo(t[0].x,t[0].y);for(const s of t.slice(1))n.lineTo(s.x,s.y);n.closePath(),n.stroke(),n.setLineDash([])}for(const s of e){const r=xo.landmarkColour(s.residualDeg),o=s.selected?3:2;s.selected&&(n.strokeStyle="#fff",n.lineWidth=o+3,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Un+2,Un+2,0,0,2*Math.PI),n.stroke()),s.scene&&(n.strokeStyle=r,n.lineWidth=1,n.beginPath(),n.moveTo(s.picture.x,s.picture.y),n.lineTo(s.scene.x,s.scene.y),n.stroke(),n.fillStyle=r,n.beginPath(),n.ellipse(s.scene.x,s.scene.y,Un,Un,0,0,2*Math.PI),n.fill()),n.strokeStyle=r,n.lineWidth=o,n.beginPath(),n.ellipse(s.picture.x,s.picture.y,Un+2,Un+2,0,0,2*Math.PI),n.stroke(),this.paintLabel(s.label,s.picture.x+Un+5,s.picture.y-Un-2,r)}i&&this.paintLabel(i,8,8,"#fff",13),n.restore()}static landmarkColour(t){return t===void 0?"#ffb000":t<=1?"#3c3":t<=3?"#ffb000":"#f33"}paintLabel(t,e,i,n,s=11){const r=this.ctx;r.save(),r.font=`${s}px system-ui, sans-serif`,r.textBaseline="top";const o=r.measureText(t).width;r.fillStyle="rgba(0, 0, 0, 0.6)",r.fillRect(e-3,i-2,o+6,s+4),r.fillStyle=n,r.fillText(t,e,i),r.restore()}paintGroupHandles(t){this.paintHandleFrame(ji.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 i of km){const n=t[i];this.ctx.fillRect(n.x-zo,n.y-zo,ru,ru)}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,zo+1,zo+1,0,0,2*Math.PI),this.ctx.fill())}}const B0=.05,H0=.08,G0=2,V0=3,o2=14,c2=.02;class l2{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 i=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,i):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 i=this.context;if(!t||!i)return;const n=i.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,n,B0);for(const{param:s,ratio:r}of t.pitch)s.setTargetAtTime(Math.min(e.pitchHz*r,i.sampleRate/2-1),n,B0)}buildSynthesizedVoice(t,e){const i=this.context;if(i)switch(t.kind){case"hum":return this.buildHum(i,e);case"whistle":return this.buildWhistle(i,e);case"rumble":return this.buildRumble(i,e);case"crackle":return this.buildCrackle(i,e);default:return}}buildHum(t,e){const i=t.createOscillator();i.type="sawtooth";const n=t.createOscillator();n.type="sawtooth";const s=t.createBiquadFilter();s.type="lowpass",s.Q.value=1;const r=t.createGain();return r.gain.value=0,i.connect(s),n.connect(s),s.connect(r).connect(t.destination),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.16,pitch:[{param:i.frequency,ratio:1},{param:n.frequency,ratio:1.006},{param:s.frequency,ratio:6}]}}buildWhistle(t,e){const i=t.createOscillator();i.type="sine";const n=t.createOscillator();n.type="sine",n.frequency.value=5;const s=t.createGain(),r=t.createGain();return r.gain.value=0,n.connect(s).connect(i.frequency),i.connect(r).connect(t.destination),i.start(),n.start(),{key:e,nodes:[s,r],sources:[i,n],volumeParam:r.gain,gainScale:.22,pitch:[{param:i.frequency,ratio:1},{param:s.gain,ratio:.012}]}}buildRumble(t,e){const i=t.createBufferSource();i.buffer=this.brownNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="lowpass",n.Q.value=.8;const s=t.createGain();return s.gain.value=0,i.connect(n).connect(s).connect(t.destination),i.start(),{key:e,nodes:[n,s],sources:[i],volumeParam:s.gain,gainScale:1.4,pitch:[{param:n.frequency,ratio:1}]}}buildCrackle(t,e){const i=t.createBufferSource();i.buffer=this.whiteNoise(t),i.loop=!0;const n=t.createBiquadFilter();n.type="bandpass",n.Q.value=1.2;const s=t.createGain();s.gain.value=0;const r=t.createBufferSource();r.buffer=this.crackleEnvelope(t),r.loop=!0;const o=t.createGain();return o.gain.value=0,r.connect(o).connect(s.gain),i.connect(n).connect(s).connect(t.destination),i.start(),r.start(),{key:e,nodes:[n,s,o],sources:[i,r],volumeParam:o.gain,gainScale:.9,pitch:[{param:n.frequency,ratio:4}]}}async buildRecordedVoice(t,e,i){const n=this.context;if(!n)return;let s;try{s=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(i!==this.voiceToken||!this.context)return;const r=n.createBufferSource();r.buffer=s,r.loop=!0;const o=n.createGain();o.gain.value=0,r.connect(o).connect(n.destination),r.start(),this.voice={key:e,nodes:[o],sources:[r],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 i=this.buffers.get(t);return i||(i=fetch(t).then(n=>{if(!n.ok)throw new Error(`Audio fetch failed (${n.status}): ${t}`);return n.arrayBuffer()}).then(n=>e.decodeAudioData(n)),this.buffers.set(t,i)),i}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*G0),t.sampleRate),i=e.getChannelData(0);for(let n=0;n<i.length;n++)i[n]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*G0),t.sampleRate),i=e.getChannelData(0);let n=0,s=0;for(let r=0;r<i.length;r++)n=(n+.02*(Math.random()*2-1))/1.02,i[r]=n,s=Math.max(s,Math.abs(n));if(s>0)for(let r=0;r<i.length;r++)i[r]/=s;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*V0),t.sampleRate),i=e.getChannelData(0),n=Math.max(1,Math.floor(c2*t.sampleRate)),s=Math.round(V0*o2);for(let r=0;r<s;r++){const o=Math.floor(Math.random()*i.length),c=.4+Math.random()*.6;for(let l=0;l<n&&o+l<i.length;l++)i[o+l]=Math.max(i[o+l],c*(1-l/n))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const i=e.currentTime;t.volumeParam.cancelScheduledValues(i),t.volumeParam.setTargetAtTime(0,i,H0/3);const n=i+H0;for(const s of t.sources){s.onended=()=>{s.disconnect();for(const r of t.nodes)r.disconnect()};try{s.stop(n)}catch{s.disconnect();for(const r of t.nodes)r.disconnect()}}}}function Jc(a){return[...a].sort((t,e)=>t.t-e.t)}function W0(a,t){let e;for(const i of Jc(a)){if(i.t>t)break;e=i}return e}const zl=Math.PI/180,Bo=180/Math.PI;class ms{constructor(t,e,i){this.kind=t,this.canvasHeightPx=e,this.fovDeg=i;const n=i*zl/2;this.focalPx=t==="equidistant"?e/2/n:e/2/Math.tan(n)}focalPx;static of(t,e,i){return new ms(t.projection,e,i)}degToPx(t){const e=t*zl;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Bo:2*Math.atan(t/(2*this.focalPx))*Bo}angleDegToRadiusPx(t){const e=t*zl;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*Bo:Math.atan(t/this.focalPx)*Bo}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(Re.angularWidthDeg(t))}}class Wi{static fovOf(t,e){return ai(t,e)?.fovDeg??ri.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,i)=>({...e,angular:i.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,i)=>{if(!e.angular)return e;const{width:n,height:s}=i.toBoundsSize(e.angular),r={x:e.bounds.x+(e.bounds.width-n)/2,y:e.bounds.y+(e.bounds.height-s)/2,width:n,height:s};if(e.kind!=="polygon")return{...e,bounds:r};const o=e.bounds.width===0?1:n/e.bounds.width,c=e.bounds.height===0?1:s/e.bounds.height;return{...e,bounds:r,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);if(s&&Math.abs(s.x-e.bounds.x)<Wi.UNMOVED_PX&&Math.abs(s.y-e.bounds.y)<Wi.UNMOVED_PX)return e;const r=this.aimFrom(t,i,n,e.bounds);return r?{...e,aim:r}:e})}static UNMOVED_PX=.01;static aimOf(t,e,i){const n=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,n,ai(t,e),i)}static aimFrom(t,e,i,n){if(i?.headingDeg===void 0)return;const s=this.frameCentre(t),r=e.radiusPxToAngleDeg(n.x+n.width/2-s.x),o=e.radiusPxToAngleDeg(s.y-(n.y+n.height/2));return{azimuthDeg:((i.headingDeg+r)%360+360)%360,altitudeDeg:i.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,i,n)=>{const s=e.aim&&this.positionOf(t,e.aim,e.bounds,i,n);return s?{...e,bounds:{...e.bounds,...s}}:e})}static positionOf(t,e,i,n,s){if(s?.headingDeg===void 0)return;const r=this.frameCentre(t),o=this.shortestArc(e.azimuthDeg-s.headingDeg),c=e.altitudeDeg-s.pitchDeg;return{x:r.x+this.offAxisPx(n,o)-i.width/2,y:r.y-this.offAxisPx(n,c)-i.height/2}}static frameCentre(t){return{x:ri.frameWidthPx(t.instrument,Re.CANVAS_HEIGHT_PX)/2,y:Re.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Wi.OFF_CANVAS_DEG?Math.sign(e)*Wi.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,i){const n=ri.frameWidthPx(e,Re.CANVAS_HEIGHT_PX)/2,s=ri.frameWidthPx(t.instrument,Re.CANVAS_HEIGHT_PX)/2,r=Re.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=i?.get(o.t)??c,h=ms.of(e,Re.CANVAS_HEIGHT_PX,l),u=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,p=f.x+f.width/2-n,v=f.y+f.height/2-r,m=Math.hypot(p,v),g=m===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(m))/m,_={...f,x:s+p*g-f.width/2,y:r+v*g-f.height/2};return{...d,shape:{...d.shape,bounds:_}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:i}=t;for(const n of[...i.allKeyframes]){const s=ai(t,n.t),r=this.fovOf(t,n.t),o=ms.of(t.instrument,Re.CANVAS_HEIGHT_PX,r);i.addKeyframe(n.t,n.shapes.map(c=>({...c,shape:e(c.shape,o,s)})))}}}function h2(a){return dn.restore(u2(a),a.provenance)}function u2(a){return Wi.toAngular(a),Wi.toAim(a),{version:1,id:a.id,time:a.event.time,endTime:a.event.endTime,durationSeconds:a.event.durationSeconds,utcOffsetHours:a.event.utcOffsetHours,timeZone:a.event.timeZone,place:a.event.place,witness:a.witness,testimony:a.testimony,description:a.event.description,tags:a.event.tags,timeline:a.timeline.toJSON(),witnessTrack:a.witnessTrack.toJSON(),weatherTrack:a.weatherTrack.toJSON(),soundTrack:a.soundTrack.toJSON(),weather:a.weather,decor:a.decor,milestones:a.milestones.length>0?a.milestones:void 0,references:a.references.length>0?a.references:void 0,roads:a.roads.length>0?a.roads:void 0,weatherSource:a.weatherSource,instrument:a.instrumentId,exposureSeconds:a.exposureSeconds,interpretation:a.interpretation}}function d2(a){const{recording:t,provenance:e}=dn.strip(a),i=f2(t);return i.provenance=e,i}function f2(a){const t=new Sl({eventType:"sighting",time:a.time,endTime:a.endTime,durationSeconds:a.durationSeconds,utcOffsetHours:a.utcOffsetHours,timeZone:a.timeZone,place:a.place,description:a.description,tags:a.tags},_l.fromJSON(a.timeline),a.witnessTrack?go.fromJSON(a.witnessTrack):new go,a.weatherTrack?vo.fromJSON(a.weatherTrack):new vo,a.soundTrack?Mo.fromJSON(a.soundTrack):new Mo,a.witness&&{id:a.witness.id,title:a.witness.title,lastName:a.witness.lastName,firstNames:a.witness.firstNames},a.id,a.weather,a.decor??[],a.weatherSource,a.instrument,a.exposureSeconds??a.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),Jc(a.milestones??[]),a.references??[],a.roads??[]);return t.testimony=a.testimony,t.interpretation=a.interpretation,Wi.toBounds(t),Wi.toPosition(t),t}const X0=2;function zm(a){return a==="building"||a==="vehicle"}function p2(a,t){const e=a.litKeyframes;if(!e||e.length===0)return a.lit??!1;let i=e[0];for(const n of e){if(n.t>t)break;i=n}return i.lit}function m2(a,t){return a.pattern.kind==="steady"?!0:Bm(a,t,t+1)>.5}function Bm(a,t,e){if(a.pattern.kind==="steady")return 1;const{perMinute:i,dutyCycle:n,phase:s=0}=a.pattern,r=Math.min(Math.max(n,0),1);if(r===0||i<=0)return 0;const o=6e4/i,c=t/o+s,l=e/o+s;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),r)<r?1:0;const h=u=>Math.floor(u)*r+Math.min(u-Math.floor(u),r);return(h(l)-h(c))/(l-c)}function Id(a,t){const e=a.track,i={eastM:a.eastM,northM:a.northM,altitudeM:0,headingDeg:a.headingDeg};if(!e||e.length===0)return i;if(e.length===1||t<=e[0].t)return q0(e[0],a);const n=e[e.length-1];if(t>=n.t)return q0(n,a);for(let s=0;s<e.length-1;s++){const r=e[s],o=e[s+1];if(t<r.t||t>o.t)continue;const c=o.t-r.t,l=c===0?0:(t-r.t)/c;return{eastM:r.eastM+(o.eastM-r.eastM)*l,northM:r.northM+(o.northM-r.northM)*l,altitudeM:(r.altitudeM??0)+((o.altitudeM??0)-(r.altitudeM??0))*l,headingDeg:r.headingDeg??a.headingDeg}}return i}function q0(a,t){return{eastM:a.eastM,northM:a.northM,altitudeM:a.altitudeM??0,headingDeg:a.headingDeg??t.headingDeg}}class En{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static windowEndingAt(t,e){const i=Number.isFinite(e)?Math.max(0,e):0,n=Math.max(0,t-i*1e3),s=Math.max(0,t-n);return{fromMs:n,toMs:t,ms:s,seconds:s/1e3}}static instants(t,e,i,n,s){if(!(n>0))return 1;const r=s>0?En.travelDegOver(t,e,i,i+n*1e3)/s/En.PIXELS_PER_INSTANT:0,o=En.flashesOver(t,n)*En.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(r,o));return c<2?1:Math.min(En.MAX_INSTANTS,c)}static travelDegOver(t,e,i,n){let s=0;for(const r of t){if(!r.track||r.track.length<2)continue;const o=En.directionAt(r,e,i),c=En.directionAt(r,e,n),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));s=Math.max(s,Math.acos(l)*180/Math.PI)}return s}static flashesOver(t,e){let i=0;for(const n of t)for(const s of n.lights??[])s.pattern.kind==="flash"&&(i=Math.max(i,s.pattern.perMinute));return i/60*e}static directionAt(t,e,i){const n=Id(t,i),s=n.eastM,r=n.altitudeM-e,o=n.northM,c=Math.hypot(s,r,o);return c===0?{x:0,y:1,z:0}:{x:s/c,y:r/c,z:o/c}}}function jc(a,t){for(const e of a){const i=e.toLowerCase().split("-")[0];if(t.includes(i))return i}return"en"}class ao{static preferencesFor(t){const e=navigator.languages??[],i=this.declaredFor(t);return i?[i,...e]:e}static declaredFor(t){for(let e=t;e;){const i=e.closest("[lang]")?.getAttribute("lang")?.trim();if(i)return i;const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}}}class zs{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const i of this.preferences){const n=t[i]??t[zs.base(i)];if(n)return n}const e=new Set(this.preferences.map(i=>zs.base(i)));for(const[i,n]of Object.entries(t))if(n&&e.has(zs.base(i)))return n;return Object.values(t).find(i=>i)??void 0}write(t,e,i){const n=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return n;const s={...t},r=Object.keys(s).find(o=>o===i)??Object.keys(s).find(o=>zs.base(o)===zs.base(i))??i;return n===void 0?delete s[r]:s[r]=n,Object.keys(s).length===0?void 0:s}static base(t){return t.toLowerCase().split("-")[0]}}const g2=["en","fr"],v2={en:()=>Kc(()=>Promise.resolve().then(()=>x2),void 0,import.meta.url).then(a=>a.ufoMessages_en),fr:()=>Kc(()=>import("./UfoMessages_fr-CnenjNH2.js"),[],import.meta.url).then(a=>a.ufoMessages_fr)};function M2(a){return v2[a]()}const Hm={play:"Play",pause:"Pause",noDuration:"No observation duration",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showReferences:"Show the pictures of the place",hideReferences:"Hide the pictures of the place",referenceOpacity:"Picture opacity",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},x2=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Hm},Symbol.toStringTag,{value:"Module"})),Gm=Math.PI/180,y2=180/Math.PI,_2=256,Vm=19,S2=1.25;function Wm(a,t){return 156543.03392*Math.cos(a*Gm)/2**t}function Xm(a,t){return Wm(a,t)*_2}function w2(a,t){let e=0;for(;e<Vm&&Xm(a,e+1)>=t;)e++;return e}function qm(a,t){return Xm(a,t)}function b2(a,t){const e=t*S2;let i=0;for(;i<Vm&&Wm(a,i)>e;)i++;return i}function kc(a){const t=a*Gm;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function Ym(a,t,e){const i=2**e;return{x:(a+180)/360*i,y:kc(t)*i}}function Km(a,t,e){const i=kc(a.north),n=kc(a.south);return{x:(t-a.west)/(a.east-a.west),y:(kc(e)-i)/(n-i)}}function E2(a,t,e){const{x:i,y:n}=Ym(a,t,e);return{x:Math.floor(i),y:Math.floor(n),z:e}}function A2(a){const t=2**a.z,e=a.x/t*360-180,i=(a.x+1)/t*360-180,n=Y0(a.y,t);return{south:Y0(a.y+1,t),north:n,west:e,east:i}}function Y0(a,t){const e=a/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*y2}function $m(a,t,e,i){const n=E2(a,t,e),s=Math.floor(i/2),r=[];for(let l=-s;l<=s;l++)for(let h=-s;h<=s;h++)r.push({x:n.x+h,y:n.y+l,z:e});const o=r.map(A2),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:r,bounds:c}}class oa{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 i,n=1/0;for(const s of this.targets){const r=Math.hypot(s.x-t,s.y-e);r>s.radius||r>n||(i=s,n=r)}return i}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(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,i){const n=Km(t,i,e);return{x:n.x*this.width,y:n.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const i=t.imagery;if(!i)return;const n=this.toCanvas(t.bounds,i.bounds.north,i.bounds.west),s=this.toCanvas(t.bounds,i.bounds.south,i.bounds.east);e.drawImage(i.source,n.x,n.y,s.x-n.x,s.y-n.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 i of t.decor){const n=this.toCanvas(t.bounds,i.lat,i.lng);if(i.label&&this.targets.push({kind:"decor",label:i.label,lat:i.lat,lng:i.lng,x:n.x,y:n.y,radius:7}),e.beginPath(),e.rect(n.x-3.5,n.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(),i.headingDeg===void 0)continue;const s=(i.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(n.x,n.y),e.lineTo(n.x+Math.cos(s)*10,n.y+Math.sin(s)*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,i=t.path.points.map(n=>this.toCanvas(t.bounds,n.lat,n.lng));e.beginPath(),e.moveTo(i[0].x,i[0].y);for(const n of i.slice(1))e.lineTo(n.x,n.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:i,coneHalfAngleDeg:n}=t;if(i===void 0||n===void 0)return;const{ctx:s}=this,r=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(i-90)*Math.PI/180,l=n*Math.PI/180;s.save(),s.beginPath(),s.moveTo(r.x,r.y),s.arc(r.x,r.y,o,c-l,c+l),s.closePath();const h=s.createRadialGradient(r.x,r.y,0,r.x,r.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),s.fillStyle=h,s.fill(),s.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const i of[...t.markers].sort((n,s)=>Number(n.current)-Number(s.current))){const n=this.toCanvas(t.bounds,i.lat,i.lng);this.targets.push({kind:"milestone",label:i.note?`${i.label} — ${i.note}`:i.label,lat:i.lat,lng:i.lng,t:i.t,x:n.x,y:n.y,radius:oa.MARKER_RADIUS_PX}),e.beginPath(),e.arc(n.x,n.y,oa.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=i.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=i.current?"#1d2321":"#fff",e.fillText(i.label,n.x,n.y)}}paintWitness(t,e){const{ctx:i}=this,n=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:n.x,y:n.y,radius:8});const s=t.markers.some(r=>{if(!r.current)return!1;const o=li(r.lat,r.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=oa.ON_MARKER_M});i.beginPath(),i.arc(n.x,n.y,s?oa.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),s||(i.fillStyle="#ff5a3c",i.fill()),i.lineWidth=4,i.strokeStyle="rgba(0, 0, 0, 0.5)",i.stroke(),i.lineWidth=s?3:2.5,i.strokeStyle=s?"#ff5a3c":"#fff",i.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,i=16;t.beginPath(),t.moveTo(e,i-9),t.lineTo(e-4.5,i+5),t.lineTo(e,i+2),t.lineTo(e+4.5,i+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,i+6),t.fillText("N",e,i+6)}paintFooter(t,e){const{ctx:i}=this;i.font="9px sans-serif",i.textBaseline="bottom";const n=e?this.wrap(e,this.width-20):[];let s=this.height-4;i.textAlign="right";for(const f of n.slice().reverse())this.paintOutlinedText(f,this.width-6,s),s-=11;const r=(t.south+t.north)/2,c=Math.abs(li(r,t.east,r,t.west).x)/this.width,l=oa.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=s-3;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.6)",i.beginPath(),i.moveTo(u,d),i.lineTo(u+h,d),i.stroke(),i.lineWidth=1.5,i.strokeStyle="rgba(255, 255, 255, 0.95)",i.stroke(),i.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,i){const{ctx:n}=this;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.75)",n.strokeText(t,e,i),n.fillStyle="#fff",n.fillText(t,e,i)}wrap(t,e){const i=[];let n="";for(const s of t.split(" ")){const r=n?`${n} ${s}`:s;n&&this.ctx.measureText(r).width>e?(i.push(n),n=s):n=r}return n&&i.push(n),i}}const on=256,K0=3,T2=32768;class R2{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 i=(t.south+t.north)/2,n=(t.west+t.east)/2,s=Math.abs(li(i,t.east,i,t.west).x),r=Math.abs(li(t.north,n,t.south,n).z),o=w2(i,Math.max(s,r)),{tiles:c}=$m(n,i,o,K0),l=K0*on,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 m=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(p,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,i,n){const s=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),r=await this.fetchImpl(s);if(!r.ok)throw new Error(`Elevation tile fetch failed (${r.status}): ${s}`);const o=await createImageBitmap(await r.blob()),c=document.createElement("canvas");c.width=on,c.height=on;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,on,on),u=(t.x-e.x)*on,d=(t.y-e.y)*on;for(let f=0;f<on;f++)for(let p=0;p<on;p++){const v=(f*on+p)*4,m=h[v]*256+h[v+1]+h[v+2]/256-T2,g=u+p,_=d+f;i[_*n+g]=m}}sampleAt(t,e,i,n,s,r){const{x:o,y:c}=Ym(e,t,i),l=(o-n.x)*on,h=(c-n.y)*on,u=Math.max(0,Math.min(r-1,Math.floor(l))),d=Math.max(0,Math.min(r-1,Math.floor(h))),f=Math.min(r-1,u+1),p=Math.min(r-1,d+1),v=l-u,m=h-d,g=s[d*r+u],_=s[d*r+f],w=s[p*r+u],M=s[p*r+f],S=g+(_-g)*v,b=w+(M-w)*v;return S+(b-S)*m}}const zc=256,D2=5;async function C2(a,t,e,i){const n=(a.south+a.north)/2,s=(a.west+a.east)/2,r=Math.abs(li(n,a.east,n,a.west).x),o=Math.abs(li(a.north,s,a.south,s).z),c=Math.max(r,o),{zoom:l,gridSize:h}=I2(n,c,Math.max(t.width,t.height)),{tiles:u,bounds:d}=$m(s,n,l,h),f=h*zc,p=document.createElement("canvas");p.width=f,p.height=f;const v=p.getContext("2d");if(!v)throw new Error("2D canvas context unavailable");const m=u[0];await Promise.all(u.map(async M=>{const S=e(M),b=await i(S);if(!b.ok)throw new Error(`Imagery tile fetch failed (${b.status}): ${S}`);const T=await createImageBitmap(await b.blob());v.drawImage(T,(M.x-m.x)*zc,(M.y-m.y)*zc)}));const g=Math.min(Math.max(t.width,t.height),f);if(g===f)return{source:p,width:f,height:f,bounds:d};const _=document.createElement("canvas");_.width=g,_.height=g;const w=_.getContext("2d");if(!w)throw new Error("2D canvas context unavailable");return w.drawImage(p,0,0,f,f,0,0,g,g),{source:_,width:g,height:g,bounds:d}}function I2(a,t,e){let i=b2(a,t/Math.max(1,e)),n=$0(a,i,t);for(;n>D2&&i>0;)i--,n=$0(a,i,t);return{zoom:i,gridSize:n,mPerPixel:qm(a,i)/zc}}function $0(a,t,e){const i=Math.ceil(e/2/qm(a,t));return Math.max(3,2*i+1)}class P2{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 C2(t,e,i=>this.tileUrlTemplate.replace("{z}",String(i.z)).replace("{y}",String(i.y)).replace("{x}",String(i.x)),this.fetchImpl)}}class Sn{attribution="Roads © OpenStreetMap contributors, as surveyed today";contemporary=!0;static DRIVABLE=["motorway","trunk","primary","secondary","tertiary","unclassified","residential","service","track","motorway_link","trunk_link","primary_link","secondary_link","tertiary_link"];static WIDTH_M={motorway:11,trunk:9,primary:8,secondary:7,tertiary:6.5,unclassified:5.5,residential:5.5,service:4,track:3.5};static DEFAULT_WIDTH_M=5;static ENDPOINTS=["https://overpass-api.de/api/interpreter","https://overpass.kumi.systems/api/interpreter","https://overpass.private.coffee/api/interpreter"];fetchImpl;endpoints;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.endpoints=t.endpoints??Sn.ENDPOINTS}static queue=Promise.resolve();static RETRY_MS=4e3;async getRoads(t){const e=`${t.south},${t.west},${t.north},${t.east}`,i=`[out:json][timeout:30];way["highway"~"^(${Sn.DRIVABLE.join("|")})$"](${e});out geom;`;return this.waysFrom(await this.queued(()=>this.ask(i)))}waysFrom(t){const e=[];for(const i of t.elements??[]){const n=i.geometry,s=i.tags;!s||!n||n.length<2||e.push({id:`osm-${i.id??e.length}`,name:s.name,surface:Sn.surfaceOf(s),widthM:Sn.widthOf(s),points:n.map(r=>({lat:r.lat,lng:r.lon}))})}return e}queued(t){const e=Sn.queue.then(t,t);return Sn.queue=e.catch(()=>{}),e}async ask(t){let e;for(const i of this.endpoints)for(let n=0;n<2;n++){try{const s=await this.fetchImpl(`${i}?data=${encodeURIComponent(t)}`);if(s.ok)return await s.json();if(e=new Error(`${new URL(i).host} refused (${s.status})`),s.status!==429&&s.status!==504)break}catch(s){e=new Error(`${new URL(i).host} unreachable (${String(s)})`);break}await new Promise(s=>setTimeout(s,Sn.RETRY_MS))}throw e??new Error("No Overpass instance answered")}static widthOf(t){const e=Number.parseFloat(t.width??t.est_width??"");if(Number.isFinite(e)&&e>0)return e;const i=Number.parseInt(t.lanes??"",10);return Number.isFinite(i)&&i>0?i*3.5:Sn.WIDTH_M[t.highway]??Sn.DEFAULT_WIDTH_M}static surfaceOf(t){const e=t.surface;return e==="dirt"||e==="earth"||e==="mud"?"dirt":e==="gravel"||e==="fine_gravel"||e==="compacted"||e==="ground"||e==="sand"||e==="unpaved"?"gravel":e?"paved":t.highway==="track"?"gravel":"paved"}}const Bl="https://ufoathome.org/roads/index.json";class Pd{attributionRead;contemporaryRead;fetchImpl;indexUrls;fallback;index;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.indexUrls=t.indexUrls??Pd.defaultIndexUrls(),this.fallback=t.fallback}get attribution(){return this.attributionRead??this.fallback?.attribution??"Roads © OpenStreetMap contributors"}get contemporary(){return this.contemporaryRead??this.fallback?.contemporary??!0}async getRoads(t){const e=await this.held(t);if(e)return e;if(!this.fallback)return[];const i=await this.fallback.getRoads(t);return this.attributionRead=this.fallback.attribution,this.contemporaryRead=this.fallback.contemporary,i}async held(t){let e;try{e=await this.load()}catch{return}const i=e.find(({entry:n})=>n.north>=t.north&&n.south<=t.south&&n.east>=t.east&&n.west<=t.west);if(i)try{const n=await this.fetchImpl(new URL(i.entry.file,i.indexUrl).href);if(!n.ok)return;const s=await n.json();return Array.isArray(s?.ways)?(this.attributionRead=s.attribution,this.contemporaryRead=s.contemporary,s.ways):void 0}catch{return}}load(){return this.index??=this.fetchFirstAvailable(),this.index}async fetchFirstAvailable(){for(const t of this.indexUrls)try{const e=await this.fetchImpl(t);if(!e.ok)continue;const i=await e.json();if(Array.isArray(i?.entries))return i.entries.map(n=>({entry:n,indexUrl:t}))}catch{}return[]}static defaultIndexUrls(){const t=`?v=${encodeURIComponent("0.65.3")}`,e=typeof location>"u"?void 0:new URL("/roads/index.json",location.href).href;return(e&&e!==Bl?[e,Bl]:[Bl]).map(i=>i+t)}}function L2(){return{elevation:new R2,imagery:Zm(),roads:N2()}}function Zm(){return new P2}function N2(){return new Pd({fallback:new Sn})}const O2=new Set,cr="show-witness-map",lr="hide-milestones";class Ki extends HTMLElement{static get observedAttributes(){return["src",cr,lr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;witnessMapButton;referencesButton;referenceOpacityInput;referencesShownState=!0;referenceOpacityTouched=!1;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=Sl.create();sightingAudio=new l2;soundPreview;player;loopEnabled=!1;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;selectionShown=!0;overlayPainter;enableClickToPlay=!0;fullscreenTarget;messages=Hm;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),i=e&&this.shapeAt(e.x,e.y),n=this.said.read(i?.shape.title);if(!n){this.tooltip.hidden=!0;return}this.tooltip.textContent=n,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.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 i=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-i.left+12}px`,this.tooltip.style.top=`${t.clientY-i.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>${O1}</style>${N1}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new xo(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.referencesButton=this.shadow.getElementById("references"),this.referenceOpacityInput=this.shadow.getElementById("reference-opacity"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new oa(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",i=>{i.key!=="Enter"&&i.key!==" "||(i.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.referencesButton.addEventListener("click",()=>this.toggleReferences()),this.referenceOpacityInput.addEventListener("input",()=>{this.referenceOpacityTouched=!0,this.dispatchReferenceView()}),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(this.snapSeekToMark(Number(this.seekInput.value)))),this.seekInput.addEventListener("pointerdown",e=>{this.seekSnapArmed=!0,this.nameMarkUnder(e)}),this.seekInput.addEventListener("pointerup",()=>{this.seekSnapArmed=!1}),this.seekInput.addEventListener("pointermove",e=>this.nameMarkUnder(e)),this.seekInput.addEventListener("pointerleave",()=>this.seekInput.removeAttribute("title")),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.hostControls(void 0),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const 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,i){t==="src"&&i&&i!==e&&this.isConnected&&this.loadFromSrc(i),t===cr&&this.applyWitnessMapDefault(),t===lr&&this.setMilestonesShown(!this.hasAttribute(lr))}async loadFromSrc(t){this.sightingData=await Fm.json(t)}get sightingData(){return h2(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=d2(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(n=>this.highlightedSourceIds.has(n))||(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.updateReferences(),this.player.seek(this.player.time)}hostControls(t){const e=[this.milestonesButton,this.referenceOpacityInput,this.referencesButton,this.witnessMapButton];if(t)for(const i of e)t.appendChild(i);else for(const i of e)this.toolbar.appendChild(i)}get referencesShown(){return this.referencesShownState}get referenceOpacity(){return Number(this.referenceOpacityInput.value)}toggleReferences(){this.referencesShownState=!this.referencesShownState,this.updateReferencesButton(),this.dispatchReferenceView()}updateReferences(){const t=this.currentSighting.references;!this.referenceOpacityTouched&&t.length>0&&(this.referenceOpacityInput.value=String(t[0].opacity)),this.updateReferencesButton()}updateReferencesButton(){const t=this.currentSighting.references.length>0;this.referencesButton.hidden=!t,this.referenceOpacityInput.hidden=!t||!this.referencesShownState,this.referencesButton.setAttribute("aria-pressed",String(this.referencesShownState));const e=this.referencesShownState?this.messages.hideReferences:this.messages.showReferences;this.referencesButton.title=e,this.referencesButton.setAttribute("aria-label",e),this.referenceOpacityInput.title=this.messages.referenceOpacity,this.referenceOpacityInput.setAttribute("aria-label",this.messages.referenceOpacity)}dispatchReferenceView(){this.dispatchEvent(new CustomEvent("referenceview",{detail:{shown:this.referencesShown,opacity:this.referenceOpacity}}))}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Jc(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(i=>{const n=document.createElement("button");n.type="button",n.className="milestone-mark",n.style.left=`${Math.min(Math.max(i.t/t,0),1)*100}%`;const s=this.said.read(i.label)??"",r=this.said.read(i.note),o=r?`${s} — ${r}`:s;return n.title=o,n.setAttribute("aria-label",o),n.dataset.t=String(i.t),n.addEventListener("click",()=>this.player.seek(i.t)),n}))}seekSnapArmed=!1;static MARK_SNAP_PX=6;markNear(t){const e=this.player.seekableDuration,i=this.seekInput.getBoundingClientRect().width;if(e<=0||i<=0)return;const n=Ki.MARK_SNAP_PX/i*e;let s;for(const r of this.milestoneMarks.children){const o=Number(r.dataset.t);Math.abs(o-t)>n||(!s||Math.abs(o-t)<Math.abs(s.t-t))&&(s={t:o,name:r.title})}return s}snapSeekToMark(t){return this.seekSnapArmed?(this.seekSnapArmed=!1,this.markNear(t)?.t??t):t}nameMarkUnder(t){const e=this.seekInput.getBoundingClientRect(),i=this.player.seekableDuration;if(e.width<=0||i<=0)return;const n=(t.clientX-e.left)/e.width*i,s=this.markNear(n);s?this.seekInput.title=s.name:this.seekInput.removeAttribute("title")}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?W0(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const i=document.createElement("b");i.textContent=this.said.read(e.label)??"";const n=this.said.read(e.note),s=n?` — ${n}`:"";this.milestoneCaption.replaceChildren(i,document.createTextNode(s))}exposureInstants(t){const e=this.exposureTimes(t),i=1/e.length;return e.map(n=>({shapes:this.shapesAt(n),share:i}))}exposureTimes(t=this.currentTime){const e=En.windowEndingAt(t,this.currentSighting.exposure??0);if(e.ms<Ki.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const i=Math.min(Ki.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e.ms/Ki.SHORTEST_VISIBLE_EXPOSURE_MS))),n=Math.ceil(this.travelPxOver(e.fromMs,e.ms)/Ki.EXPOSURE_STEP_PX),s=Math.min(Ki.MAX_TRAVEL_STEPS,Math.max(i,n)),r=[];for(let o=0;o<s;o++)r.push(e.fromMs+e.ms*o/(s-1));return r}travelPxOver(t,e){const i=this.shapesAt(t),n=this.shapesAt(t+e);let s=0;for(const[r,o]of i){const c=n.get(r);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);s=Math.max(s,Math.hypot(l,h))}return s}shapeAt(t,e,i){for(const n of this.exposureTimes()){const s=this.currentSighting.timeline.hitTest(n,t,e,i);if(s)return s}}shapesAt(t){const e=new Map;for(const i of this.currentSighting.timeline.sourceIds){const n=this.currentSighting.timeline.getInterpolatedShapeAt(t,i);n&&e.set(i,n)}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=ri.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 i=this.playbackState!=="playing"?this.highlightedSourceIds:O2;this.canvasRenderer.setStarPoints(ri.starPointsOf(this.sighting.instrument));const n=(ai(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(n*Math.PI/180);const s=this.exposureInstants(t),r=this.frameShift;if(this.paintsShapes)for(const o of s)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,r))}for(const[o,c]of s[0].shapes)!this.selectionShown||!i.has(o)||(this.paintsShapes?i.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,r)));if(this.selectionShown&&i.size>1){const o=ji.groupBoundsFor([...e].filter(([c])=>i.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.overlayPainter?.(this.canvasRenderer),this.mapShapeBounds=s.flatMap(o=>[...o.shapes.values()].filter(c=>c.transparency<1).map(c=>this.shifted(c,r).bounds)),this.keepWitnessMapClear(),this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(e2(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 i2(this.currentSighting.timeline,(e,i)=>this.onFrame(e,i));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 i=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=i,this.playPauseButton.setAttribute("aria-label",i)}toggleLoop(){this.loopEnabled=!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(cr)&&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=mo.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(Ki.WITNESS_MAP_MIN_SPAN_M,Ki.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 i=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<i&&Math.abs(t.south-e.south)<i&&Math.abs(t.west-e.west)<i&&Math.abs(t.east-e.east)<i}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=Zm(),e=this.witnessMapBounds;try{const i=await t.getImageryTexture(e,{width:Ki.WITNESS_MAP_IMAGERY_PX,height:Ki.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=i,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],i=(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},n=[this.canvas.width-t.width,this.canvas.width],s=[0,t.width],r=Ki.WITNESS_MAP_CLEARANCE_PX,o=i(...n,0),c=i(...s,0);if(this.witnessMapPanel.classList.toggle("subject-overlap",o&&c),this.witnessMapPanel.classList.contains("on-the-left")){!o&&(c||!i(n[0],n[1],r))&&this.witnessMapPanel.classList.remove("on-the-left");return}i(n[0],n[1],0)&&!i(s[0],s[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const 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 i=this.canvas.width/e.width,n=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*i,top:(t.top-e.top)*n,bottom:(t.bottom-e.top)*n}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=ai(this.currentSighting,t),i=this.currentSighting.instrument,n=[],s=this.currentSighting.milestones.length>0?W0(this.currentSighting.milestones,t):void 0;for(const r of this.milestonesShown?Jc(this.currentSighting.milestones):[]){const o=ai(this.currentSighting,r.t);o?.lat===void 0||o.lng===void 0||n.push({label:this.said.read(r.label)??"",note:this.said.read(r.note),t:r.t,lat:o.lat,lng:o.lng,current:r===s})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position: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?ms.of(i,this.canvas.height,e.fovDeg).halfWidthAngleDeg(ri.aspectOf(i)):void 0,markers:n,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=ai(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(i=>i.kind!=="crop").map(i=>{const n=Id(i,t),{lat:s,lng:r}=ps(n.eastM,-n.northM,e.lat,e.lng);return{lat:s,lng:r,headingDeg:n.headingDeg,label:this.said.read(i.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,i=this.lookPitchDeg+t.pitchDeg;if(e===0&&i===0)return{x:0,y:0};const n=ai(this.currentSighting,this.currentTime),s=ms.of(this.currentSighting.instrument,this.canvas.height,n?.fovDeg??60);return{x:-s.angleDegToRadiusPx(e),y:s.angleDegToRadiusPx(i)}}gaitAt(t){return si.of(this.currentSighting)?.offsetAt(t)??si.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 zs(ao.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=jc(ao.preferencesFor(this),g2);t!=="en"&&this.applyMessages(await M2(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 i of[this.timeStartLabel,this.timeEndLabel])i.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(i.setAttribute("role","button"),i.setAttribute("tabindex","0")):(i.removeAttribute("role"),i.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateReferencesButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=j1(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?au(t.time):void 0;const i=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&i>0?i/this.realDurationMs:1,this.player.durationOverrideMs=i>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Ho(t);const e=this.currentSighting.timeline.duration,i=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?J0(Z0(this.realStartMs+i)):Ho(i)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ho(this.currentSighting.timeline.duration):this.canShowClockTime?J0(Z0(this.realStartMs+this.realDurationMs)):Ho(this.realDurationMs)}}function Z0(a){const t=new Date(a);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function J0(a){if(a.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return a.second?`${t(a.hour)}:${t(a.minute??0)}:${t(a.second)}`:`${t(a.hour)}:${t(a.minute??0)}`}function Ho(a){const t=Math.round(a/1e3),e=Math.floor(t/60),i=t%60;return`${e}:${String(i).padStart(2,"0")}`}const ou="rr0-ufo";function Jm(){customElements.get(ou)||customElements.define(ou,Ki)}/**
|
|
697
697
|
* @license
|
|
698
698
|
* Copyright 2010-2026 Three.js Authors
|
|
699
699
|
* SPDX-License-Identifier: MIT
|
|
700
|
-
*/const Ld="185",U2=0,j0=1,F2=2,ro=1,k2=2,Qr=3,Ys=0,Ue=1,en=2,jn=0,Xs=1,Ci=2,Q0=3,tf=4,wl=5,ca=100,z2=101,B2=102,H2=103,G2=104,V2=200,yo=201,W2=202,X2=203,cu=204,_o=205,q2=206,Y2=207,K2=208,$2=209,Z2=210,J2=211,j2=212,Q2=213,tv=214,lu=0,hu=1,uu=2,xr=3,du=4,fu=5,pu=6,mu=7,Nd=0,ev=1,iv=2,Qn=0,jm=1,Qm=2,tg=3,eg=4,ig=5,ng=6,sg=7,ef="attached",nv="detached",ag=300,Sa=301,yr=302,Hl=303,Gl=304,bl=306,So=1e3,yi=1001,gu=1002,we=1003,sv=1004,Go=1005,se=1006,Vl=1007,pa=1008,nn=1009,rg=1010,og=1011,wo=1012,Od=1013,vn=1014,Di=1015,ze=1016,Ud=1017,Fd=1018,bo=1020,cg=35902,lg=35899,hg=1021,ug=1022,_i=1023,Ms=1026,ma=1027,El=1028,kd=1029,wa=1030,zd=1031,Bd=1033,Bc=33776,Hc=33777,Gc=33778,Vc=33779,vu=35840,Mu=35841,xu=35842,yu=35843,_u=36196,Su=37492,wu=37496,bu=37488,Eu=37489,Qc=37490,Au=37491,Tu=37808,Ru=37809,Du=37810,Cu=37811,Iu=37812,Pu=37813,Lu=37814,Nu=37815,Ou=37816,Uu=37817,Fu=37818,ku=37819,zu=37820,Bu=37821,Hu=36492,Gu=36494,Vu=36495,Wu=36283,Xu=36284,tl=36285,qu=36286,dg=2200,av=2201,rv=2202,el=2300,Yu=2301,Wl=2302,nf=2303,ir=2400,nr=2401,il=2402,Hd=2500,ov=2501,DE=0,CE=1,IE=2,cv=3200,nl=0,lv=1,Bs="",Fi="srgb",sl="srgb-linear",al="linear",ve="srgb",Ca=7680,sf=519,hv=512,uv=513,dv=514,Gd=515,fv=516,pv=517,Vd=518,mv=519,Ku=35044,rl="300 es",Zn=2e3,Eo=2001;function gv(a){for(let t=a.length-1;t>=0;--t)if(a[t]>=65535)return!0;return!1}function vv(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function Ao(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function Mv(){const a=Ao("canvas");return a.style.display="block",a}const af={};function ol(...a){const t="THREE."+a.shift();console.log(t,...a)}function fg(a){const t=a[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=a[1];e&&e.isStackTrace?a[0]+=" "+e.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function Tt(...a){a=fg(a);const t="THREE."+a.shift();{const e=a[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...a)}}function Ht(...a){a=fg(a);const t="THREE."+a.shift();{const e=a[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...a)}}function hr(...a){const t=a.join(" ");t in af||(af[t]=!0,Tt(...a))}function xv(a,t,e){return new Promise(function(i,n){function s(){switch(a.clientWaitSync(t,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:n();break;case a.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const yv={[lu]:hu,[uu]:pu,[du]:mu,[xr]:fu,[hu]:lu,[pu]:uu,[mu]:du,[fu]:xr};class Zs{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,r=n.length;s<r;s++)n[s].call(this,t);t.target=null}}}const bi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let rf=1234567;const oo=Math.PI/180,_r=180/Math.PI;function Dn(){const a=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(bi[a&255]+bi[a>>8&255]+bi[a>>16&255]+bi[a>>24&255]+"-"+bi[t&255]+bi[t>>8&255]+"-"+bi[t>>16&15|64]+bi[t>>24&255]+"-"+bi[e&63|128]+bi[e>>8&255]+"-"+bi[e>>16&255]+bi[e>>24&255]+bi[i&255]+bi[i>>8&255]+bi[i>>16&255]+bi[i>>24&255]).toLowerCase()}function jt(a,t,e){return Math.max(t,Math.min(e,a))}function Wd(a,t){return(a%t+t)%t}function _v(a,t,e,i,n){return i+(a-t)*(n-i)/(e-t)}function Sv(a,t,e){return a!==t?(e-a)/(t-a):0}function co(a,t,e){return(1-e)*a+e*t}function wv(a,t,e,i){return co(a,t,1-Math.exp(-e*i))}function bv(a,t=1){return t-Math.abs(Wd(a,t*2)-t)}function Ev(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*(3-2*a))}function Av(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*a*(a*(a*6-15)+10))}function Tv(a,t){return a+Math.floor(Math.random()*(t-a+1))}function Rv(a,t){return a+Math.random()*(t-a)}function Dv(a){return a*(.5-Math.random())}function Cv(a){a!==void 0&&(rf=a);let t=rf+=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(a){return a*oo}function Pv(a){return a*_r}function Lv(a){return(a&a-1)===0&&a!==0}function Nv(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Ov(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Uv(a,t,e,i,n){const s=Math.cos,r=Math.sin,o=s(e/2),c=r(e/2),l=s((t+i)/2),h=r((t+i)/2),u=s((t-i)/2),d=r((t-i)/2),f=s((i-t)/2),p=r((i-t)/2);switch(n){case"XYX":a.set(o*h,c*u,c*d,o*l);break;case"YZY":a.set(c*d,o*h,c*u,o*l);break;case"ZXZ":a.set(c*u,c*d,o*h,o*l);break;case"XZX":a.set(o*h,c*p,c*f,o*l);break;case"YXY":a.set(c*f,o*h,c*p,o*l);break;case"ZYZ":a.set(c*p,c*f,o*h,o*l);break;default:Tt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Tn(a,t){switch(t.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Me(a,t){switch(t.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const PE={DEG2RAD:oo,RAD2DEG:_r,generateUUID:Dn,clamp:jt,euclideanModulo:Wd,mapLinear:_v,inverseLerp:Sv,lerp:co,damp:wv,pingpong:bv,smoothstep:Ev,smootherstep:Av,randInt:Tv,randFloat:Rv,randFloatSpread:Dv,seededRandom:Cv,degToRad:Iv,radToDeg:Pv,isPowerOfTwo:Lv,ceilPowerOfTwo:Nv,floorPowerOfTwo:Ov,setQuaternionFromProperEuler:Uv,normalize:Me,denormalize:Tn};class Mt{static{Mt.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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(jt(i,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 i=this.dot(t)/e;return Math.acos(jt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*i-r*n+t.x,this.y=s*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class sn{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,r,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[r+0],f=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const _=Math.acos(m),w=Math.sin(_);g=Math.sin(g*_)/w,o=Math.sin(o*_)/w,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const _=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=_,l*=_,h*=_,u*=_}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,s,r){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[r],d=s[r+1],f=s[r+2],p=s[r+3];return 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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,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 i=t._x,n=t._y,s=t._z,r=t._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(r){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Tt("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],r=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(r-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+r)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+r)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(r-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(jt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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 i=t._x,n=t._y,s=t._z,r=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+r*o+n*l-s*c,this._y=n*h+r*c+s*o-i*l,this._z=s*h+r*l+i*c-n*o,this._w=r*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,r=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,r=-r,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+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+r*e,this._onChangeCallback()}else this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+r*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*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 D{static{D.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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(of.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(of.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,r=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,c=t.w,l=2*(r*n-o*i),h=2*(o*e-s*n),u=2*(s*i-r*e);return this.x=e+c*l+r*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-r*l,this}project(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,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(jt(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,c=e.z;return this.x=n*c-s*o,this.y=s*r-i*c,this.z=i*o-n*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Xl.copy(this).projectOnVector(t),this.sub(Xl)}reflect(t){return this.sub(Xl.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 i=this.dot(t)/e;return Math.acos(jt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xl=new D,of=new sn;class Xt{static{Xt.prototype.isMatrix3=!0}constructor(t,e,i,n,s,r,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,r,o,c,l)}set(t,e,i,n,s,r,o,c,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],_=n[1],w=n[4],M=n[7],S=n[2],b=n[5],T=n[8];return s[0]=r*v+o*_+c*S,s[3]=r*m+o*w+c*b,s[6]=r*g+o*M+c*T,s[1]=l*v+h*_+u*S,s[4]=l*m+h*w+u*b,s[7]=l*g+h*M+u*T,s[2]=d*v+f*_+p*S,s[5]=d*m+f*w+p*b,s[8]=d*g+f*M+p*T,this}multiplyScalar(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],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*r*h-e*o*l-i*s*h+i*o*c+n*s*l-n*r*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*r-o*l,d=o*c-h*s,f=l*s-r*c,p=e*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(n*l-h*i)*v,t[2]=(o*i-n*r)*v,t[3]=d*v,t[4]=(h*e-n*c)*v,t[5]=(n*s-o*e)*v,t[6]=f*v,t[7]=(i*c-l*e)*v,t[8]=(r*e-i*s)*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,i,n,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*r+l*o)+r+t,-n*l,n*c,-n*(-l*r+c*o)+o+e,0,0,1),this}scale(t,e){return hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ql.makeScale(t,e)),this}rotate(t){return hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ql.makeRotation(-t)),this}translate(t,e){return hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ql.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ql=new Xt,cf=new Xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lf=new Xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fv(){const a={enabled:!0,workingColorSpace:sl,spaces:{},convert:function(n,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===ve&&(n.r=vs(n.r),n.g=vs(n.g),n.b=vs(n.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===ve&&(n.r=ur(n.r),n.g=ur(n.g),n.b=ur(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===Bs?al:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,r){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return a.define({[sl]:{primaries:t,whitePoint:i,transfer:al,toXYZ:cf,fromXYZ:lf,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fi},outputColorSpaceConfig:{drawingBufferColorSpace:Fi}},[Fi]:{primaries:t,whitePoint:i,transfer:ve,toXYZ:cf,fromXYZ:lf,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fi}}}),a}const ne=Fv();function vs(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function ur(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let Ia;class kv{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{Ia===void 0&&(Ia=Ao("canvas")),Ia.width=t.width,Ia.height=t.height;const n=Ia.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=Ia}return i.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=Ao("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let r=0;r<s.length;r++)s[r]=vs(s[r]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(vs(e[i]/255)*255):e[i]=vs(e[i]);return{data:e,width:t.width,height:t.height}}else return Tt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let zv=0;class Xd{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zv++}),this.uuid=Dn(),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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let r=0,o=n.length;r<o;r++)n[r].isDataTexture?s.push(Yl(n[r].image)):s.push(Yl(n[r]))}else s=Yl(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Yl(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?kv.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(Tt("Texture: Unable to serialize Texture."),{})}let Bv=0;const Kl=new D;class xi extends Zs{constructor(t=xi.DEFAULT_IMAGE,e=xi.DEFAULT_MAPPING,i=yi,n=yi,s=se,r=pa,o=_i,c=nn,l=xi.DEFAULT_ANISOTROPY,h=Bs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bv++}),this.uuid=Dn(),this.name="",this.source=new Xd(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Mt(0,0),this.repeat=new Mt(1,1),this.center=new Mt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xt,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(Kl).x}get height(){return this.source.getSize(Kl).y}get depth(){return this.source.getSize(Kl).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 i=t[e];if(i===void 0){Tt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Tt(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ag)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case So:t.x=t.x-Math.floor(t.x);break;case yi:t.x=t.x<0?0:1;break;case gu: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 So:t.y=t.y-Math.floor(t.y);break;case yi:t.y=t.y<0?0:1;break;case gu: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++}}xi.DEFAULT_IMAGE=null;xi.DEFAULT_MAPPING=ag;xi.DEFAULT_ANISOTROPY=1;class ie{static{ie.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}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,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,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,i,n,s;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],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const w=(l+1)/2,M=(f+1)/2,S=(g+1)/2,b=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return w>M&&w>S?w<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(w),n=b/i,s=T/i):M>S?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=b/n,s=x/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=x/s),this.set(i,n,s,e),this}let _=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(u-v)/_,this.z=(d-h)/_,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(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=jt(this.x,t.x,e.x),this.y=jt(this.y,t.y,e.y),this.z=jt(this.z,t.z,e.z),this.w=jt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=jt(this.x,t,e),this.y=jt(this.y,t,e),this.z=jt(this.z,t,e),this.w=jt(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(jt(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,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 Hv extends Zs{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:se,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ie(0,0,t,e),this.scissorTest=!1,this.viewport=new ie(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},s=new xi(n),r=i.count;for(let o=0;o<r;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:se,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,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,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new Xd(n)}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 je extends Hv{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class pg extends xi{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=we,this.minFilter=we,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class mg extends xi{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=we,this.minFilter=we,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Zt{static{Zt.prototype.isMatrix4=!0}constructor(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m)}set(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Zt().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Pa.setFromMatrixColumn(t,0).length(),s=1/Pa.setFromMatrixColumn(t,1).length(),r=1/Pa.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=r*h,f=r*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]=r*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]=r*l,e[1]=r*u,e[5]=r*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=r*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]=-r*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=r*h,e[9]=v-d*o,e[2]=-r*l,e[6]=o,e[10]=r*c}else if(t.order==="ZYX"){const d=r*h,f=r*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]=r*c}else if(t.order==="YZX"){const d=r*c,f=r*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]=r*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=r*c,f=r*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]=r*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(Gv,t,Vv)}lookAt(t,e,i){const n=this.elements;return qi.subVectors(t,e),qi.lengthSq()===0&&(qi.z=1),qi.normalize(),Ts.crossVectors(i,qi),Ts.lengthSq()===0&&(Math.abs(i.z)===1?qi.x+=1e-4:qi.z+=1e-4,qi.normalize(),Ts.crossVectors(i,qi)),Ts.normalize(),Vo.crossVectors(qi,Ts),n[0]=Ts.x,n[4]=Vo.x,n[8]=qi.x,n[1]=Ts.y,n[5]=Vo.y,n[9]=qi.y,n[2]=Ts.z,n[6]=Vo.z,n[10]=qi.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],_=i[3],w=i[7],M=i[11],S=i[15],b=n[0],T=n[4],x=n[8],A=n[12],I=n[1],C=n[5],P=n[9],X=n[13],z=n[2],N=n[6],V=n[10],k=n[14],K=n[3],tt=n[7],J=n[11],it=n[15];return s[0]=r*b+o*I+c*z+l*K,s[4]=r*T+o*C+c*N+l*tt,s[8]=r*x+o*P+c*V+l*J,s[12]=r*A+o*X+c*k+l*it,s[1]=h*b+u*I+d*z+f*K,s[5]=h*T+u*C+d*N+f*tt,s[9]=h*x+u*P+d*V+f*J,s[13]=h*A+u*X+d*k+f*it,s[2]=p*b+v*I+m*z+g*K,s[6]=p*T+v*C+m*N+g*tt,s[10]=p*x+v*P+m*V+g*J,s[14]=p*A+v*X+m*k+g*it,s[3]=_*b+w*I+M*z+S*K,s[7]=_*T+w*C+M*N+S*tt,s[11]=_*x+w*P+M*V+S*J,s[15]=_*A+w*X+M*k+S*it,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],i=t[4],n=t[8],s=t[12],r=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],m=t[11],g=t[15],_=c*f-l*d,w=o*f-l*u,M=o*d-c*u,S=r*f-l*h,b=r*d-c*h,T=r*u-o*h;return e*(v*_-m*w+g*M)-i*(p*_-m*S+g*b)+n*(p*w-v*S+g*T)-s*(p*M-v*b+m*T)}determinantAffine(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[1],r=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(r*h-o*l)-i*(s*h-o*c)+n*(s*l-r*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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=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],m=t[14],g=t[15],_=e*o-i*r,w=e*c-n*r,M=e*l-s*r,S=i*c-n*o,b=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,I=h*g-f*p,C=u*m-d*v,P=u*g-f*v,X=d*g-f*m,z=_*X-w*P+M*C+S*I-b*A+T*x;if(z===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const N=1/z;return t[0]=(o*X-c*P+l*C)*N,t[1]=(n*P-i*X-s*C)*N,t[2]=(v*T-m*b+g*S)*N,t[3]=(d*b-u*T-f*S)*N,t[4]=(c*I-r*X-l*A)*N,t[5]=(e*X-n*I+s*A)*N,t[6]=(m*M-p*T-g*w)*N,t[7]=(h*T-d*M+f*w)*N,t[8]=(r*P-o*I+l*x)*N,t[9]=(i*I-e*P-s*x)*N,t[10]=(p*b-v*M+g*_)*N,t[11]=(u*M-h*b-f*_)*N,t[12]=(o*A-r*C-c*x)*N,t[13]=(e*C-i*A+n*x)*N,t[14]=(v*w-p*S-m*_)*N,t[15]=(h*S-u*w+d*_)*N,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,c=t.z,l=s*r,h=s*o;return this.set(l*r+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*r,0,l*c-n*o,h*c+n*r,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,r){return this.set(1,i,s,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,r=e._y,o=e._z,c=e._w,l=s+s,h=r+r,u=o+o,d=s*l,f=s*h,p=s*u,v=r*h,m=r*u,g=o*u,_=c*l,w=c*h,M=c*u,S=i.x,b=i.y,T=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+M)*S,n[2]=(p-w)*S,n[3]=0,n[4]=(f-M)*b,n[5]=(1-(d+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(p+w)*T,n[9]=(m-_)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),e.identity(),this;let r=Pa.set(n[0],n[1],n[2]).length();const o=Pa.set(n[4],n[5],n[6]).length(),c=Pa.set(n[8],n[9],n[10]).length();s<0&&(r=-r),xn.copy(this);const l=1/r,h=1/o,u=1/c;return xn.elements[0]*=l,xn.elements[1]*=l,xn.elements[2]*=l,xn.elements[4]*=h,xn.elements[5]*=h,xn.elements[6]*=h,xn.elements[8]*=u,xn.elements[9]*=u,xn.elements[10]*=u,e.setFromRotationMatrix(xn),i.x=r,i.y=o,i.z=c,this}makePerspective(t,e,i,n,s,r,o=Zn,c=!1){const l=this.elements,h=2*s/(e-t),u=2*s/(i-n),d=(e+t)/(e-t),f=(i+n)/(i-n);let p,v;if(c)p=s/(r-s),v=r*s/(r-s);else if(o===Zn)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(o===Eo)p=-r/(r-s),v=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,r,o=Zn,c=!1){const l=this.elements,h=2/(e-t),u=2/(i-n),d=-(e+t)/(e-t),f=-(i+n)/(i-n);let p,v;if(c)p=1/(r-s),v=r/(r-s);else if(o===Zn)p=-2/(r-s),v=-(r+s)/(r-s);else if(o===Eo)p=-1/(r-s),v=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Pa=new D,xn=new Zt,Gv=new D(0,0,0),Vv=new D(1,1,1),Ts=new D,Vo=new D,qi=new D,hf=new Zt,uf=new sn;class xs{constructor(t=0,e=0,i=0,n=xs.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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,i=!0){const n=t.elements,s=n[0],r=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(jt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-jt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(jt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-jt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(jt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-jt(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Tt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return hf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(hf,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return uf.setFromEuler(this),this.setFromQuaternion(uf,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}}xs.DEFAULT_ORDER="XYZ";class qd{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 Wv=0;const df=new D,La=new sn,is=new Zt,Wo=new D,Cr=new D,Xv=new D,qv=new sn,ff=new D(1,0,0),pf=new D(0,1,0),mf=new D(0,0,1),gf={type:"added"},Yv={type:"removed"},Na={type:"childadded",child:null},$l={type:"childremoved",child:null};class Pe extends Zs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Wv++}),this.uuid=Dn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pe.DEFAULT_UP.clone();const t=new D,e=new xs,i=new sn,n=new D(1,1,1);function s(){i.setFromEuler(e,!1)}function r(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Zt},normalMatrix:{value:new Xt}}),this.matrix=new Zt,this.matrixWorld=new Zt,this.matrixAutoUpdate=Pe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qd,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 La.setFromAxisAngle(t,e),this.quaternion.multiply(La),this}rotateOnWorldAxis(t,e){return La.setFromAxisAngle(t,e),this.quaternion.premultiply(La),this}rotateX(t){return this.rotateOnAxis(ff,t)}rotateY(t){return this.rotateOnAxis(pf,t)}rotateZ(t){return this.rotateOnAxis(mf,t)}translateOnAxis(t,e){return df.copy(t).applyQuaternion(this.quaternion),this.position.add(df.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ff,t)}translateY(t){return this.translateOnAxis(pf,t)}translateZ(t){return this.translateOnAxis(mf,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(is.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Wo.copy(t):Wo.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Cr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?is.lookAt(Cr,Wo,this.up):is.lookAt(Wo,Cr,this.up),this.quaternion.setFromRotationMatrix(is),n&&(is.extractRotation(n.matrixWorld),La.setFromRotationMatrix(is),this.quaternion.premultiply(La.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Ht("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(gf),Na.child=t,this.dispatchEvent(Na),Na.child=null):Ht("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Yv),$l.child=t,this.dispatchEvent($l),$l.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),is.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),is.multiply(t.parent.matrixWorld)),t.applyMatrix4(is),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(gf),Na.child=t,this.dispatchEvent(Na),Na.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 i=0,n=this.children.length;i<n;i++){const r=this.children[i].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cr,t,Xv),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cr,qv,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 i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].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,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}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 i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e,i=!1){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),e===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0,i)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(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];s(t.shapes,u)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(t.materials,this.material[c]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(t.animations,c))}}if(e){const o=r(t.geometries),c=r(t.materials),l=r(t.textures),h=r(t.images),u=r(t.shapes),d=r(t.skeletons),f=r(t.animations),p=r(t.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function r(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(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 i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Pe.DEFAULT_UP=new D(0,1,0);Pe.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class De extends Pe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Kv={type:"move"};class Zl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new De,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 De,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new De,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(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 i of t.hand.values())this._getHandJoint(e,i)}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,i){let n=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){r=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness: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&&(s=e.getPose(t.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(n=e.getPose(t.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Kv)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const i=new De;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const gg={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},Rs={h:0,s:0,l:0},Xo={h:0,s:0,l:0};function Jl(a,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?a+(t-a)*6*e:e<1/2?t:e<2/3?a+(t-a)*6*(2/3-e):a}class st{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ne.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=ne.workingColorSpace){return this.r=t,this.g=e,this.b=i,ne.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=ne.workingColorSpace){if(t=Wd(t,1),e=jt(e,0,1),i=jt(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=Jl(r,s,t+1/3),this.g=Jl(r,s,t),this.b=Jl(r,s,t-1/3)}return ne.colorSpaceToWorking(this,n),this}setStyle(t,e=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&Tt("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Tt("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(s,16),e);Tt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fi){const i=gg[t.toLowerCase()];return i!==void 0?this.setHex(i,e):Tt("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=vs(t.r),this.g=vs(t.g),this.b=vs(t.b),this}copyLinearToSRGB(t){return this.r=ur(t.r),this.g=ur(t.g),this.b=ur(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fi){return ne.workingToColorSpace(Ei.copy(this),t),Math.round(jt(Ei.r*255,0,255))*65536+Math.round(jt(Ei.g*255,0,255))*256+Math.round(jt(Ei.b*255,0,255))}getHexString(t=Fi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ne.workingColorSpace){ne.workingToColorSpace(Ei.copy(this),e);const i=Ei.r,n=Ei.g,s=Ei.b,r=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+r)/2;if(o===r)c=0,l=0;else{const u=r-o;switch(l=h<=.5?u/(r+o):u/(2-r-o),r){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=ne.workingColorSpace){return ne.workingToColorSpace(Ei.copy(this),e),t.r=Ei.r,t.g=Ei.g,t.b=Ei.b,t}getStyle(t=Fi){ne.workingToColorSpace(Ei.copy(this),t);const e=Ei.r,i=Ei.g,n=Ei.b;return t!==Fi?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(Rs),this.setHSL(Rs.h+t,Rs.s+e,Rs.l+i)}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,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Rs),t.getHSL(Xo);const i=co(Rs.h,Xo.h,e),n=co(Rs.s,Xo.s,e),s=co(Rs.l,Xo.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,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 Ei=new st;st.NAMES=gg;class Yd{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new st(t),this.near=e,this.far=i}clone(){return new Yd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ys extends Pe{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 xs,this.environmentIntensity=1,this.environmentRotation=new xs,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 yn=new D,ns=new D,jl=new D,ss=new D,Oa=new D,Ua=new D,vf=new D,Ql=new D,th=new D,eh=new D,ih=new ie,nh=new ie,sh=new ie;class mn{constructor(t=new D,e=new D,i=new D){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),yn.subVectors(t,e),n.cross(yn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){yn.subVectors(n,e),ns.subVectors(i,e),jl.subVectors(t,e);const r=yn.dot(yn),o=yn.dot(ns),c=yn.dot(jl),l=ns.dot(ns),h=ns.dot(jl),u=r*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(r*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ss)===null?!1:ss.x>=0&&ss.y>=0&&ss.x+ss.y<=1}static getInterpolation(t,e,i,n,s,r,o,c){return this.getBarycoord(t,e,i,n,ss)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ss.x),c.addScaledVector(r,ss.y),c.addScaledVector(o,ss.z),c)}static getInterpolatedAttribute(t,e,i,n,s,r){return ih.setScalar(0),nh.setScalar(0),sh.setScalar(0),ih.fromBufferAttribute(t,e),nh.fromBufferAttribute(t,i),sh.fromBufferAttribute(t,n),r.setScalar(0),r.addScaledVector(ih,s.x),r.addScaledVector(nh,s.y),r.addScaledVector(sh,s.z),r}static isFrontFacing(t,e,i,n){return yn.subVectors(i,e),ns.subVectors(t,e),yn.cross(ns).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 yn.subVectors(this.c,this.b),ns.subVectors(this.a,this.b),yn.cross(ns).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return mn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return mn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return mn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return mn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return mn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let r,o;Oa.subVectors(n,i),Ua.subVectors(s,i),Ql.subVectors(t,i);const c=Oa.dot(Ql),l=Ua.dot(Ql);if(c<=0&&l<=0)return e.copy(i);th.subVectors(t,n);const h=Oa.dot(th),u=Ua.dot(th);if(h>=0&&u<=h)return e.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return r=c/(c-h),e.copy(i).addScaledVector(Oa,r);eh.subVectors(t,s);const f=Oa.dot(eh),p=Ua.dot(eh);if(p>=0&&f<=p)return e.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(Ua,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return vf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),e.copy(n).addScaledVector(vf,o);const g=1/(m+v+d);return r=v*g,o=d*g,e.copy(i).addScaledVector(Oa,r).addScaledVector(Ua,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Mn{constructor(t=new D(1/0,1/0,1/0),e=new D(-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,i=t.length;e<i;e+=3)this.expandByPoint(_n.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(_n.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=_n.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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 i=t.geometry;if(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,_n):_n.fromBufferAttribute(s,r),_n.applyMatrix4(t.matrixWorld),this.expandByPoint(_n);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),qo.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),qo.copy(i.boundingBox)),qo.applyMatrix4(t.matrixWorld),this.union(qo)}const n=t.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],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,_n),_n.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ir),Yo.subVectors(this.max,Ir),Fa.subVectors(t.a,Ir),ka.subVectors(t.b,Ir),za.subVectors(t.c,Ir),Ds.subVectors(ka,Fa),Cs.subVectors(za,ka),ta.subVectors(Fa,za);let e=[0,-Ds.z,Ds.y,0,-Cs.z,Cs.y,0,-ta.z,ta.y,Ds.z,0,-Ds.x,Cs.z,0,-Cs.x,ta.z,0,-ta.x,-Ds.y,Ds.x,0,-Cs.y,Cs.x,0,-ta.y,ta.x,0];return!ah(e,Fa,ka,za,Yo)||(e=[1,0,0,0,1,0,0,0,1],!ah(e,Fa,ka,za,Yo))?!1:(Ko.crossVectors(Ds,Cs),e=[Ko.x,Ko.y,Ko.z],ah(e,Fa,ka,za,Yo))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,_n).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(_n).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:(as[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),as[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),as[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),as[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),as[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),as[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),as[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),as[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(as),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 as=[new D,new D,new D,new D,new D,new D,new D,new D],_n=new D,qo=new Mn,Fa=new D,ka=new D,za=new D,Ds=new D,Cs=new D,ta=new D,Ir=new D,Yo=new D,Ko=new D,ea=new D;function ah(a,t,e,i,n){for(let s=0,r=a.length-3;s<=r;s+=3){ea.fromArray(a,s);const o=n.x*Math.abs(ea.x)+n.y*Math.abs(ea.y)+n.z*Math.abs(ea.z),c=t.dot(ea),l=e.dot(ea),h=i.dot(ea);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const fs=$v();function $v(){const a=new ArrayBuffer(4),t=new Float32Array(a),e=new Uint32Array(a),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:r,offsetTable:o}}function Zv(a){Math.abs(a)>65504&&Tt("DataUtils.toHalfFloat(): Value out of range."),a=jt(a,-65504,65504),fs.floatView[0]=a;const t=fs.uint32View[0],e=t>>23&511;return fs.baseTable[e]+((t&8388607)>>fs.shiftTable[e])}function Jv(a){const t=a>>10;return fs.uint32View[0]=fs.mantissaTable[fs.offsetTable[t]+(a&1023)]+fs.exponentTable[t],fs.floatView[0]}class Cn{static toHalfFloat(t){return Zv(t)}static fromHalfFloat(t){return Jv(t)}}const ei=new D,$o=new Mt;let jv=0;class te extends Zs{constructor(t,e,i=!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:jv++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Ku,this.updateRanges=[],this.gpuType=Di,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,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)$o.fromBufferAttribute(this,e),$o.applyMatrix3(t),this.setXY(e,$o.x,$o.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyMatrix3(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyMatrix4(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyNormalMatrix(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.transformDirection(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Tn(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Me(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Tn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Me(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Tn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Me(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array),s=Me(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,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!==Ku&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class vg extends te{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class Kd extends te{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class _e extends te{constructor(t,e,i){super(new Float32Array(t),e,i)}}const Qv=new Mn,Pr=new D,rh=new D;class _s{constructor(t=new D,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 i=this.center;e!==void 0?i.copy(e):Qv.setFromPoints(t).getCenter(i);let n=0;for(let s=0,r=t.length;s<r;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(t);return e.copy(t),i>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;Pr.subVectors(t,this.center);const e=Pr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Pr,n/i),this.radius+=n}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):(rh.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Pr.copy(t.center).add(rh)),this.expandByPoint(Pr.copy(t.center).sub(rh))),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 tM=0;const cn=new Zt,oh=new Pe,Ba=new D,Yi=new Mn,Lr=new Mn,di=new D;class ue extends Zs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tM++}),this.uuid=Dn(),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(gv(t)?Kd:vg)(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,i=0){this.groups.push({start:t,count:e,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new Xt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return cn.makeRotationFromQuaternion(t),this.applyMatrix4(cn),this}rotateX(t){return cn.makeRotationX(t),this.applyMatrix4(cn),this}rotateY(t){return cn.makeRotationY(t),this.applyMatrix4(cn),this}rotateZ(t){return cn.makeRotationZ(t),this.applyMatrix4(cn),this}translate(t,e,i){return cn.makeTranslation(t,e,i),this.applyMatrix4(cn),this}scale(t,e,i){return cn.makeScale(t,e,i),this.applyMatrix4(cn),this}lookAt(t){return oh.lookAt(t),oh.updateMatrix(),this.applyMatrix4(oh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ba).negate(),this.translate(Ba.x,Ba.y,Ba.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const r=t[n];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new _e(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&Tt("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 Mn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Yi.setFromBufferAttribute(s),this.morphTargetsRelative?(di.addVectors(this.boundingBox.min,Yi.min),this.boundingBox.expandByPoint(di),di.addVectors(this.boundingBox.max,Yi.max),this.boundingBox.expandByPoint(di)):(this.boundingBox.expandByPoint(Yi.min),this.boundingBox.expandByPoint(Yi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ht('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 _s);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const i=this.boundingSphere.center;if(Yi.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){const o=e[s];Lr.setFromBufferAttribute(o),this.morphTargetsRelative?(di.addVectors(Yi.min,Lr.min),Yi.expandByPoint(di),di.addVectors(Yi.max,Lr.max),Yi.expandByPoint(di)):(Yi.expandByPoint(Lr.min),Yi.expandByPoint(Lr.max))}Yi.getCenter(i);let n=0;for(let s=0,r=t.count;s<r;s++)di.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(di));if(e)for(let s=0,r=e.length;s<r;s++){const o=e[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)di.fromBufferAttribute(o,l),c&&(Ba.fromBufferAttribute(t,l),di.add(Ba)),n=Math.max(n,i.distanceToSquared(di))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ht('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){Ht("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==i.count)&&(r=new te(new Float32Array(4*i.count),4),this.setAttribute("tangent",r));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new D,c[x]=new D;const l=new D,h=new D,u=new D,d=new Mt,f=new Mt,p=new Mt,v=new D,m=new D;function g(x,A,I){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,I),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const C=1/(f.x*p.y-p.x*f.y);isFinite(C)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(C),o[x].add(v),o[A].add(v),o[I].add(v),c[x].add(m),c[A].add(m),c[I].add(m))}let _=this.groups;_.length===0&&(_=[{start:0,count:t.count}]);for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)g(t.getX(X+0),t.getX(X+1),t.getX(X+2))}const w=new D,M=new D,S=new D,b=new D;function T(x){S.fromBufferAttribute(n,x),b.copy(S);const A=o[x];w.copy(A),w.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(b,A);const C=M.dot(c[x])<0?-1:1;r.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,P=I.count;for(let X=C,z=C+P;X<z;X+=3)T(t.getX(X+0)),T(t.getX(X+1)),T(t.getX(X+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==e.count)i=new te(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new D,s=new D,r=new D,o=new D,c=new D,l=new D,h=new D,u=new D;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),m=t.getX(d+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),r.fromBufferAttribute(e,m),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)di.fromBufferAttribute(t,e),di.normalize(),t.setXYZ(e,di.x,di.y,di.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,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new te(d,h,u)}if(this.index===null)return Tt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ue,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=t(c,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,i);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,c=r.length;o<c;o++){const l=r[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 i=this.attributes;for(const c in i){const l=i[c];t.data.attributes[c]=l.toJSON(t.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));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 i=t.index;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let l=0,h=r.length;l<h;l++){const u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=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 eM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Ku,this.updateRanges=[],this.version=0,this.uuid=Dn()}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,i){t*=this.stride,i*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];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=Dn()),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]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}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=Dn()),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 Ii=new D;class cl{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}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,i=this.data.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.applyMatrix4(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.applyNormalMatrix(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.transformDirection(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Tn(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Me(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Tn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Tn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Tn(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array),s=Me(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){ol("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new te(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 cl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){ol("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}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 iM=0;class Ss extends Zs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:iM++}),this.uuid=Dn(),this.name="",this.type="Material",this.blending=Xs,this.side=Ys,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cu,this.blendDst=_o,this.blendEquation=ca,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new st(0,0,0),this.blendAlpha=0,this.depthFunc=xr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=sf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ca,this.stencilZFail=Ca,this.stencilZPass=Ca,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 i=t[e];if(i===void 0){Tt(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Tt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Xs&&(i.blending=this.blending),this.side!==Ys&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==cu&&(i.blendSrc=this.blendSrc),this.blendDst!==_o&&(i.blendDst=this.blendDst),this.blendEquation!==ca&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==xr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==sf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ca&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ca&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ca&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(e){const s=n(t.textures),r=n(t.images);s.length>0&&(i.textures=s),r.length>0&&(i.images=r)}return i}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 st().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 i=t.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Mt().fromArray(i)}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 Mt().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 i=null;if(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,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 Wc extends Ss{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new st(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 Ha;const Nr=new D,Ga=new D,Va=new D,Wa=new Mt,Or=new Mt,Mg=new Zt,Zo=new D,Ur=new D,Jo=new D,Mf=new Mt,ch=new Mt,xf=new Mt;class Fr extends Pe{constructor(t=new Wc){if(super(),this.isSprite=!0,this.type="Sprite",Ha===void 0){Ha=new ue;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new eM(e,5);Ha.setIndex([0,1,2,0,2,3]),Ha.setAttribute("position",new cl(i,3,0,!1)),Ha.setAttribute("uv",new cl(i,2,3,!1))}this.geometry=Ha,this.material=t,this.center=new Mt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Ht('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ga.setFromMatrixScale(this.matrixWorld),Mg.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Va.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ga.multiplyScalar(-Va.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;jo(Zo.set(-.5,-.5,0),Va,r,Ga,n,s),jo(Ur.set(.5,-.5,0),Va,r,Ga,n,s),jo(Jo.set(.5,.5,0),Va,r,Ga,n,s),Mf.set(0,0),ch.set(1,0),xf.set(1,1);let o=t.ray.intersectTriangle(Zo,Ur,Jo,!1,Nr);if(o===null&&(jo(Ur.set(-.5,.5,0),Va,r,Ga,n,s),ch.set(0,1),o=t.ray.intersectTriangle(Zo,Jo,Ur,!1,Nr),o===null))return;const c=t.ray.origin.distanceTo(Nr);c<t.near||c>t.far||e.push({distance:c,point:Nr.clone(),uv:mn.getInterpolation(Nr,Zo,Ur,Jo,Mf,ch,xf,new Mt),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 jo(a,t,e,i,n,s){Wa.subVectors(a,e).addScalar(.5).multiply(i),n!==void 0?(Or.x=s*Wa.x-n*Wa.y,Or.y=n*Wa.x+s*Wa.y):Or.copy(Wa),a.copy(t),a.x+=Or.x,a.y+=Or.y,a.applyMatrix4(Mg)}const rs=new D,lh=new D,Qo=new D,Is=new D,hh=new D,tc=new D,uh=new D;class Co{constructor(t=new D,e=new D(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,rs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=rs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(rs.copy(this.origin).addScaledVector(this.direction,e),rs.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){lh.copy(t).add(e).multiplyScalar(.5),Qo.copy(e).sub(t).normalize(),Is.copy(this.origin).sub(lh);const s=t.distanceTo(e)*.5,r=-this.direction.dot(Qo),o=Is.dot(this.direction),c=-Is.dot(Qo),l=Is.lengthSq(),h=Math.abs(1-r*r);let u,d,f,p;if(h>0)if(u=r*c-o,d=r*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+r*d+2*o)+d*(r*u+d+2*c)+l}else d=s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-r*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(r*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=r>0?-s:s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(lh).addScaledVector(Qo,d),f}intersectSphere(t,e){rs.subVectors(t.center,this.origin);const i=rs.dot(this.direction),n=rs.dot(rs)-i*i,s=t.radius*t.radius;if(n>s)return null;const r=Math.sqrt(s-n),o=i-r,c=i+r;return c<0?null:o<0?this.at(c,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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,r,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(t.min.x-d.x)*l,n=(t.max.x-d.x)*l):(i=(t.max.x-d.x)*l,n=(t.min.x-d.x)*l),h>=0?(s=(t.min.y-d.y)*h,r=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,r=(t.min.y-d.y)*h),i>r||s>n||((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),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),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,rs)!==null}intersectTriangle(t,e,i,n,s){hh.subVectors(e,t),tc.subVectors(i,t),uh.crossVectors(hh,tc);let r=this.direction.dot(uh),o;if(r>0){if(n)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Is.subVectors(this.origin,t);const c=o*this.direction.dot(tc.crossVectors(Is,tc));if(c<0)return null;const l=o*this.direction.dot(hh.cross(Is));if(l<0||c+l>r)return null;const h=-o*Is.dot(uh);return h<0?null:this.at(h/r,s)}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 gn extends Ss{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new st(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 xs,this.combine=Nd,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 yf=new Zt,ia=new Co,ec=new _s,_f=new D,ic=new D,nc=new D,sc=new D,dh=new D,ac=new D,Sf=new D,rc=new D;class Dt extends Pe{constructor(t=new ue,e=new gn){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,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){ac.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(dh.fromBufferAttribute(u,t),r?ac.addScaledVector(dh,h):ac.addScaledVector(dh.sub(e),h))}e.add(ac)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ec.copy(i.boundingSphere),ec.applyMatrix4(s),ia.copy(t.ray).recast(t.near),!(ec.containsPoint(ia.origin)===!1&&(ia.intersectSphere(ec,_f)===null||ia.origin.distanceToSquared(_f)>(t.far-t.near)**2))&&(yf.copy(s).invert(),ia.copy(t.ray).applyMatrix4(yf),!(i.boundingBox!==null&&ia.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,ia)))}_computeIntersections(t,e,i){let n;const s=this.geometry,r=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=oc(this,g,t,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);n=oc(this,r,t,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}else if(c!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=M,T=M+1,x=M+2;n=oc(this,g,t,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=m,w=m+1,M=m+2;n=oc(this,r,t,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}}}function nM(a,t,e,i,n,s,r,o){let c;if(t.side===Ue?c=i.intersectTriangle(r,s,n,!0,o):c=i.intersectTriangle(n,s,r,t.side===Ys,o),c===null)return null;rc.copy(o),rc.applyMatrix4(a.matrixWorld);const l=e.ray.origin.distanceTo(rc);return l<e.near||l>e.far?null:{distance:l,point:rc.clone(),object:a}}function oc(a,t,e,i,n,s,r,o,c,l){a.getVertexPosition(o,ic),a.getVertexPosition(c,nc),a.getVertexPosition(l,sc);const h=nM(a,t,e,i,ic,nc,sc,Sf);if(h){const u=new D;mn.getBarycoord(Sf,ic,nc,sc,u),n&&(h.uv=mn.getInterpolatedAttribute(n,o,c,l,u,new Mt)),s&&(h.uv1=mn.getInterpolatedAttribute(s,o,c,l,u,new Mt)),r&&(h.normal=mn.getInterpolatedAttribute(r,o,c,l,u,new D),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new D,materialIndex:0};mn.getNormal(ic,nc,sc,d.normal),h.face=d,h.barycoord=u}return h}const kr=new ie,wf=new ie,bf=new ie,sM=new ie,Ef=new Zt,cc=new D,fh=new _s,Af=new Zt,ph=new Co;class LE extends Dt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ef,this.bindMatrix=new Zt,this.bindMatrixInverse=new Zt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,cc),this.boundingBox.expandByPoint(cc)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new _s),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,cc),this.boundingSphere.expandByPoint(cc)}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 i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),fh.copy(this.boundingSphere),fh.applyMatrix4(n),t.ray.intersectsSphere(fh)!==!1&&(Af.copy(n).invert(),ph.copy(t.ray).applyMatrix4(Af),!(this.boundingBox!==null&&ph.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,ph)))}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 ie,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ef?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===nv?this.bindMatrixInverse.copy(this.bindMatrix).invert():Tt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;wf.fromBufferAttribute(n.attributes.skinIndex,t),bf.fromBufferAttribute(n.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 s=0;s<4;s++){const r=bf.getComponent(s);if(r!==0){const o=wf.getComponent(s);Ef.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),e.addScaledVector(sM.copy(kr).applyMatrix4(Ef),r)}}return e.isVector4&&(e.w=kr.w),e.applyMatrix4(this.bindMatrixInverse)}}class aM extends Pe{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Js extends xi{constructor(t=null,e=1,i=1,n,s,r,o,c,l=we,h=we,u,d){super(null,r,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Tf=new Zt,rM=new Zt;class xg{constructor(t=[],e=[]){this.uuid=Dn(),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){Tt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Zt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new Zt;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=t.length;s<r;s++){const o=t[s]?t[s].matrixWorld:rM;Tf.multiplyMatrices(o,e[s]),Tf.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new xg(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 i=new Js(e,t,t,_i,Di);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const s=t.bones[i];let r=e[s];r===void 0&&(Tt("Skeleton: No bone found with UUID:",s),r=new aM),this.bones.push(r),this.boneInverses.push(new Zt().fromArray(t.boneInverses[i]))}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,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const r=e[n];t.bones.push(r.uuid);const o=i[n];t.boneInverses.push(o.toArray())}return t}}class Rf extends te{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}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 Xa=new Zt,Df=new Zt,lc=[],Cf=new Mn,oM=new Zt,zr=new Dt,Br=new _s;class NE extends Dt{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Rf(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,oM)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Mn),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Xa),Cf.copy(t.boundingBox).applyMatrix4(Xa),this.boundingBox.union(Cf)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new _s),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Xa),Br.copy(t.boundingSphere).applyMatrix4(Xa),this.boundingSphere.union(Br)}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 i=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,r=t*s+1;for(let o=0;o<i.length;o++)i[o]=n[r+o]}raycast(t,e){const i=this.matrixWorld,n=this.count;if(zr.geometry=this.geometry,zr.material=this.material,zr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Br.copy(this.boundingSphere),Br.applyMatrix4(i),t.ray.intersectsSphere(Br)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Xa),Df.multiplyMatrices(i,Xa),zr.matrixWorld=Df,zr.raycast(t,lc);for(let r=0,o=lc.length;r<o;r++){const c=lc[r];c.instanceId=s,c.object=this,e.push(c)}lc.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new Rf(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 i=e.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Js(new Float32Array(n*this.count),n,this.count,El,Di));const s=this.morphTexture.source.data.data;let r=0;for(let l=0;l<i.length;l++)r+=i[l];const o=this.geometry.morphTargetsRelative?1:1-r,c=n*t;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const mh=new D,cM=new D,lM=new Xt;class ra{constructor(t=new D(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,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=mh.subVectors(i,e).cross(cM.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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,i=!0){const n=t.delta(mh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/s;return i===!0&&(r<0||r>1)?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||lM.getNormalMatrix(t),n=this.coplanarPoint(mh).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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 na=new _s,hM=new Mt(.5,.5),hc=new D;class $d{constructor(t=new ra,e=new ra,i=new ra,n=new ra,s=new ra,r=new ra){this.planes=[t,e,i,n,s,r]}set(t,e,i,n,s,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Zn,i=!1){const n=this.planes,s=t.elements,r=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],_=s[12],w=s[13],M=s[14],S=s[15];if(n[0].setComponents(l-r,f-h,g-p,S-_).normalize(),n[1].setComponents(l+r,f+h,g+p,S+_).normalize(),n[2].setComponents(l+o,f+u,g+v,S+w).normalize(),n[3].setComponents(l-o,f-u,g-v,S-w).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,S-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,S-M).normalize(),e===Zn)n[5].setComponents(l+c,f+d,g+m,S+M).normalize();else if(e===Eo)n[5].setComponents(c,d,m,M).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(),na.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),na.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(na)}intersectsSprite(t){na.center.set(0,0,0);const e=hM.distanceTo(t.center);return na.radius=.7071067811865476+e,na.applyMatrix4(t.matrixWorld),this.intersectsSphere(na)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(hc.x=n.normal.x>0?t.max.x:t.min.x,hc.y=n.normal.y>0?t.max.y:t.min.y,hc.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(hc)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class uM extends Ss{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new st(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 ll=new D,hl=new D,If=new Zt,Hr=new Co,uc=new _s,gh=new D,Pf=new D;class yg extends Pe{constructor(t=new ue,e=new uM){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,i=[0];for(let n=1,s=e.count;n<s;n++)ll.fromBufferAttribute(e,n-1),hl.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=ll.distanceTo(hl);t.setAttribute("lineDistance",new _e(i,1))}else Tt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),uc.copy(i.boundingSphere),uc.applyMatrix4(n),uc.radius+=s,t.ray.intersectsSphere(uc)===!1)return;If.copy(n).invert(),Hr.copy(t.ray).applyMatrix4(If);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,r.start),p=Math.min(h.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),_=h.getX(v+1),w=dc(this,t,Hr,c,g,_,v);w&&e.push(w)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=dc(this,t,Hr,c,v,m,p-1);g&&e.push(g)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=dc(this,t,Hr,c,v,v+1,v);g&&e.push(g)}if(this.isLineLoop){const v=dc(this,t,Hr,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function dc(a,t,e,i,n,s,r){const o=a.geometry.attributes.position;if(ll.fromBufferAttribute(o,n),hl.fromBufferAttribute(o,s),e.distanceSqToSegment(ll,hl,gh,Pf)>i)return;gh.applyMatrix4(a.matrixWorld);const l=t.ray.origin.distanceTo(gh);if(!(l<t.near||l>t.far))return{distance:l,point:Pf.clone().applyMatrix4(a.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:a}}const Lf=new D,Nf=new D;class OE extends yg{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,i=[];for(let n=0,s=e.count;n<s;n+=2)Lf.fromBufferAttribute(e,n),Nf.fromBufferAttribute(e,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Lf.distanceTo(Nf);t.setAttribute("lineDistance",new _e(i,1))}else Tt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class UE extends yg{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class _g extends Ss{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new st(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 Of=new Zt,$u=new Co,fc=new _s,pc=new D;class ds extends Pe{constructor(t=new ue,e=new _g){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 i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),fc.copy(i.boundingSphere),fc.applyMatrix4(n),fc.radius+=s,t.ray.intersectsSphere(fc)===!1)return;Of.copy(n).invert(),$u.copy(t.ray).applyMatrix4(Of);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,r.start),f=Math.min(l.count,r.start+r.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);pc.fromBufferAttribute(u,m),Uf(pc,m,c,n,t,e,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,v=f;p<v;p++)pc.fromBufferAttribute(u,p),Uf(pc,p,c,n,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Uf(a,t,e,i,n,s,r){const o=$u.distanceSqToPoint(a);if(o<e){const c=new D;$u.closestPointToPoint(a,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:r})}}class Sg extends xi{constructor(t=[],e=Sa,i,n,s,r,o,c,l,h){super(t,e,i,n,s,r,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ws extends xi{constructor(t,e,i,n,s,r,o,c,l){super(t,e,i,n,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends xi{constructor(t,e,i=vn,n,s,r,o=we,c=we,l,h=Ms,u=1){if(h!==Ms&&h!==ma)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,n,s,r,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Xd(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 dM extends Ks{constructor(t,e=vn,i=Sa,n,s,r=we,o=we,c,l=Ms){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,i,n,s,r,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class wg extends xi{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class an extends ue{constructor(t=1,e=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const o=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,r,s,0),p("z","y","x",1,-1,i,e,-t,r,s,1),p("x","z","y",1,1,t,i,e,n,r,2),p("x","z","y",1,-1,t,i,-e,n,r,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new _e(l,3)),this.setAttribute("normal",new _e(h,3)),this.setAttribute("uv",new _e(u,2));function p(v,m,g,_,w,M,S,b,T,x,A){const I=M/T,C=S/x,P=M/2,X=S/2,z=b/2,N=T+1,V=x+1;let k=0,K=0;const tt=new D;for(let J=0;J<V;J++){const it=J*C-X;for(let ot=0;ot<N;ot++){const Vt=ot*I-P;tt[v]=Vt*_,tt[m]=it*w,tt[g]=z,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[m]=0,tt[g]=b>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(ot/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let it=0;it<T;it++){const ot=d+it+N*J,Vt=d+it+N*(J+1),Qt=d+(it+1)+N*(J+1),qt=d+(it+1)+N*J;c.push(ot,Vt,qt),c.push(Vt,Qt,qt),K+=6}o.addGroup(f,K,A),f+=K,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new an(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Zd extends ue{constructor(t=1,e=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],r=[],o=[],c=[],l=new D,h=new Mt;r.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=i+u/e*n;l.x=t*Math.cos(f),l.y=t*Math.sin(f),r.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(r[d]/t+1)/2,h.y=(r[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new _e(r,3)),this.setAttribute("normal",new _e(o,3)),this.setAttribute("uv",new _e(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zd(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class es extends ue{constructor(t=1,e=1,i=1,n=32,s=1,r=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;_(),r===!1&&(t>0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new _e(u,3)),this.setAttribute("normal",new _e(d,3)),this.setAttribute("uv",new _e(f,2));function _(){const M=new D,S=new D;let b=0;const T=(e-t)/i;for(let x=0;x<=s;x++){const A=[],I=x/s,C=I*(e-t)+t;for(let P=0;P<=n;P++){const X=P/n,z=X*c+o,N=Math.sin(z),V=Math.cos(z);S.x=C*N,S.y=-I*i+m,S.z=C*V,u.push(S.x,S.y,S.z),M.set(N,T,V).normalize(),d.push(M.x,M.y,M.z),f.push(X,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const I=v[A][x],C=v[A+1][x],P=v[A+1][x+1],X=v[A][x+1];(t>0||A!==0)&&(h.push(I,C,X),b+=3),(e>0||A!==s-1)&&(h.push(C,P,X),b+=3)}l.addGroup(g,b,0),g+=b}function w(M){const S=p,b=new Mt,T=new D;let x=0;const A=M===!0?t:e,I=M===!0?1:-1;for(let P=1;P<=n;P++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const C=p;for(let P=0;P<=n;P++){const z=P/n*c+o,N=Math.cos(z),V=Math.sin(z);T.x=A*V,T.y=m*I,T.z=A*N,u.push(T.x,T.y,T.z),d.push(0,I,0),b.x=N*.5+.5,b.y=V*.5*I+.5,f.push(b.x,b.y),p++}for(let P=0;P<n;P++){const X=S+P,z=C+P;M===!0?h.push(z,z+1,X):h.push(z+1,z,X),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new es(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class br extends es{constructor(t=1,e=1,i=32,n=1,s=!1,r=0,o=Math.PI*2){super(0,t,e,i,n,s,r,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:o}}static fromJSON(t){return new br(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Al extends ue{constructor(t=[new Mt(0,-.5),new Mt(.5,0),new Mt(0,.5)],e=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=jt(n,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],h=1/e,u=new D,d=new Mt,f=new D,p=new D,v=new D;let m=0,g=0;for(let _=0;_<=t.length-1;_++)switch(_){case 0:m=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:m=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let _=0;_<=e;_++){const w=i+_*h*n,M=Math.sin(w),S=Math.cos(w);for(let b=0;b<=t.length-1;b++){u.x=t[b].x*M,u.y=t[b].y,u.z=t[b].x*S,r.push(u.x,u.y,u.z),d.x=_/e,d.y=b/(t.length-1),o.push(d.x,d.y);const T=c[3*b+0]*M,x=c[3*b+1],A=c[3*b+0]*S;l.push(T,x,A)}}for(let _=0;_<e;_++)for(let w=0;w<t.length-1;w++){const M=w+_*t.length,S=M,b=M+t.length,T=M+t.length+1,x=M+1;s.push(S,b,x),s.push(T,x,b)}this.setIndex(s),this.setAttribute("position",new _e(r,3)),this.setAttribute("uv",new _e(o,2)),this.setAttribute("normal",new _e(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Al(t.points,t.segments,t.phiStart,t.phiLength)}}class ki extends ue{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,r=e/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const _=g*d-r;for(let w=0;w<l;w++){const M=w*u-s;p.push(M,-_,0),v.push(0,0,1),m.push(w/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let _=0;_<o;_++){const w=_+l*g,M=_+l*(g+1),S=_+1+l*(g+1),b=_+1+l*g;f.push(w,M,b),f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(v,3)),this.setAttribute("uv",new _e(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ki(t.width,t.height,t.widthSegments,t.heightSegments)}}class Qe extends ue{constructor(t=1,e=32,i=16,n=0,s=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const c=Math.min(r+o,Math.PI);let l=0;const h=[],u=new D,d=new D,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const _=[],w=g/i,M=r+w*o,S=t*Math.cos(M),b=Math.sqrt(t*t-S*S);let T=0;g===0&&r===0?T=.5/e:g===i&&c===Math.PI&&(T=-.5/e);for(let x=0;x<=e;x++){const A=x/e,I=n+A*s;u.x=-b*Math.cos(I),u.y=S,u.z=b*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-w),_.push(l++)}h.push(_)}for(let g=0;g<i;g++)for(let _=0;_<e;_++){const w=h[g][_+1],M=h[g][_],S=h[g+1][_],b=h[g+1][_+1];(g!==0||r>0)&&f.push(w,M,b),(g!==i-1||c<Math.PI)&&f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(v,3)),this.setAttribute("uv",new _e(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Qe(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Jd extends ue{constructor(t=1,e=.4,i=12,n=48,s=Math.PI*2,r=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s,thetaStart:r,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new D,f=new D,p=new D;for(let v=0;v<=i;v++){const m=r+v/i*o;for(let g=0;g<=n;g++){const _=g/n*s;f.x=(t+e*Math.cos(m))*Math.cos(_),f.y=(t+e*Math.cos(m))*Math.sin(_),f.z=e*Math.sin(m),l.push(f.x,f.y,f.z),d.x=t*Math.cos(_),d.y=t*Math.sin(_),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,_=(n+1)*(v-1)+m-1,w=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,_,M),c.push(_,w,M)}this.setIndex(c),this.setAttribute("position",new _e(l,3)),this.setAttribute("normal",new _e(h,3)),this.setAttribute("uv",new _e(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jd(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}function Sr(a){const t={};for(const e in a){t[e]={};for(const i in a[e]){const n=a[e][i];if(Ff(n))n.isRenderTargetTexture?(Tt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone();else if(Array.isArray(n))if(Ff(n[0])){const s=[];for(let r=0,o=n.length;r<o;r++)s[r]=n[r].clone();t[e][i]=s}else t[e][i]=n.slice();else t[e][i]=n}}return t}function Pi(a){const t={};for(let e=0;e<a.length;e++){const i=Sr(a[e]);for(const n in i)t[n]=i[n]}return t}function Ff(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function fM(a){const t=[];for(let e=0;e<a.length;e++)t.push(a[e].clone());return t}function bg(a){const t=a.getRenderTarget();return t===null?a.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ne.workingColorSpace}const pM={clone:Sr,merge:Pi};var mM=`void main() {
|
|
700
|
+
*/const Ld="185",U2=0,j0=1,F2=2,ro=1,k2=2,Qr=3,Ys=0,Ue=1,en=2,jn=0,Xs=1,Ci=2,Q0=3,tf=4,wl=5,ca=100,z2=101,B2=102,H2=103,G2=104,V2=200,yo=201,W2=202,X2=203,cu=204,_o=205,q2=206,Y2=207,K2=208,$2=209,Z2=210,J2=211,j2=212,Q2=213,tv=214,lu=0,hu=1,uu=2,xr=3,du=4,fu=5,pu=6,mu=7,Nd=0,ev=1,iv=2,Qn=0,jm=1,Qm=2,tg=3,eg=4,ig=5,ng=6,sg=7,ef="attached",nv="detached",ag=300,Sa=301,yr=302,Hl=303,Gl=304,bl=306,So=1e3,yi=1001,gu=1002,we=1003,sv=1004,Go=1005,se=1006,Vl=1007,pa=1008,nn=1009,rg=1010,og=1011,wo=1012,Od=1013,vn=1014,Di=1015,ze=1016,Ud=1017,Fd=1018,bo=1020,cg=35902,lg=35899,hg=1021,ug=1022,_i=1023,Ms=1026,ma=1027,El=1028,kd=1029,wa=1030,zd=1031,Bd=1033,Bc=33776,Hc=33777,Gc=33778,Vc=33779,vu=35840,Mu=35841,xu=35842,yu=35843,_u=36196,Su=37492,wu=37496,bu=37488,Eu=37489,Qc=37490,Au=37491,Tu=37808,Ru=37809,Du=37810,Cu=37811,Iu=37812,Pu=37813,Lu=37814,Nu=37815,Ou=37816,Uu=37817,Fu=37818,ku=37819,zu=37820,Bu=37821,Hu=36492,Gu=36494,Vu=36495,Wu=36283,Xu=36284,tl=36285,qu=36286,dg=2200,av=2201,rv=2202,el=2300,Yu=2301,Wl=2302,nf=2303,ir=2400,nr=2401,il=2402,Hd=2500,ov=2501,DE=0,CE=1,IE=2,cv=3200,nl=0,lv=1,Bs="",Fi="srgb",sl="srgb-linear",al="linear",ve="srgb",Ca=7680,sf=519,hv=512,uv=513,dv=514,Gd=515,fv=516,pv=517,Vd=518,mv=519,Ku=35044,rl="300 es",Zn=2e3,Eo=2001;function gv(a){for(let t=a.length-1;t>=0;--t)if(a[t]>=65535)return!0;return!1}function vv(a){return ArrayBuffer.isView(a)&&!(a instanceof DataView)}function Ao(a){return document.createElementNS("http://www.w3.org/1999/xhtml",a)}function Mv(){const a=Ao("canvas");return a.style.display="block",a}const af={};function ol(...a){const t="THREE."+a.shift();console.log(t,...a)}function fg(a){const t=a[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=a[1];e&&e.isStackTrace?a[0]+=" "+e.getLocation():a[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return a}function Tt(...a){a=fg(a);const t="THREE."+a.shift();{const e=a[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...a)}}function Ht(...a){a=fg(a);const t="THREE."+a.shift();{const e=a[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...a)}}function hr(...a){const t=a.join(" ");t in af||(af[t]=!0,Tt(...a))}function xv(a,t,e){return new Promise(function(i,n){function s(){switch(a.clientWaitSync(t,a.SYNC_FLUSH_COMMANDS_BIT,0)){case a.WAIT_FAILED:n();break;case a.TIMEOUT_EXPIRED:setTimeout(s,e);break;default:i()}}setTimeout(s,e)})}const yv={[lu]:hu,[uu]:pu,[du]:mu,[xr]:fu,[hu]:lu,[pu]:uu,[mu]:du,[fu]:xr};class Zs{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[t]===void 0&&(i[t]=[]),i[t].indexOf(e)===-1&&i[t].push(e)}hasEventListener(t,e){const i=this._listeners;return i===void 0?!1:i[t]!==void 0&&i[t].indexOf(e)!==-1}removeEventListener(t,e){const i=this._listeners;if(i===void 0)return;const n=i[t];if(n!==void 0){const s=n.indexOf(e);s!==-1&&n.splice(s,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const i=e[t.type];if(i!==void 0){t.target=this;const n=i.slice(0);for(let s=0,r=n.length;s<r;s++)n[s].call(this,t);t.target=null}}}const bi=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let rf=1234567;const oo=Math.PI/180,_r=180/Math.PI;function Dn(){const a=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,i=Math.random()*4294967295|0;return(bi[a&255]+bi[a>>8&255]+bi[a>>16&255]+bi[a>>24&255]+"-"+bi[t&255]+bi[t>>8&255]+"-"+bi[t>>16&15|64]+bi[t>>24&255]+"-"+bi[e&63|128]+bi[e>>8&255]+"-"+bi[e>>16&255]+bi[e>>24&255]+bi[i&255]+bi[i>>8&255]+bi[i>>16&255]+bi[i>>24&255]).toLowerCase()}function Qt(a,t,e){return Math.max(t,Math.min(e,a))}function Wd(a,t){return(a%t+t)%t}function _v(a,t,e,i,n){return i+(a-t)*(n-i)/(e-t)}function Sv(a,t,e){return a!==t?(e-a)/(t-a):0}function co(a,t,e){return(1-e)*a+e*t}function wv(a,t,e,i){return co(a,t,1-Math.exp(-e*i))}function bv(a,t=1){return t-Math.abs(Wd(a,t*2)-t)}function Ev(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*(3-2*a))}function Av(a,t,e){return a<=t?0:a>=e?1:(a=(a-t)/(e-t),a*a*a*(a*(a*6-15)+10))}function Tv(a,t){return a+Math.floor(Math.random()*(t-a+1))}function Rv(a,t){return a+Math.random()*(t-a)}function Dv(a){return a*(.5-Math.random())}function Cv(a){a!==void 0&&(rf=a);let t=rf+=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(a){return a*oo}function Pv(a){return a*_r}function Lv(a){return(a&a-1)===0&&a!==0}function Nv(a){return Math.pow(2,Math.ceil(Math.log(a)/Math.LN2))}function Ov(a){return Math.pow(2,Math.floor(Math.log(a)/Math.LN2))}function Uv(a,t,e,i,n){const s=Math.cos,r=Math.sin,o=s(e/2),c=r(e/2),l=s((t+i)/2),h=r((t+i)/2),u=s((t-i)/2),d=r((t-i)/2),f=s((i-t)/2),p=r((i-t)/2);switch(n){case"XYX":a.set(o*h,c*u,c*d,o*l);break;case"YZY":a.set(c*d,o*h,c*u,o*l);break;case"ZXZ":a.set(c*u,c*d,o*h,o*l);break;case"XZX":a.set(o*h,c*p,c*f,o*l);break;case"YXY":a.set(c*f,o*h,c*p,o*l);break;case"ZYZ":a.set(c*p,c*f,o*h,o*l);break;default:Tt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+n)}}function Tn(a,t){switch(t.constructor){case Float32Array:return a;case Uint32Array:return a/4294967295;case Uint16Array:return a/65535;case Uint8Array:return a/255;case Int32Array:return Math.max(a/2147483647,-1);case Int16Array:return Math.max(a/32767,-1);case Int8Array:return Math.max(a/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function Me(a,t){switch(t.constructor){case Float32Array:return a;case Uint32Array:return Math.round(a*4294967295);case Uint16Array:return Math.round(a*65535);case Uint8Array:return Math.round(a*255);case Int32Array:return Math.round(a*2147483647);case Int16Array:return Math.round(a*32767);case Int8Array:return Math.round(a*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const PE={DEG2RAD:oo,RAD2DEG:_r,generateUUID:Dn,clamp:Qt,euclideanModulo:Wd,mapLinear:_v,inverseLerp:Sv,lerp:co,damp:wv,pingpong:bv,smoothstep:Ev,smootherstep:Av,randInt:Tv,randFloat:Rv,randFloatSpread:Dv,seededRandom:Cv,degToRad:Iv,radToDeg:Pv,isPowerOfTwo:Lv,ceilPowerOfTwo:Nv,floorPowerOfTwo:Ov,setQuaternionFromProperEuler:Uv,normalize:Me,denormalize:Tn};class Mt{static{Mt.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,i=this.y,n=t.elements;return this.x=n[0]*e+n[3]*i+n[6],this.y=n[1]*e+n[4]*i+n[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=Qt(this.x,t.x,e.x),this.y=Qt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Qt(this.x,t,e),this.y=Qt(this.y,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qt(i,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 i=this.dot(t)/e;return Math.acos(Qt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y;return e*e+i*i}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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,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 i=Math.cos(e),n=Math.sin(e),s=this.x-t.x,r=this.y-t.y;return this.x=s*i-r*n+t.x,this.y=s*n+r*i+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class sn{constructor(t=0,e=0,i=0,n=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=i,this._w=n}static slerpFlat(t,e,i,n,s,r,o){let c=i[n+0],l=i[n+1],h=i[n+2],u=i[n+3],d=s[r+0],f=s[r+1],p=s[r+2],v=s[r+3];if(u!==v||c!==d||l!==f||h!==p){let m=c*d+l*f+h*p+u*v;m<0&&(d=-d,f=-f,p=-p,v=-v,m=-m);let g=1-o;if(m<.9995){const _=Math.acos(m),w=Math.sin(_);g=Math.sin(g*_)/w,o=Math.sin(o*_)/w,c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o}else{c=c*g+d*o,l=l*g+f*o,h=h*g+p*o,u=u*g+v*o;const _=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=_,l*=_,h*=_,u*=_}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,i,n,s,r){const o=i[n],c=i[n+1],l=i[n+2],h=i[n+3],u=s[r],d=s[r+1],f=s[r+2],p=s[r+3];return 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,i,n){return this._x=t,this._y=e,this._z=i,this._w=n,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 i=t._x,n=t._y,s=t._z,r=t._order,o=Math.cos,c=Math.sin,l=o(i/2),h=o(n/2),u=o(s/2),d=c(i/2),f=c(n/2),p=c(s/2);switch(r){case"XYZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"YXZ":this._x=d*h*u+l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"ZXY":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u-d*f*p;break;case"ZYX":this._x=d*h*u-l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u+d*f*p;break;case"YZX":this._x=d*h*u+l*f*p,this._y=l*f*u+d*h*p,this._z=l*h*p-d*f*u,this._w=l*h*u-d*f*p;break;case"XZY":this._x=d*h*u-l*f*p,this._y=l*f*u-d*h*p,this._z=l*h*p+d*f*u,this._w=l*h*u+d*f*p;break;default:Tt("Quaternion: .setFromEuler() encountered an unknown order: "+r)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const i=e/2,n=Math.sin(i);return this._x=t.x*n,this._y=t.y*n,this._z=t.z*n,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,i=e[0],n=e[4],s=e[8],r=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=i+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(s-l)*f,this._z=(r-n)*f}else if(i>o&&i>u){const f=2*Math.sqrt(1+i-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(n+r)/f,this._z=(s+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-i-u);this._w=(s-l)/f,this._x=(n+r)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-i-o);this._w=(r-n)/f,this._x=(s+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let i=t.dot(e)+1;return i<1e-8?(i=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=i):(this._x=0,this._y=-t.z,this._z=t.y,this._w=i)):(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=i),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Qt(this.dot(t),-1,1)))}rotateTowards(t,e){const i=this.angleTo(t);if(i===0)return this;const n=Math.min(1,e/i);return this.slerp(t,n),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(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 i=t._x,n=t._y,s=t._z,r=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=i*h+r*o+n*l-s*c,this._y=n*h+r*c+s*o-i*l,this._z=s*h+r*l+i*c-n*o,this._w=r*h-i*o-n*c-s*l,this._onChangeCallback(),this}slerp(t,e){let i=t._x,n=t._y,s=t._z,r=t._w,o=this.dot(t);o<0&&(i=-i,n=-n,s=-s,r=-r,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+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+r*e,this._onChangeCallback()}else this._x=this._x*c+i*e,this._y=this._y*c+n*e,this._z=this._z*c+s*e,this._w=this._w*c+r*e,this.normalize();return this}slerpQuaternions(t,e,i){return this.copy(t).slerp(e,i)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),i=Math.random(),n=Math.sqrt(1-i),s=Math.sqrt(i);return this.set(n*Math.sin(t),n*Math.cos(t),s*Math.sin(e),s*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 D{static{D.prototype.isVector3=!0}constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.z=i}set(t,e,i){return i===void 0&&(i=this.z),this.x=t,this.y=e,this.z=i,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(of.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(of.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[3]*i+s[6]*n,this.y=s[1]*e+s[4]*i+s[7]*n,this.z=s[2]*e+s[5]*i+s[8]*n,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,i=this.y,n=this.z,s=t.elements,r=1/(s[3]*e+s[7]*i+s[11]*n+s[15]);return this.x=(s[0]*e+s[4]*i+s[8]*n+s[12])*r,this.y=(s[1]*e+s[5]*i+s[9]*n+s[13])*r,this.z=(s[2]*e+s[6]*i+s[10]*n+s[14])*r,this}applyQuaternion(t){const e=this.x,i=this.y,n=this.z,s=t.x,r=t.y,o=t.z,c=t.w,l=2*(r*n-o*i),h=2*(o*e-s*n),u=2*(s*i-r*e);return this.x=e+c*l+r*u-o*h,this.y=i+c*h+o*l-s*u,this.z=n+c*u+s*h-r*l,this}project(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,i=this.y,n=this.z,s=t.elements;return this.x=s[0]*e+s[4]*i+s[8]*n,this.y=s[1]*e+s[5]*i+s[9]*n,this.z=s[2]*e+s[6]*i+s[10]*n,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=Qt(this.x,t.x,e.x),this.y=Qt(this.y,t.y,e.y),this.z=Qt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Qt(this.x,t,e),this.y=Qt(this.y,t,e),this.z=Qt(this.z,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qt(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const i=t.x,n=t.y,s=t.z,r=e.x,o=e.y,c=e.z;return this.x=n*c-s*o,this.y=s*r-i*c,this.z=i*o-n*r,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const i=t.dot(this)/e;return this.copy(t).multiplyScalar(i)}projectOnPlane(t){return Xl.copy(this).projectOnVector(t),this.sub(Xl)}reflect(t){return this.sub(Xl.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 i=this.dot(t)/e;return Math.acos(Qt(i,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,i=this.y-t.y,n=this.z-t.z;return e*e+i*i+n*n}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,i){const n=Math.sin(e)*t;return this.x=n*Math.sin(i),this.y=Math.cos(e)*t,this.z=n*Math.cos(i),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,i){return this.x=t*Math.sin(e),this.y=i,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(),i=this.setFromMatrixColumn(t,1).length(),n=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=i,this.z=n,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,i=Math.sqrt(1-e*e);return this.x=i*Math.cos(t),this.y=e,this.z=i*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Xl=new D,of=new sn;class Xt{static{Xt.prototype.isMatrix3=!0}constructor(t,e,i,n,s,r,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,r,o,c,l)}set(t,e,i,n,s,r,o,c,l){const h=this.elements;return h[0]=t,h[1]=n,h[2]=o,h[3]=e,h[4]=s,h[5]=c,h[6]=i,h[7]=r,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],this}extractBasis(t,e,i){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),i.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 i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[3],c=i[6],l=i[1],h=i[4],u=i[7],d=i[2],f=i[5],p=i[8],v=n[0],m=n[3],g=n[6],_=n[1],w=n[4],M=n[7],S=n[2],b=n[5],T=n[8];return s[0]=r*v+o*_+c*S,s[3]=r*m+o*w+c*b,s[6]=r*g+o*M+c*T,s[1]=l*v+h*_+u*S,s[4]=l*m+h*w+u*b,s[7]=l*g+h*M+u*T,s[2]=d*v+f*_+p*S,s[5]=d*m+f*w+p*b,s[8]=d*g+f*M+p*T,this}multiplyScalar(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],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*r*h-e*o*l-i*s*h+i*o*c+n*s*l-n*r*c}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*r-o*l,d=o*c-h*s,f=l*s-r*c,p=e*u+i*d+n*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/p;return t[0]=u*v,t[1]=(n*l-h*i)*v,t[2]=(o*i-n*r)*v,t[3]=d*v,t[4]=(h*e-n*c)*v,t[5]=(n*s-o*e)*v,t[6]=f*v,t[7]=(i*c-l*e)*v,t[8]=(r*e-i*s)*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,i,n,s,r,o){const c=Math.cos(s),l=Math.sin(s);return this.set(i*c,i*l,-i*(c*r+l*o)+r+t,-n*l,n*c,-n*(-l*r+c*o)+o+e,0,0,1),this}scale(t,e){return hr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ql.makeScale(t,e)),this}rotate(t){return hr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ql.makeRotation(-t)),this}translate(t,e){return hr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ql.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),i=Math.sin(t);return this.set(e,-i,0,i,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,i=t.elements;for(let n=0;n<9;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<9;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const ql=new Xt,cf=new Xt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),lf=new Xt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Fv(){const a={enabled:!0,workingColorSpace:sl,spaces:{},convert:function(n,s,r){return this.enabled===!1||s===r||!s||!r||(this.spaces[s].transfer===ve&&(n.r=vs(n.r),n.g=vs(n.g),n.b=vs(n.b)),this.spaces[s].primaries!==this.spaces[r].primaries&&(n.applyMatrix3(this.spaces[s].toXYZ),n.applyMatrix3(this.spaces[r].fromXYZ)),this.spaces[r].transfer===ve&&(n.r=ur(n.r),n.g=ur(n.g),n.b=ur(n.b))),n},workingToColorSpace:function(n,s){return this.convert(n,this.workingColorSpace,s)},colorSpaceToWorking:function(n,s){return this.convert(n,s,this.workingColorSpace)},getPrimaries:function(n){return this.spaces[n].primaries},getTransfer:function(n){return n===Bs?al:this.spaces[n].transfer},getToneMappingMode:function(n){return this.spaces[n].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(n,s=this.workingColorSpace){return n.fromArray(this.spaces[s].luminanceCoefficients)},define:function(n){Object.assign(this.spaces,n)},_getMatrix:function(n,s,r){return n.copy(this.spaces[s].toXYZ).multiply(this.spaces[r].fromXYZ)},_getDrawingBufferColorSpace:function(n){return this.spaces[n].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(n=this.workingColorSpace){return this.spaces[n].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(n,s){return hr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),a.workingToColorSpace(n,s)},toWorkingColorSpace:function(n,s){return hr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),a.colorSpaceToWorking(n,s)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],i=[.3127,.329];return a.define({[sl]:{primaries:t,whitePoint:i,transfer:al,toXYZ:cf,fromXYZ:lf,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Fi},outputColorSpaceConfig:{drawingBufferColorSpace:Fi}},[Fi]:{primaries:t,whitePoint:i,transfer:ve,toXYZ:cf,fromXYZ:lf,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Fi}}}),a}const ne=Fv();function vs(a){return a<.04045?a*.0773993808:Math.pow(a*.9478672986+.0521327014,2.4)}function ur(a){return a<.0031308?a*12.92:1.055*Math.pow(a,.41666)-.055}let Ia;class kv{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let i;if(t instanceof HTMLCanvasElement)i=t;else{Ia===void 0&&(Ia=Ao("canvas")),Ia.width=t.width,Ia.height=t.height;const n=Ia.getContext("2d");t instanceof ImageData?n.putImageData(t,0,0):n.drawImage(t,0,0,t.width,t.height),i=Ia}return i.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=Ao("canvas");e.width=t.width,e.height=t.height;const i=e.getContext("2d");i.drawImage(t,0,0,t.width,t.height);const n=i.getImageData(0,0,t.width,t.height),s=n.data;for(let r=0;r<s.length;r++)s[r]=vs(s[r]/255)*255;return i.putImageData(n,0,0),e}else if(t.data){const e=t.data.slice(0);for(let i=0;i<e.length;i++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[i]=Math.floor(vs(e[i]/255)*255):e[i]=vs(e[i]);return{data:e,width:t.width,height:t.height}}else return Tt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let zv=0;class Xd{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:zv++}),this.uuid=Dn(),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 i={uuid:this.uuid,url:""},n=this.data;if(n!==null){let s;if(Array.isArray(n)){s=[];for(let r=0,o=n.length;r<o;r++)n[r].isDataTexture?s.push(Yl(n[r].image)):s.push(Yl(n[r]))}else s=Yl(n);i.url=s}return e||(t.images[this.uuid]=i),i}}function Yl(a){return typeof HTMLImageElement<"u"&&a instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&a instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&a instanceof ImageBitmap?kv.getDataURL(a):a.data?{data:Array.from(a.data),width:a.width,height:a.height,type:a.data.constructor.name}:(Tt("Texture: Unable to serialize Texture."),{})}let Bv=0;const Kl=new D;class xi extends Zs{constructor(t=xi.DEFAULT_IMAGE,e=xi.DEFAULT_MAPPING,i=yi,n=yi,s=se,r=pa,o=_i,c=nn,l=xi.DEFAULT_ANISOTROPY,h=Bs){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:Bv++}),this.uuid=Dn(),this.name="",this.source=new Xd(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=i,this.wrapT=n,this.magFilter=s,this.minFilter=r,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Mt(0,0),this.repeat=new Mt(1,1),this.center=new Mt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Xt,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(Kl).x}get height(){return this.source.getSize(Kl).y}get depth(){return this.source.getSize(Kl).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 i=t[e];if(i===void 0){Tt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Tt(`Texture.setValues(): property '${e}' does not exist.`);continue}n&&i&&n.isVector2&&i.isVector2||n&&i&&n.isVector3&&i.isVector3||n&&i&&n.isMatrix3&&i.isMatrix3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const i={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&&(i.userData=this.userData),e||(t.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==ag)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case So:t.x=t.x-Math.floor(t.x);break;case yi:t.x=t.x<0?0:1;break;case gu: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 So:t.y=t.y-Math.floor(t.y);break;case yi:t.y=t.y<0?0:1;break;case gu: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++}}xi.DEFAULT_IMAGE=null;xi.DEFAULT_MAPPING=ag;xi.DEFAULT_ANISOTROPY=1;class ie{static{ie.prototype.isVector4=!0}constructor(t=0,e=0,i=0,n=1){this.x=t,this.y=e,this.z=i,this.w=n}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,i,n){return this.x=t,this.y=e,this.z=i,this.w=n,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,i=this.y,n=this.z,s=this.w,r=t.elements;return this.x=r[0]*e+r[4]*i+r[8]*n+r[12]*s,this.y=r[1]*e+r[5]*i+r[9]*n+r[13]*s,this.z=r[2]*e+r[6]*i+r[10]*n+r[14]*s,this.w=r[3]*e+r[7]*i+r[11]*n+r[15]*s,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,i,n,s;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],m=c[6],g=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(p-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(p+m)<.1&&Math.abs(l+f+g-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const w=(l+1)/2,M=(f+1)/2,S=(g+1)/2,b=(h+d)/4,T=(u+v)/4,x=(p+m)/4;return w>M&&w>S?w<.01?(i=0,n=.707106781,s=.707106781):(i=Math.sqrt(w),n=b/i,s=T/i):M>S?M<.01?(i=.707106781,n=0,s=.707106781):(n=Math.sqrt(M),i=b/n,s=x/n):S<.01?(i=.707106781,n=.707106781,s=0):(s=Math.sqrt(S),i=T/s,n=x/s),this.set(i,n,s,e),this}let _=Math.sqrt((m-p)*(m-p)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(_)<.001&&(_=1),this.x=(m-p)/_,this.y=(u-v)/_,this.z=(d-h)/_,this.w=Math.acos((l+f+g-1)/2),this}setFromMatrixPosition(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=Qt(this.x,t.x,e.x),this.y=Qt(this.y,t.y,e.y),this.z=Qt(this.z,t.z,e.z),this.w=Qt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Qt(this.x,t,e),this.y=Qt(this.y,t,e),this.z=Qt(this.z,t,e),this.w=Qt(this.w,t,e),this}clampLength(t,e){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qt(i,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,i){return this.x=t.x+(e.x-t.x)*i,this.y=t.y+(e.y-t.y)*i,this.z=t.z+(e.z-t.z)*i,this.w=t.w+(e.w-t.w)*i,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 Hv extends Zs{constructor(t=1,e=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:se,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=i.depth,this.scissor=new ie(0,0,t,e),this.scissorTest=!1,this.viewport=new ie(0,0,t,e),this.textures=[];const n={width:t,height:e,depth:i.depth},s=new xi(n),r=i.count;for(let o=0;o<r;o++)this.textures[o]=s.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(i),this.depthBuffer=i.depthBuffer,this.stencilBuffer=i.stencilBuffer,this.resolveDepthBuffer=i.resolveDepthBuffer,this.resolveStencilBuffer=i.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=i.depthTexture,this.samples=i.samples,this.multiview=i.multiview,this.useArrayDepthTexture=i.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:se,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 i=0;i<this.textures.length;i++)this.textures[i].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,i=1){if(this.width!==t||this.height!==e||this.depth!==i){this.width=t,this.height=e,this.depth=i;for(let n=0,s=this.textures.length;n<s;n++)this.textures[n].image.width=t,this.textures[n].image.height=e,this.textures[n].image.depth=i,this.textures[n].isData3DTexture!==!0&&(this.textures[n].isArrayTexture=this.textures[n].image.depth>1);this.dispose()}this.viewport.set(0,0,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,i=t.textures.length;e<i;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const n=Object.assign({},t.textures[e].image);this.textures[e].source=new Xd(n)}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 je extends Hv{constructor(t=1,e=1,i={}){super(t,e,i),this.isWebGLRenderTarget=!0}}class pg extends xi{constructor(t=null,e=1,i=1,n=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=we,this.minFilter=we,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class mg extends xi{constructor(t=null,e=1,i=1,n=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:i,depth:n},this.magFilter=we,this.minFilter=we,this.wrapR=yi,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Zt{static{Zt.prototype.isMatrix4=!0}constructor(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m)}set(t,e,i,n,s,r,o,c,l,h,u,d,f,p,v,m){const g=this.elements;return g[0]=t,g[4]=e,g[8]=i,g[12]=n,g[1]=s,g[5]=r,g[9]=o,g[13]=c,g[2]=l,g[6]=h,g[10]=u,g[14]=d,g[3]=f,g[7]=p,g[11]=v,g[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new Zt().fromArray(this.elements)}copy(t){const e=this.elements,i=t.elements;return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],this}copyPosition(t){const e=this.elements,i=t.elements;return e[12]=i[12],e[13]=i[13],e[14]=i[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,i){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),i.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(t,e,i){return this.set(t.x,e.x,i.x,0,t.y,e.y,i.y,0,t.z,e.z,i.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,i=t.elements,n=1/Pa.setFromMatrixColumn(t,0).length(),s=1/Pa.setFromMatrixColumn(t,1).length(),r=1/Pa.setFromMatrixColumn(t,2).length();return e[0]=i[0]*n,e[1]=i[1]*n,e[2]=i[2]*n,e[3]=0,e[4]=i[4]*s,e[5]=i[5]*s,e[6]=i[6]*s,e[7]=0,e[8]=i[8]*r,e[9]=i[9]*r,e[10]=i[10]*r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,i=t.x,n=t.y,s=t.z,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s);if(t.order==="XYZ"){const d=r*h,f=r*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]=r*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]=r*l,e[1]=r*u,e[5]=r*h,e[9]=-o,e[2]=f*o-p,e[6]=v+d*o,e[10]=r*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]=-r*u,e[8]=p+f*o,e[1]=f+p*o,e[5]=r*h,e[9]=v-d*o,e[2]=-r*l,e[6]=o,e[10]=r*c}else if(t.order==="ZYX"){const d=r*h,f=r*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]=r*c}else if(t.order==="YZX"){const d=r*c,f=r*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]=r*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=r*c,f=r*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]=r*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(Gv,t,Vv)}lookAt(t,e,i){const n=this.elements;return qi.subVectors(t,e),qi.lengthSq()===0&&(qi.z=1),qi.normalize(),Ts.crossVectors(i,qi),Ts.lengthSq()===0&&(Math.abs(i.z)===1?qi.x+=1e-4:qi.z+=1e-4,qi.normalize(),Ts.crossVectors(i,qi)),Ts.normalize(),Vo.crossVectors(qi,Ts),n[0]=Ts.x,n[4]=Vo.x,n[8]=qi.x,n[1]=Ts.y,n[5]=Vo.y,n[9]=qi.y,n[2]=Ts.z,n[6]=Vo.z,n[10]=qi.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const i=t.elements,n=e.elements,s=this.elements,r=i[0],o=i[4],c=i[8],l=i[12],h=i[1],u=i[5],d=i[9],f=i[13],p=i[2],v=i[6],m=i[10],g=i[14],_=i[3],w=i[7],M=i[11],S=i[15],b=n[0],T=n[4],x=n[8],A=n[12],I=n[1],C=n[5],L=n[9],W=n[13],X=n[2],P=n[6],B=n[10],k=n[14],K=n[3],tt=n[7],J=n[11],it=n[15];return s[0]=r*b+o*I+c*X+l*K,s[4]=r*T+o*C+c*P+l*tt,s[8]=r*x+o*L+c*B+l*J,s[12]=r*A+o*W+c*k+l*it,s[1]=h*b+u*I+d*X+f*K,s[5]=h*T+u*C+d*P+f*tt,s[9]=h*x+u*L+d*B+f*J,s[13]=h*A+u*W+d*k+f*it,s[2]=p*b+v*I+m*X+g*K,s[6]=p*T+v*C+m*P+g*tt,s[10]=p*x+v*L+m*B+g*J,s[14]=p*A+v*W+m*k+g*it,s[3]=_*b+w*I+M*X+S*K,s[7]=_*T+w*C+M*P+S*tt,s[11]=_*x+w*L+M*B+S*J,s[15]=_*A+w*W+M*k+S*it,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],i=t[4],n=t[8],s=t[12],r=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],m=t[11],g=t[15],_=c*f-l*d,w=o*f-l*u,M=o*d-c*u,S=r*f-l*h,b=r*d-c*h,T=r*u-o*h;return e*(v*_-m*w+g*M)-i*(p*_-m*S+g*b)+n*(p*w-v*S+g*T)-s*(p*M-v*b+m*T)}determinantAffine(){const t=this.elements,e=t[0],i=t[4],n=t[8],s=t[1],r=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(r*h-o*l)-i*(s*h-o*c)+n*(s*l-r*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,i){const n=this.elements;return t.isVector3?(n[12]=t.x,n[13]=t.y,n[14]=t.z):(n[12]=t,n[13]=e,n[14]=i),this}invert(){const t=this.elements,e=t[0],i=t[1],n=t[2],s=t[3],r=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],m=t[14],g=t[15],_=e*o-i*r,w=e*c-n*r,M=e*l-s*r,S=i*c-n*o,b=i*l-s*o,T=n*l-s*c,x=h*v-u*p,A=h*m-d*p,I=h*g-f*p,C=u*m-d*v,L=u*g-f*v,W=d*g-f*m,X=_*W-w*L+M*C+S*I-b*A+T*x;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const P=1/X;return t[0]=(o*W-c*L+l*C)*P,t[1]=(n*L-i*W-s*C)*P,t[2]=(v*T-m*b+g*S)*P,t[3]=(d*b-u*T-f*S)*P,t[4]=(c*I-r*W-l*A)*P,t[5]=(e*W-n*I+s*A)*P,t[6]=(m*M-p*T-g*w)*P,t[7]=(h*T-d*M+f*w)*P,t[8]=(r*L-o*I+l*x)*P,t[9]=(i*I-e*L-s*x)*P,t[10]=(p*b-v*M+g*_)*P,t[11]=(u*M-h*b-f*_)*P,t[12]=(o*A-r*C-c*x)*P,t[13]=(e*C-i*A+n*x)*P,t[14]=(v*w-p*S-m*_)*P,t[15]=(h*S-u*w+d*_)*P,this}scale(t){const e=this.elements,i=t.x,n=t.y,s=t.z;return e[0]*=i,e[4]*=n,e[8]*=s,e[1]*=i,e[5]*=n,e[9]*=s,e[2]*=i,e[6]*=n,e[10]*=s,e[3]*=i,e[7]*=n,e[11]*=s,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],i=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],n=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,i,n))}makeTranslation(t,e,i){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,i,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),i=Math.sin(t);return this.set(1,0,0,0,0,e,-i,0,0,i,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,0,i,0,0,1,0,0,-i,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),i=Math.sin(t);return this.set(e,-i,0,0,i,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const i=Math.cos(e),n=Math.sin(e),s=1-i,r=t.x,o=t.y,c=t.z,l=s*r,h=s*o;return this.set(l*r+i,l*o-n*c,l*c+n*o,0,l*o+n*c,h*o+i,h*c-n*r,0,l*c-n*o,h*c+n*r,s*c*c+i,0,0,0,0,1),this}makeScale(t,e,i){return this.set(t,0,0,0,0,e,0,0,0,0,i,0,0,0,0,1),this}makeShear(t,e,i,n,s,r){return this.set(1,i,s,0,t,1,r,0,e,n,1,0,0,0,0,1),this}compose(t,e,i){const n=this.elements,s=e._x,r=e._y,o=e._z,c=e._w,l=s+s,h=r+r,u=o+o,d=s*l,f=s*h,p=s*u,v=r*h,m=r*u,g=o*u,_=c*l,w=c*h,M=c*u,S=i.x,b=i.y,T=i.z;return n[0]=(1-(v+g))*S,n[1]=(f+M)*S,n[2]=(p-w)*S,n[3]=0,n[4]=(f-M)*b,n[5]=(1-(d+g))*b,n[6]=(m+_)*b,n[7]=0,n[8]=(p+w)*T,n[9]=(m-_)*T,n[10]=(1-(d+v))*T,n[11]=0,n[12]=t.x,n[13]=t.y,n[14]=t.z,n[15]=1,this}decompose(t,e,i){const n=this.elements;t.x=n[12],t.y=n[13],t.z=n[14];const s=this.determinantAffine();if(s===0)return i.set(1,1,1),e.identity(),this;let r=Pa.set(n[0],n[1],n[2]).length();const o=Pa.set(n[4],n[5],n[6]).length(),c=Pa.set(n[8],n[9],n[10]).length();s<0&&(r=-r),xn.copy(this);const l=1/r,h=1/o,u=1/c;return xn.elements[0]*=l,xn.elements[1]*=l,xn.elements[2]*=l,xn.elements[4]*=h,xn.elements[5]*=h,xn.elements[6]*=h,xn.elements[8]*=u,xn.elements[9]*=u,xn.elements[10]*=u,e.setFromRotationMatrix(xn),i.x=r,i.y=o,i.z=c,this}makePerspective(t,e,i,n,s,r,o=Zn,c=!1){const l=this.elements,h=2*s/(e-t),u=2*s/(i-n),d=(e+t)/(e-t),f=(i+n)/(i-n);let p,v;if(c)p=s/(r-s),v=r*s/(r-s);else if(o===Zn)p=-(r+s)/(r-s),v=-2*r*s/(r-s);else if(o===Eo)p=-r/(r-s),v=-r*s/(r-s);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,i,n,s,r,o=Zn,c=!1){const l=this.elements,h=2/(e-t),u=2/(i-n),d=-(e+t)/(e-t),f=-(i+n)/(i-n);let p,v;if(c)p=1/(r-s),v=r/(r-s);else if(o===Zn)p=-2/(r-s),v=-(r+s)/(r-s);else if(o===Eo)p=-1/(r-s),v=-s/(r-s);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=p,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,i=t.elements;for(let n=0;n<16;n++)if(e[n]!==i[n])return!1;return!0}fromArray(t,e=0){for(let i=0;i<16;i++)this.elements[i]=t[i+e];return this}toArray(t=[],e=0){const i=this.elements;return t[e]=i[0],t[e+1]=i[1],t[e+2]=i[2],t[e+3]=i[3],t[e+4]=i[4],t[e+5]=i[5],t[e+6]=i[6],t[e+7]=i[7],t[e+8]=i[8],t[e+9]=i[9],t[e+10]=i[10],t[e+11]=i[11],t[e+12]=i[12],t[e+13]=i[13],t[e+14]=i[14],t[e+15]=i[15],t}}const Pa=new D,xn=new Zt,Gv=new D(0,0,0),Vv=new D(1,1,1),Ts=new D,Vo=new D,qi=new D,hf=new Zt,uf=new sn;class xs{constructor(t=0,e=0,i=0,n=xs.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=i,this._order=n}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,i,n=this._order){return this._x=t,this._y=e,this._z=i,this._order=n,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,i=!0){const n=t.elements,s=n[0],r=n[4],o=n[8],c=n[1],l=n[5],h=n[9],u=n[2],d=n[6],f=n[10];switch(e){case"XYZ":this._y=Math.asin(Qt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-r,s)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Qt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,s),this._z=0);break;case"ZXY":this._x=Math.asin(Qt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-r,l)):(this._y=0,this._z=Math.atan2(c,s));break;case"ZYX":this._y=Math.asin(-Qt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,s)):(this._x=0,this._z=Math.atan2(-r,l));break;case"YZX":this._z=Math.asin(Qt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,s)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Qt(r,-1,1)),Math.abs(r)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,s)):(this._x=Math.atan2(-h,f),this._y=0);break;default:Tt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,i===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,i){return hf.makeRotationFromQuaternion(t),this.setFromRotationMatrix(hf,e,i)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return uf.setFromEuler(this),this.setFromQuaternion(uf,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}}xs.DEFAULT_ORDER="XYZ";class qd{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 Wv=0;const df=new D,La=new sn,is=new Zt,Wo=new D,Cr=new D,Xv=new D,qv=new sn,ff=new D(1,0,0),pf=new D(0,1,0),mf=new D(0,0,1),gf={type:"added"},Yv={type:"removed"},Na={type:"childadded",child:null},$l={type:"childremoved",child:null};class Pe extends Zs{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Wv++}),this.uuid=Dn(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Pe.DEFAULT_UP.clone();const t=new D,e=new xs,i=new sn,n=new D(1,1,1);function s(){i.setFromEuler(e,!1)}function r(){e.setFromQuaternion(i,void 0,!1)}e._onChange(s),i._onChange(r),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:i},scale:{configurable:!0,enumerable:!0,value:n},modelViewMatrix:{value:new Zt},normalMatrix:{value:new Xt}}),this.matrix=new Zt,this.matrixWorld=new Zt,this.matrixAutoUpdate=Pe.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new qd,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 La.setFromAxisAngle(t,e),this.quaternion.multiply(La),this}rotateOnWorldAxis(t,e){return La.setFromAxisAngle(t,e),this.quaternion.premultiply(La),this}rotateX(t){return this.rotateOnAxis(ff,t)}rotateY(t){return this.rotateOnAxis(pf,t)}rotateZ(t){return this.rotateOnAxis(mf,t)}translateOnAxis(t,e){return df.copy(t).applyQuaternion(this.quaternion),this.position.add(df.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(ff,t)}translateY(t){return this.translateOnAxis(pf,t)}translateZ(t){return this.translateOnAxis(mf,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(is.copy(this.matrixWorld).invert())}lookAt(t,e,i){t.isVector3?Wo.copy(t):Wo.set(t,e,i);const n=this.parent;this.updateWorldMatrix(!0,!1),Cr.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?is.lookAt(Cr,Wo,this.up):is.lookAt(Wo,Cr,this.up),this.quaternion.setFromRotationMatrix(is),n&&(is.extractRotation(n.matrixWorld),La.setFromRotationMatrix(is),this.quaternion.premultiply(La.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Ht("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(gf),Na.child=t,this.dispatchEvent(Na),Na.child=null):Ht("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let i=0;i<arguments.length;i++)this.remove(arguments[i]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(Yv),$l.child=t,this.dispatchEvent($l),$l.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),is.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),is.multiply(t.parent.matrixWorld)),t.applyMatrix4(is),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(gf),Na.child=t,this.dispatchEvent(Na),Na.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 i=0,n=this.children.length;i<n;i++){const r=this.children[i].getObjectByProperty(t,e);if(r!==void 0)return r}}getObjectsByProperty(t,e,i=[]){this[t]===e&&i.push(this);const n=this.children;for(let s=0,r=n.length;s<r;s++)n[s].getObjectsByProperty(t,e,i);return i}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cr,t,Xv),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Cr,qv,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 i=0,n=e.length;i<n;i++)e[i].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let i=0,n=e.length;i<n;i++)e[i].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,i=t.y,n=t.z,s=this.matrix.elements;s[12]+=e-s[0]*e-s[4]*i-s[8]*n,s[13]+=i-s[1]*e-s[5]*i-s[9]*n,s[14]+=n-s[2]*e-s[6]*i-s[10]*n}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 i=0,n=e.length;i<n;i++)e[i].updateMatrixWorld(t)}updateWorldMatrix(t,e,i=!1){const n=this.parent;if(t===!0&&n!==null&&n.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||i)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,i=!0),e===!0){const s=this.children;for(let r=0,o=s.length;r<o;r++)s[r].updateWorldMatrix(!1,!0,i)}}toJSON(t){const e=t===void 0||typeof t=="string",i={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},i.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const n={};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.castShadow===!0&&(n.castShadow=!0),this.receiveShadow===!0&&(n.receiveShadow=!0),this.visible===!1&&(n.visible=!1),this.frustumCulled===!1&&(n.frustumCulled=!1),this.renderOrder!==0&&(n.renderOrder=this.renderOrder),this.static!==!1&&(n.static=this.static),Object.keys(this.userData).length>0&&(n.userData=this.userData),n.layers=this.layers.mask,n.matrix=this.matrix.toArray(),n.up=this.up.toArray(),this.pivot!==null&&(n.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(n.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(n.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(n.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(n.type="InstancedMesh",n.count=this.count,n.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(n.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(n.type="BatchedMesh",n.perObjectFrustumCulled=this.perObjectFrustumCulled,n.sortObjects=this.sortObjects,n.drawRanges=this._drawRanges,n.reservedRanges=this._reservedRanges,n.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),n.instanceInfo=this._instanceInfo.map(o=>({...o})),n.availableInstanceIds=this._availableInstanceIds.slice(),n.availableGeometryIds=this._availableGeometryIds.slice(),n.nextIndexStart=this._nextIndexStart,n.nextVertexStart=this._nextVertexStart,n.geometryCount=this._geometryCount,n.maxInstanceCount=this._maxInstanceCount,n.maxVertexCount=this._maxVertexCount,n.maxIndexCount=this._maxIndexCount,n.geometryInitialized=this._geometryInitialized,n.matricesTexture=this._matricesTexture.toJSON(t),n.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(n.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.toJSON()));function s(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?n.background=this.background.toJSON():this.background.isTexture&&(n.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(n.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){n.geometry=s(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];s(t.shapes,u)}else s(t.shapes,c)}}if(this.isSkinnedMesh&&(n.bindMode=this.bindMode,n.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(s(t.skeletons,this.skeleton),n.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(s(t.materials,this.material[c]));n.material=o}else n.material=s(t.materials,this.material);if(this.children.length>0){n.children=[];for(let o=0;o<this.children.length;o++)n.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){n.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];n.animations.push(s(t.animations,c))}}if(e){const o=r(t.geometries),c=r(t.materials),l=r(t.textures),h=r(t.images),u=r(t.shapes),d=r(t.skeletons),f=r(t.animations),p=r(t.nodes);o.length>0&&(i.geometries=o),c.length>0&&(i.materials=c),l.length>0&&(i.textures=l),h.length>0&&(i.images=h),u.length>0&&(i.shapes=u),d.length>0&&(i.skeletons=d),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=n,i;function r(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(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 i=0;i<t.children.length;i++){const n=t.children[i];this.add(n.clone())}return this}}Pe.DEFAULT_UP=new D(0,1,0);Pe.DEFAULT_MATRIX_AUTO_UPDATE=!0;Pe.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class De extends Pe{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Kv={type:"move"};class Zl{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new De,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 De,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new D,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new D),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new De,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new D,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new D,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(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 i of t.hand.values())this._getHandJoint(e,i)}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,i){let n=null,s=null,r=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){r=!0;for(const v of t.hand.values()){const m=e.getJointPose(v,i),g=this._getHandJoint(l,v);m!==null&&(g.matrix.fromArray(m.transform.matrix),g.matrix.decompose(g.position,g.rotation,g.scale),g.matrixWorldNeedsUpdate=!0,g.jointRadius=m.radius),g.visible=m!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,p=.005;l.inputState.pinching&&d>f+p?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness: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&&(s=e.getPose(t.gripSpace,i),s!==null&&(c.matrix.fromArray(s.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,s.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(s.linearVelocity)):c.hasLinearVelocity=!1,s.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(s.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(n=e.getPose(t.targetRaySpace,i),n===null&&s!==null&&(n=s),n!==null&&(o.matrix.fromArray(n.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,n.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(n.linearVelocity)):o.hasLinearVelocity=!1,n.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(n.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Kv)))}return o!==null&&(o.visible=n!==null),c!==null&&(c.visible=s!==null),l!==null&&(l.visible=r!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const i=new De;i.matrixAutoUpdate=!1,i.visible=!1,t.joints[e.jointName]=i,t.add(i)}return t.joints[e.jointName]}}const gg={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},Rs={h:0,s:0,l:0},Xo={h:0,s:0,l:0};function Jl(a,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?a+(t-a)*6*e:e<1/2?t:e<2/3?a+(t-a)*6*(2/3-e):a}class st{constructor(t,e,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,i)}set(t,e,i){if(e===void 0&&i===void 0){const n=t;n&&n.isColor?this.copy(n):typeof n=="number"?this.setHex(n):typeof n=="string"&&this.setStyle(n)}else this.setRGB(t,e,i);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Fi){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,ne.colorSpaceToWorking(this,e),this}setRGB(t,e,i,n=ne.workingColorSpace){return this.r=t,this.g=e,this.b=i,ne.colorSpaceToWorking(this,n),this}setHSL(t,e,i,n=ne.workingColorSpace){if(t=Wd(t,1),e=Qt(e,0,1),i=Qt(i,0,1),e===0)this.r=this.g=this.b=i;else{const s=i<=.5?i*(1+e):i+e-i*e,r=2*i-s;this.r=Jl(r,s,t+1/3),this.g=Jl(r,s,t),this.b=Jl(r,s,t-1/3)}return ne.colorSpaceToWorking(this,n),this}setStyle(t,e=Fi){function i(s){s!==void 0&&parseFloat(s)<1&&Tt("Color: Alpha component of "+t+" will be ignored.")}let n;if(n=/^(\w+)\(([^\)]*)\)/.exec(t)){let s;const r=n[1],o=n[2];switch(r){case"rgb":case"rgba":if(s=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(255,parseInt(s[1],10))/255,Math.min(255,parseInt(s[2],10))/255,Math.min(255,parseInt(s[3],10))/255,e);if(s=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setRGB(Math.min(100,parseInt(s[1],10))/100,Math.min(100,parseInt(s[2],10))/100,Math.min(100,parseInt(s[3],10))/100,e);break;case"hsl":case"hsla":if(s=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(s[4]),this.setHSL(parseFloat(s[1])/360,parseFloat(s[2])/100,parseFloat(s[3])/100,e);break;default:Tt("Color: Unknown color model "+t)}}else if(n=/^\#([A-Fa-f\d]+)$/.exec(t)){const s=n[1],r=s.length;if(r===3)return this.setRGB(parseInt(s.charAt(0),16)/15,parseInt(s.charAt(1),16)/15,parseInt(s.charAt(2),16)/15,e);if(r===6)return this.setHex(parseInt(s,16),e);Tt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Fi){const i=gg[t.toLowerCase()];return i!==void 0?this.setHex(i,e):Tt("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=vs(t.r),this.g=vs(t.g),this.b=vs(t.b),this}copyLinearToSRGB(t){return this.r=ur(t.r),this.g=ur(t.g),this.b=ur(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Fi){return ne.workingToColorSpace(Ei.copy(this),t),Math.round(Qt(Ei.r*255,0,255))*65536+Math.round(Qt(Ei.g*255,0,255))*256+Math.round(Qt(Ei.b*255,0,255))}getHexString(t=Fi){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=ne.workingColorSpace){ne.workingToColorSpace(Ei.copy(this),e);const i=Ei.r,n=Ei.g,s=Ei.b,r=Math.max(i,n,s),o=Math.min(i,n,s);let c,l;const h=(o+r)/2;if(o===r)c=0,l=0;else{const u=r-o;switch(l=h<=.5?u/(r+o):u/(2-r-o),r){case i:c=(n-s)/u+(n<s?6:0);break;case n:c=(s-i)/u+2;break;case s:c=(i-n)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=ne.workingColorSpace){return ne.workingToColorSpace(Ei.copy(this),e),t.r=Ei.r,t.g=Ei.g,t.b=Ei.b,t}getStyle(t=Fi){ne.workingToColorSpace(Ei.copy(this),t);const e=Ei.r,i=Ei.g,n=Ei.b;return t!==Fi?`color(${t} ${e.toFixed(3)} ${i.toFixed(3)} ${n.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(i*255)},${Math.round(n*255)})`}offsetHSL(t,e,i){return this.getHSL(Rs),this.setHSL(Rs.h+t,Rs.s+e,Rs.l+i)}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,i){return this.r=t.r+(e.r-t.r)*i,this.g=t.g+(e.g-t.g)*i,this.b=t.b+(e.b-t.b)*i,this}lerpHSL(t,e){this.getHSL(Rs),t.getHSL(Xo);const i=co(Rs.h,Xo.h,e),n=co(Rs.s,Xo.s,e),s=co(Rs.l,Xo.l,e);return this.setHSL(i,n,s),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,i=this.g,n=this.b,s=t.elements;return this.r=s[0]*e+s[3]*i+s[6]*n,this.g=s[1]*e+s[4]*i+s[7]*n,this.b=s[2]*e+s[5]*i+s[8]*n,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 Ei=new st;st.NAMES=gg;class Yd{constructor(t,e=1,i=1e3){this.isFog=!0,this.name="",this.color=new st(t),this.near=e,this.far=i}clone(){return new Yd(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class ys extends Pe{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 xs,this.environmentIntensity=1,this.environmentRotation=new xs,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 yn=new D,ns=new D,jl=new D,ss=new D,Oa=new D,Ua=new D,vf=new D,Ql=new D,th=new D,eh=new D,ih=new ie,nh=new ie,sh=new ie;class mn{constructor(t=new D,e=new D,i=new D){this.a=t,this.b=e,this.c=i}static getNormal(t,e,i,n){n.subVectors(i,e),yn.subVectors(t,e),n.cross(yn);const s=n.lengthSq();return s>0?n.multiplyScalar(1/Math.sqrt(s)):n.set(0,0,0)}static getBarycoord(t,e,i,n,s){yn.subVectors(n,e),ns.subVectors(i,e),jl.subVectors(t,e);const r=yn.dot(yn),o=yn.dot(ns),c=yn.dot(jl),l=ns.dot(ns),h=ns.dot(jl),u=r*l-o*o;if(u===0)return s.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,p=(r*h-o*c)*d;return s.set(1-f-p,p,f)}static containsPoint(t,e,i,n){return this.getBarycoord(t,e,i,n,ss)===null?!1:ss.x>=0&&ss.y>=0&&ss.x+ss.y<=1}static getInterpolation(t,e,i,n,s,r,o,c){return this.getBarycoord(t,e,i,n,ss)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(s,ss.x),c.addScaledVector(r,ss.y),c.addScaledVector(o,ss.z),c)}static getInterpolatedAttribute(t,e,i,n,s,r){return ih.setScalar(0),nh.setScalar(0),sh.setScalar(0),ih.fromBufferAttribute(t,e),nh.fromBufferAttribute(t,i),sh.fromBufferAttribute(t,n),r.setScalar(0),r.addScaledVector(ih,s.x),r.addScaledVector(nh,s.y),r.addScaledVector(sh,s.z),r}static isFrontFacing(t,e,i,n){return yn.subVectors(i,e),ns.subVectors(t,e),yn.cross(ns).dot(n)<0}set(t,e,i){return this.a.copy(t),this.b.copy(e),this.c.copy(i),this}setFromPointsAndIndices(t,e,i,n){return this.a.copy(t[e]),this.b.copy(t[i]),this.c.copy(t[n]),this}setFromAttributeAndIndices(t,e,i,n){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,i),this.c.fromBufferAttribute(t,n),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 yn.subVectors(this.c,this.b),ns.subVectors(this.a,this.b),yn.cross(ns).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return mn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return mn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,i,n,s){return mn.getInterpolation(t,this.a,this.b,this.c,e,i,n,s)}containsPoint(t){return mn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return mn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const i=this.a,n=this.b,s=this.c;let r,o;Oa.subVectors(n,i),Ua.subVectors(s,i),Ql.subVectors(t,i);const c=Oa.dot(Ql),l=Ua.dot(Ql);if(c<=0&&l<=0)return e.copy(i);th.subVectors(t,n);const h=Oa.dot(th),u=Ua.dot(th);if(h>=0&&u<=h)return e.copy(n);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return r=c/(c-h),e.copy(i).addScaledVector(Oa,r);eh.subVectors(t,s);const f=Oa.dot(eh),p=Ua.dot(eh);if(p>=0&&f<=p)return e.copy(s);const v=f*l-c*p;if(v<=0&&l>=0&&p<=0)return o=l/(l-p),e.copy(i).addScaledVector(Ua,o);const m=h*p-f*u;if(m<=0&&u-h>=0&&f-p>=0)return vf.subVectors(s,n),o=(u-h)/(u-h+(f-p)),e.copy(n).addScaledVector(vf,o);const g=1/(m+v+d);return r=v*g,o=d*g,e.copy(i).addScaledVector(Oa,r).addScaledVector(Ua,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class Mn{constructor(t=new D(1/0,1/0,1/0),e=new D(-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,i=t.length;e<i;e+=3)this.expandByPoint(_n.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,i=t.count;e<i;e++)this.expandByPoint(_n.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,i=t.length;e<i;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const i=_n.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(i),this.max.copy(t).add(i),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 i=t.geometry;if(i!==void 0){const s=i.getAttribute("position");if(e===!0&&s!==void 0&&t.isInstancedMesh!==!0)for(let r=0,o=s.count;r<o;r++)t.isMesh===!0?t.getVertexPosition(r,_n):_n.fromBufferAttribute(s,r),_n.applyMatrix4(t.matrixWorld),this.expandByPoint(_n);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),qo.copy(t.boundingBox)):(i.boundingBox===null&&i.computeBoundingBox(),qo.copy(i.boundingBox)),qo.applyMatrix4(t.matrixWorld),this.union(qo)}const n=t.children;for(let s=0,r=n.length;s<r;s++)this.expandByObject(n[s],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,_n),_n.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,i;return t.normal.x>0?(e=t.normal.x*this.min.x,i=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,i=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,i+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,i+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,i+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,i+=t.normal.z*this.min.z),e<=-t.constant&&i>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ir),Yo.subVectors(this.max,Ir),Fa.subVectors(t.a,Ir),ka.subVectors(t.b,Ir),za.subVectors(t.c,Ir),Ds.subVectors(ka,Fa),Cs.subVectors(za,ka),ta.subVectors(Fa,za);let e=[0,-Ds.z,Ds.y,0,-Cs.z,Cs.y,0,-ta.z,ta.y,Ds.z,0,-Ds.x,Cs.z,0,-Cs.x,ta.z,0,-ta.x,-Ds.y,Ds.x,0,-Cs.y,Cs.x,0,-ta.y,ta.x,0];return!ah(e,Fa,ka,za,Yo)||(e=[1,0,0,0,1,0,0,0,1],!ah(e,Fa,ka,za,Yo))?!1:(Ko.crossVectors(Ds,Cs),e=[Ko.x,Ko.y,Ko.z],ah(e,Fa,ka,za,Yo))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,_n).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(_n).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:(as[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),as[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),as[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),as[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),as[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),as[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),as[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),as[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(as),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 as=[new D,new D,new D,new D,new D,new D,new D,new D],_n=new D,qo=new Mn,Fa=new D,ka=new D,za=new D,Ds=new D,Cs=new D,ta=new D,Ir=new D,Yo=new D,Ko=new D,ea=new D;function ah(a,t,e,i,n){for(let s=0,r=a.length-3;s<=r;s+=3){ea.fromArray(a,s);const o=n.x*Math.abs(ea.x)+n.y*Math.abs(ea.y)+n.z*Math.abs(ea.z),c=t.dot(ea),l=e.dot(ea),h=i.dot(ea);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const fs=$v();function $v(){const a=new ArrayBuffer(4),t=new Float32Array(a),e=new Uint32Array(a),i=new Uint32Array(512),n=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(i[c]=0,i[c|256]=32768,n[c]=24,n[c|256]=24):l<-14?(i[c]=1024>>-l-14,i[c|256]=1024>>-l-14|32768,n[c]=-l-1,n[c|256]=-l-1):l<=15?(i[c]=l+15<<10,i[c|256]=l+15<<10|32768,n[c]=13,n[c|256]=13):l<128?(i[c]=31744,i[c|256]=64512,n[c]=24,n[c|256]=24):(i[c]=31744,i[c|256]=64512,n[c]=13,n[c|256]=13)}const s=new Uint32Array(2048),r=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,s[c]=l|h}for(let c=1024;c<2048;++c)s[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)r[c]=c<<23;r[31]=1199570944,r[32]=2147483648;for(let c=33;c<63;++c)r[c]=2147483648+(c-32<<23);r[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:i,shiftTable:n,mantissaTable:s,exponentTable:r,offsetTable:o}}function Zv(a){Math.abs(a)>65504&&Tt("DataUtils.toHalfFloat(): Value out of range."),a=Qt(a,-65504,65504),fs.floatView[0]=a;const t=fs.uint32View[0],e=t>>23&511;return fs.baseTable[e]+((t&8388607)>>fs.shiftTable[e])}function Jv(a){const t=a>>10;return fs.uint32View[0]=fs.mantissaTable[fs.offsetTable[t]+(a&1023)]+fs.exponentTable[t],fs.floatView[0]}class Cn{static toHalfFloat(t){return Zv(t)}static fromHalfFloat(t){return Jv(t)}}const ei=new D,$o=new Mt;let jv=0;class te extends Zs{constructor(t,e,i=!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:jv++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=i,this.usage=Ku,this.updateRanges=[],this.gpuType=Di,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,i){t*=this.itemSize,i*=e.itemSize;for(let n=0,s=this.itemSize;n<s;n++)this.array[t+n]=e.array[i+n];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,i=this.count;e<i;e++)$o.fromBufferAttribute(this,e),$o.applyMatrix3(t),this.setXY(e,$o.x,$o.y);else if(this.itemSize===3)for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyMatrix3(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}applyMatrix4(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyMatrix4(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.applyNormalMatrix(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)ei.fromBufferAttribute(this,e),ei.transformDirection(t),this.setXYZ(e,ei.x,ei.y,ei.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let i=this.array[t*this.itemSize+e];return this.normalized&&(i=Tn(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Me(i,this.array)),this.array[t*this.itemSize+e]=i,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Tn(e,this.array)),e}setX(t,e){return this.normalized&&(e=Me(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Tn(e,this.array)),e}setY(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}setW(t,e){return this.normalized&&(e=Me(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,i){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array)),this.array[t+0]=e,this.array[t+1]=i,this}setXYZ(t,e,i,n){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t*=this.itemSize,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array),s=Me(s,this.array)),this.array[t+0]=e,this.array[t+1]=i,this.array[t+2]=n,this.array[t+3]=s,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!==Ku&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class vg extends te{constructor(t,e,i){super(new Uint16Array(t),e,i)}}class Kd extends te{constructor(t,e,i){super(new Uint32Array(t),e,i)}}class _e extends te{constructor(t,e,i){super(new Float32Array(t),e,i)}}const Qv=new Mn,Pr=new D,rh=new D;class _s{constructor(t=new D,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 i=this.center;e!==void 0?i.copy(e):Qv.setFromPoints(t).getCenter(i);let n=0;for(let s=0,r=t.length;s<r;s++)n=Math.max(n,i.distanceToSquared(t[s]));return this.radius=Math.sqrt(n),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 i=this.center.distanceToSquared(t);return e.copy(t),i>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;Pr.subVectors(t,this.center);const e=Pr.lengthSq();if(e>this.radius*this.radius){const i=Math.sqrt(e),n=(i-this.radius)*.5;this.center.addScaledVector(Pr,n/i),this.radius+=n}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):(rh.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Pr.copy(t.center).add(rh)),this.expandByPoint(Pr.copy(t.center).sub(rh))),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 tM=0;const cn=new Zt,oh=new Pe,Ba=new D,Yi=new Mn,Lr=new Mn,di=new D;class ue extends Zs{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:tM++}),this.uuid=Dn(),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(gv(t)?Kd:vg)(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,i=0){this.groups.push({start:t,count:e,materialIndex:i})}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 i=this.attributes.normal;if(i!==void 0){const s=new Xt().getNormalMatrix(t);i.applyNormalMatrix(s),i.needsUpdate=!0}const n=this.attributes.tangent;return n!==void 0&&(n.transformDirection(t),n.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return cn.makeRotationFromQuaternion(t),this.applyMatrix4(cn),this}rotateX(t){return cn.makeRotationX(t),this.applyMatrix4(cn),this}rotateY(t){return cn.makeRotationY(t),this.applyMatrix4(cn),this}rotateZ(t){return cn.makeRotationZ(t),this.applyMatrix4(cn),this}translate(t,e,i){return cn.makeTranslation(t,e,i),this.applyMatrix4(cn),this}scale(t,e,i){return cn.makeScale(t,e,i),this.applyMatrix4(cn),this}lookAt(t){return oh.lookAt(t),oh.updateMatrix(),this.applyMatrix4(oh.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ba).negate(),this.translate(Ba.x,Ba.y,Ba.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const i=[];for(let n=0,s=t.length;n<s;n++){const r=t[n];i.push(r.x,r.y,r.z||0)}this.setAttribute("position",new _e(i,3))}else{const i=Math.min(t.length,e.count);for(let n=0;n<i;n++){const s=t[n];e.setXYZ(n,s.x,s.y,s.z||0)}t.length>e.count&&Tt("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 Mn);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new D(-1/0,-1/0,-1/0),new D(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let i=0,n=e.length;i<n;i++){const s=e[i];Yi.setFromBufferAttribute(s),this.morphTargetsRelative?(di.addVectors(this.boundingBox.min,Yi.min),this.boundingBox.expandByPoint(di),di.addVectors(this.boundingBox.max,Yi.max),this.boundingBox.expandByPoint(di)):(this.boundingBox.expandByPoint(Yi.min),this.boundingBox.expandByPoint(Yi.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Ht('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 _s);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Ht("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new D,1/0);return}if(t){const i=this.boundingSphere.center;if(Yi.setFromBufferAttribute(t),e)for(let s=0,r=e.length;s<r;s++){const o=e[s];Lr.setFromBufferAttribute(o),this.morphTargetsRelative?(di.addVectors(Yi.min,Lr.min),Yi.expandByPoint(di),di.addVectors(Yi.max,Lr.max),Yi.expandByPoint(di)):(Yi.expandByPoint(Lr.min),Yi.expandByPoint(Lr.max))}Yi.getCenter(i);let n=0;for(let s=0,r=t.count;s<r;s++)di.fromBufferAttribute(t,s),n=Math.max(n,i.distanceToSquared(di));if(e)for(let s=0,r=e.length;s<r;s++){const o=e[s],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)di.fromBufferAttribute(o,l),c&&(Ba.fromBufferAttribute(t,l),di.add(Ba)),n=Math.max(n,i.distanceToSquared(di))}this.boundingSphere.radius=Math.sqrt(n),isNaN(this.boundingSphere.radius)&&Ht('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){Ht("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const i=e.position,n=e.normal,s=e.uv;let r=this.getAttribute("tangent");(r===void 0||r.count!==i.count)&&(r=new te(new Float32Array(4*i.count),4),this.setAttribute("tangent",r));const o=[],c=[];for(let x=0;x<i.count;x++)o[x]=new D,c[x]=new D;const l=new D,h=new D,u=new D,d=new Mt,f=new Mt,p=new Mt,v=new D,m=new D;function g(x,A,I){l.fromBufferAttribute(i,x),h.fromBufferAttribute(i,A),u.fromBufferAttribute(i,I),d.fromBufferAttribute(s,x),f.fromBufferAttribute(s,A),p.fromBufferAttribute(s,I),h.sub(l),u.sub(l),f.sub(d),p.sub(d);const C=1/(f.x*p.y-p.x*f.y);isFinite(C)&&(v.copy(h).multiplyScalar(p.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-p.x).multiplyScalar(C),o[x].add(v),o[A].add(v),o[I].add(v),c[x].add(m),c[A].add(m),c[I].add(m))}let _=this.groups;_.length===0&&(_=[{start:0,count:t.count}]);for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,L=I.count;for(let W=C,X=C+L;W<X;W+=3)g(t.getX(W+0),t.getX(W+1),t.getX(W+2))}const w=new D,M=new D,S=new D,b=new D;function T(x){S.fromBufferAttribute(n,x),b.copy(S);const A=o[x];w.copy(A),w.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(b,A);const C=M.dot(c[x])<0?-1:1;r.setXYZW(x,w.x,w.y,w.z,C)}for(let x=0,A=_.length;x<A;++x){const I=_[x],C=I.start,L=I.count;for(let W=C,X=C+L;W<X;W+=3)T(t.getX(W+0)),T(t.getX(W+1)),T(t.getX(W+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let i=this.getAttribute("normal");if(i===void 0||i.count!==e.count)i=new te(new Float32Array(e.count*3),3),this.setAttribute("normal",i);else for(let d=0,f=i.count;d<f;d++)i.setXYZ(d,0,0,0);const n=new D,s=new D,r=new D,o=new D,c=new D,l=new D,h=new D,u=new D;if(t)for(let d=0,f=t.count;d<f;d+=3){const p=t.getX(d+0),v=t.getX(d+1),m=t.getX(d+2);n.fromBufferAttribute(e,p),s.fromBufferAttribute(e,v),r.fromBufferAttribute(e,m),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),o.fromBufferAttribute(i,p),c.fromBufferAttribute(i,v),l.fromBufferAttribute(i,m),o.add(h),c.add(h),l.add(h),i.setXYZ(p,o.x,o.y,o.z),i.setXYZ(v,c.x,c.y,c.z),i.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)n.fromBufferAttribute(e,d+0),s.fromBufferAttribute(e,d+1),r.fromBufferAttribute(e,d+2),h.subVectors(r,s),u.subVectors(n,s),h.cross(u),i.setXYZ(d+0,h.x,h.y,h.z),i.setXYZ(d+1,h.x,h.y,h.z),i.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),i.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,i=t.count;e<i;e++)di.fromBufferAttribute(t,e),di.normalize(),t.setXYZ(e,di.x,di.y,di.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,m=c.length;v<m;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let g=0;g<h;g++)d[p++]=l[f++]}return new te(d,h,u)}if(this.index===null)return Tt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new ue,i=this.index.array,n=this.attributes;for(const o in n){const c=n[o],l=t(c,i);e.setAttribute(o,l)}const s=this.morphAttributes;for(const o in s){const c=[],l=s[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,i);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const r=this.groups;for(let o=0,c=r.length;o<c;o++){const l=r[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 i=this.attributes;for(const c in i){const l=i[c];t.data.attributes[c]=l.toJSON(t.data)}const n={};let s=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(n[c]=h,s=!0)}s&&(t.data.morphAttributes=n,t.data.morphTargetsRelative=this.morphTargetsRelative);const r=this.groups;r.length>0&&(t.data.groups=JSON.parse(JSON.stringify(r)));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 i=t.index;i!==null&&this.setIndex(i.clone());const n=t.attributes;for(const l in n){const h=n[l];this.setAttribute(l,h.clone(e))}const s=t.morphAttributes;for(const l in s){const h=[],u=s[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const r=t.groups;for(let l=0,h=r.length;l<h;l++){const u=r[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=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 eM{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=Ku,this.updateRanges=[],this.version=0,this.uuid=Dn()}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,i){t*=this.stride,i*=e.stride;for(let n=0,s=this.stride;n<s;n++)this.array[t+n]=e.array[i+n];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=Dn()),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]),i=new this.constructor(e,this.stride);return i.setUsage(this.usage),i}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=Dn()),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 Ii=new D;class cl{constructor(t,e,i,n=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=i,this.normalized=n}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,i=this.data.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.applyMatrix4(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}applyNormalMatrix(t){for(let e=0,i=this.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.applyNormalMatrix(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}transformDirection(t){for(let e=0,i=this.count;e<i;e++)Ii.fromBufferAttribute(this,e),Ii.transformDirection(t),this.setXYZ(e,Ii.x,Ii.y,Ii.z);return this}getComponent(t,e){let i=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(i=Tn(i,this.array)),i}setComponent(t,e,i){return this.normalized&&(i=Me(i,this.array)),this.data.array[t*this.data.stride+this.offset+e]=i,this}setX(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=Me(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=Me(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=Tn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Tn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Tn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Tn(e,this.array)),e}setXY(t,e,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this}setXYZ(t,e,i,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this}setXYZW(t,e,i,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=Me(e,this.array),i=Me(i,this.array),n=Me(n,this.array),s=Me(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=i,this.data.array[t+2]=n,this.data.array[t+3]=s,this}clone(t){if(t===void 0){ol("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}return new te(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 cl(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){ol("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let i=0;i<this.count;i++){const n=i*this.data.stride+this.offset;for(let s=0;s<this.itemSize;s++)e.push(this.data.array[n+s])}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 iM=0;class Ss extends Zs{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:iM++}),this.uuid=Dn(),this.name="",this.type="Material",this.blending=Xs,this.side=Ys,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=cu,this.blendDst=_o,this.blendEquation=ca,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new st(0,0,0),this.blendAlpha=0,this.depthFunc=xr,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=sf,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Ca,this.stencilZFail=Ca,this.stencilZPass=Ca,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 i=t[e];if(i===void 0){Tt(`Material: parameter '${e}' has value of undefined.`);continue}const n=this[e];if(n===void 0){Tt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}n&&n.isColor?n.set(i):n&&n.isVector2&&i&&i.isVector2||n&&n.isEuler&&i&&i.isEuler||n&&n.isVector3&&i&&i.isVector3?n.copy(i):this[e]=i}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(t).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(t).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(t).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(t).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(t).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Xs&&(i.blending=this.blending),this.side!==Ys&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==cu&&(i.blendSrc=this.blendSrc),this.blendDst!==_o&&(i.blendDst=this.blendDst),this.blendEquation!==ca&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==xr&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==sf&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Ca&&(i.stencilFail=this.stencilFail),this.stencilZFail!==Ca&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==Ca&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function n(s){const r=[];for(const o in s){const c=s[o];delete c.metadata,r.push(c)}return r}if(e){const s=n(t.textures),r=n(t.images);s.length>0&&(i.textures=s),r.length>0&&(i.images=r)}return i}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 st().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 i=t.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Mt().fromArray(i)}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 Mt().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 i=null;if(e!==null){const n=e.length;i=new Array(n);for(let s=0;s!==n;++s)i[s]=e[s].clone()}return this.clippingPlanes=i,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 Wc extends Ss{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new st(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 Ha;const Nr=new D,Ga=new D,Va=new D,Wa=new Mt,Or=new Mt,Mg=new Zt,Zo=new D,Ur=new D,Jo=new D,Mf=new Mt,ch=new Mt,xf=new Mt;class Fr extends Pe{constructor(t=new Wc){if(super(),this.isSprite=!0,this.type="Sprite",Ha===void 0){Ha=new ue;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new eM(e,5);Ha.setIndex([0,1,2,0,2,3]),Ha.setAttribute("position",new cl(i,3,0,!1)),Ha.setAttribute("uv",new cl(i,2,3,!1))}this.geometry=Ha,this.material=t,this.center=new Mt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Ht('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Ga.setFromMatrixScale(this.matrixWorld),Mg.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Va.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Ga.multiplyScalar(-Va.z);const i=this.material.rotation;let n,s;i!==0&&(s=Math.cos(i),n=Math.sin(i));const r=this.center;jo(Zo.set(-.5,-.5,0),Va,r,Ga,n,s),jo(Ur.set(.5,-.5,0),Va,r,Ga,n,s),jo(Jo.set(.5,.5,0),Va,r,Ga,n,s),Mf.set(0,0),ch.set(1,0),xf.set(1,1);let o=t.ray.intersectTriangle(Zo,Ur,Jo,!1,Nr);if(o===null&&(jo(Ur.set(-.5,.5,0),Va,r,Ga,n,s),ch.set(0,1),o=t.ray.intersectTriangle(Zo,Jo,Ur,!1,Nr),o===null))return;const c=t.ray.origin.distanceTo(Nr);c<t.near||c>t.far||e.push({distance:c,point:Nr.clone(),uv:mn.getInterpolation(Nr,Zo,Ur,Jo,Mf,ch,xf,new Mt),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 jo(a,t,e,i,n,s){Wa.subVectors(a,e).addScalar(.5).multiply(i),n!==void 0?(Or.x=s*Wa.x-n*Wa.y,Or.y=n*Wa.x+s*Wa.y):Or.copy(Wa),a.copy(t),a.x+=Or.x,a.y+=Or.y,a.applyMatrix4(Mg)}const rs=new D,lh=new D,Qo=new D,Is=new D,hh=new D,tc=new D,uh=new D;class Co{constructor(t=new D,e=new D(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,rs)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const i=e.dot(this.direction);return i<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=rs.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(rs.copy(this.origin).addScaledVector(this.direction,e),rs.distanceToSquared(t))}distanceSqToSegment(t,e,i,n){lh.copy(t).add(e).multiplyScalar(.5),Qo.copy(e).sub(t).normalize(),Is.copy(this.origin).sub(lh);const s=t.distanceTo(e)*.5,r=-this.direction.dot(Qo),o=Is.dot(this.direction),c=-Is.dot(Qo),l=Is.lengthSq(),h=Math.abs(1-r*r);let u,d,f,p;if(h>0)if(u=r*c-o,d=r*o-c,p=s*h,u>=0)if(d>=-p)if(d<=p){const v=1/h;u*=v,d*=v,f=u*(u+r*d+2*o)+d*(r*u+d+2*c)+l}else d=s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d=-s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-p?(u=Math.max(0,-(-r*s+o)),d=u>0?-s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l):d<=p?(u=0,d=Math.min(Math.max(-s,-c),s),f=d*(d+2*c)+l):(u=Math.max(0,-(r*s+o)),d=u>0?s:Math.min(Math.max(-s,-c),s),f=-u*u+d*(d+2*c)+l);else d=r>0?-s:s,u=Math.max(0,-(r*d+o)),f=-u*u+d*(d+2*c)+l;return i&&i.copy(this.origin).addScaledVector(this.direction,u),n&&n.copy(lh).addScaledVector(Qo,d),f}intersectSphere(t,e){rs.subVectors(t.center,this.origin);const i=rs.dot(this.direction),n=rs.dot(rs)-i*i,s=t.radius*t.radius;if(n>s)return null;const r=Math.sqrt(s-n),o=i-r,c=i+r;return c<0?null:o<0?this.at(c,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 i=-(this.origin.dot(t.normal)+t.constant)/e;return i>=0?i:null}intersectPlane(t,e){const i=this.distanceToPlane(t);return i===null?null:this.at(i,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let i,n,s,r,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(i=(t.min.x-d.x)*l,n=(t.max.x-d.x)*l):(i=(t.max.x-d.x)*l,n=(t.min.x-d.x)*l),h>=0?(s=(t.min.y-d.y)*h,r=(t.max.y-d.y)*h):(s=(t.max.y-d.y)*h,r=(t.min.y-d.y)*h),i>r||s>n||((s>i||isNaN(i))&&(i=s),(r<n||isNaN(n))&&(n=r),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),i>c||o>n)||((o>i||i!==i)&&(i=o),(c<n||n!==n)&&(n=c),n<0)?null:this.at(i>=0?i:n,e)}intersectsBox(t){return this.intersectBox(t,rs)!==null}intersectTriangle(t,e,i,n,s){hh.subVectors(e,t),tc.subVectors(i,t),uh.crossVectors(hh,tc);let r=this.direction.dot(uh),o;if(r>0){if(n)return null;o=1}else if(r<0)o=-1,r=-r;else return null;Is.subVectors(this.origin,t);const c=o*this.direction.dot(tc.crossVectors(Is,tc));if(c<0)return null;const l=o*this.direction.dot(hh.cross(Is));if(l<0||c+l>r)return null;const h=-o*Is.dot(uh);return h<0?null:this.at(h/r,s)}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 gn extends Ss{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new st(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 xs,this.combine=Nd,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 yf=new Zt,ia=new Co,ec=new _s,_f=new D,ic=new D,nc=new D,sc=new D,dh=new D,ac=new D,Sf=new D,rc=new D;class Dt extends Pe{constructor(t=new ue,e=new gn){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,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}getVertexPosition(t,e){const i=this.geometry,n=i.attributes.position,s=i.morphAttributes.position,r=i.morphTargetsRelative;e.fromBufferAttribute(n,t);const o=this.morphTargetInfluences;if(s&&o){ac.set(0,0,0);for(let c=0,l=s.length;c<l;c++){const h=o[c],u=s[c];h!==0&&(dh.fromBufferAttribute(u,t),r?ac.addScaledVector(dh,h):ac.addScaledVector(dh.sub(e),h))}e.add(ac)}return e}raycast(t,e){const i=this.geometry,n=this.material,s=this.matrixWorld;n!==void 0&&(i.boundingSphere===null&&i.computeBoundingSphere(),ec.copy(i.boundingSphere),ec.applyMatrix4(s),ia.copy(t.ray).recast(t.near),!(ec.containsPoint(ia.origin)===!1&&(ia.intersectSphere(ec,_f)===null||ia.origin.distanceToSquared(_f)>(t.far-t.near)**2))&&(yf.copy(s).invert(),ia.copy(t.ray).applyMatrix4(yf),!(i.boundingBox!==null&&ia.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(t,e,ia)))}_computeIntersections(t,e,i){let n;const s=this.geometry,r=this.material,o=s.index,c=s.attributes.position,l=s.attributes.uv,h=s.attributes.uv1,u=s.attributes.normal,d=s.groups,f=s.drawRange;if(o!==null)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=o.getX(M),T=o.getX(M+1),x=o.getX(M+2);n=oc(this,g,t,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=o.getX(m),w=o.getX(m+1),M=o.getX(m+2);n=oc(this,r,t,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}else if(c!==void 0)if(Array.isArray(r))for(let p=0,v=d.length;p<v;p++){const m=d[p],g=r[m.materialIndex],_=Math.max(m.start,f.start),w=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=_,S=w;M<S;M+=3){const b=M,T=M+1,x=M+2;n=oc(this,g,t,i,l,h,u,b,T,x),n&&(n.faceIndex=Math.floor(M/3),n.face.materialIndex=m.materialIndex,e.push(n))}}else{const p=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let m=p,g=v;m<g;m+=3){const _=m,w=m+1,M=m+2;n=oc(this,r,t,i,l,h,u,_,w,M),n&&(n.faceIndex=Math.floor(m/3),e.push(n))}}}}function nM(a,t,e,i,n,s,r,o){let c;if(t.side===Ue?c=i.intersectTriangle(r,s,n,!0,o):c=i.intersectTriangle(n,s,r,t.side===Ys,o),c===null)return null;rc.copy(o),rc.applyMatrix4(a.matrixWorld);const l=e.ray.origin.distanceTo(rc);return l<e.near||l>e.far?null:{distance:l,point:rc.clone(),object:a}}function oc(a,t,e,i,n,s,r,o,c,l){a.getVertexPosition(o,ic),a.getVertexPosition(c,nc),a.getVertexPosition(l,sc);const h=nM(a,t,e,i,ic,nc,sc,Sf);if(h){const u=new D;mn.getBarycoord(Sf,ic,nc,sc,u),n&&(h.uv=mn.getInterpolatedAttribute(n,o,c,l,u,new Mt)),s&&(h.uv1=mn.getInterpolatedAttribute(s,o,c,l,u,new Mt)),r&&(h.normal=mn.getInterpolatedAttribute(r,o,c,l,u,new D),h.normal.dot(i.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new D,materialIndex:0};mn.getNormal(ic,nc,sc,d.normal),h.face=d,h.barycoord=u}return h}const kr=new ie,wf=new ie,bf=new ie,sM=new ie,Ef=new Zt,cc=new D,fh=new _s,Af=new Zt,ph=new Co;class LE extends Dt{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=ef,this.bindMatrix=new Zt,this.bindMatrixInverse=new Zt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new Mn),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,cc),this.boundingBox.expandByPoint(cc)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new _s),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let i=0;i<e.count;i++)this.getVertexPosition(i,cc),this.boundingSphere.expandByPoint(cc)}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 i=this.material,n=this.matrixWorld;i!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),fh.copy(this.boundingSphere),fh.applyMatrix4(n),t.ray.intersectsSphere(fh)!==!1&&(Af.copy(n).invert(),ph.copy(t.ray).applyMatrix4(Af),!(this.boundingBox!==null&&ph.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,ph)))}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 ie,e=this.geometry.attributes.skinWeight;for(let i=0,n=e.count;i<n;i++){t.fromBufferAttribute(e,i);const s=1/t.manhattanLength();s!==1/0?t.multiplyScalar(s):t.set(1,0,0,0),e.setXYZW(i,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===ef?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===nv?this.bindMatrixInverse.copy(this.bindMatrix).invert():Tt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const i=this.skeleton,n=this.geometry;wf.fromBufferAttribute(n.attributes.skinIndex,t),bf.fromBufferAttribute(n.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 s=0;s<4;s++){const r=bf.getComponent(s);if(r!==0){const o=wf.getComponent(s);Ef.multiplyMatrices(i.bones[o].matrixWorld,i.boneInverses[o]),e.addScaledVector(sM.copy(kr).applyMatrix4(Ef),r)}}return e.isVector4&&(e.w=kr.w),e.applyMatrix4(this.bindMatrixInverse)}}class aM extends Pe{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Js extends xi{constructor(t=null,e=1,i=1,n,s,r,o,c,l=we,h=we,u,d){super(null,r,o,c,l,h,n,s,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Tf=new Zt,rM=new Zt;class xg{constructor(t=[],e=[]){this.uuid=Dn(),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){Tt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let i=0,n=this.bones.length;i<n;i++)this.boneInverses.push(new Zt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const i=new Zt;this.bones[t]&&i.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(i)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&i.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const i=this.bones[t];i&&(i.parent&&i.parent.isBone?(i.matrix.copy(i.parent.matrixWorld).invert(),i.matrix.multiply(i.matrixWorld)):i.matrix.copy(i.matrixWorld),i.matrix.decompose(i.position,i.quaternion,i.scale))}}update(){const t=this.bones,e=this.boneInverses,i=this.boneMatrices,n=this.boneTexture;for(let s=0,r=t.length;s<r;s++){const o=t[s]?t[s].matrixWorld:rM;Tf.multiplyMatrices(o,e[s]),Tf.toArray(i,s*16)}n!==null&&(n.needsUpdate=!0)}clone(){return new xg(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 i=new Js(e,t,t,_i,Di);return i.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=i,this}getBoneByName(t){for(let e=0,i=this.bones.length;e<i;e++){const n=this.bones[e];if(n.name===t)return n}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let i=0,n=t.bones.length;i<n;i++){const s=t.bones[i];let r=e[s];r===void 0&&(Tt("Skeleton: No bone found with UUID:",s),r=new aM),this.bones.push(r),this.boneInverses.push(new Zt().fromArray(t.boneInverses[i]))}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,i=this.boneInverses;for(let n=0,s=e.length;n<s;n++){const r=e[n];t.bones.push(r.uuid);const o=i[n];t.boneInverses.push(o.toArray())}return t}}class Rf extends te{constructor(t,e,i,n=1){super(t,e,i),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=n}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 Xa=new Zt,Df=new Zt,lc=[],Cf=new Mn,oM=new Zt,zr=new Dt,Br=new _s;class NE extends Dt{constructor(t,e,i){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new Rf(new Float32Array(i*16),16),this.instanceColor=null,this.morphTexture=null,this.count=i,this.boundingBox=null,this.boundingSphere=null;for(let n=0;n<i;n++)this.setMatrixAt(n,oM)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new Mn),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Xa),Cf.copy(t.boundingBox).applyMatrix4(Xa),this.boundingBox.union(Cf)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new _s),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let i=0;i<e;i++)this.getMatrixAt(i,Xa),Br.copy(t.boundingSphere).applyMatrix4(Xa),this.boundingSphere.union(Br)}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 i=e.morphTargetInfluences,n=this.morphTexture.source.data.data,s=i.length+1,r=t*s+1;for(let o=0;o<i.length;o++)i[o]=n[r+o]}raycast(t,e){const i=this.matrixWorld,n=this.count;if(zr.geometry=this.geometry,zr.material=this.material,zr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Br.copy(this.boundingSphere),Br.applyMatrix4(i),t.ray.intersectsSphere(Br)!==!1))for(let s=0;s<n;s++){this.getMatrixAt(s,Xa),Df.multiplyMatrices(i,Xa),zr.matrixWorld=Df,zr.raycast(t,lc);for(let r=0,o=lc.length;r<o;r++){const c=lc[r];c.instanceId=s,c.object=this,e.push(c)}lc.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new Rf(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 i=e.morphTargetInfluences,n=i.length+1;this.morphTexture===null&&(this.morphTexture=new Js(new Float32Array(n*this.count),n,this.count,El,Di));const s=this.morphTexture.source.data.data;let r=0;for(let l=0;l<i.length;l++)r+=i[l];const o=this.geometry.morphTargetsRelative?1:1-r,c=n*t;return s[c]=o,s.set(i,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const mh=new D,cM=new D,lM=new Xt;class ra{constructor(t=new D(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,i,n){return this.normal.set(t,e,i),this.constant=n,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,i){const n=mh.subVectors(i,e).cross(cM.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(n,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,i=!0){const n=t.delta(mh),s=this.normal.dot(n);if(s===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const r=-(t.start.dot(this.normal)+this.constant)/s;return i===!0&&(r<0||r>1)?null:e.copy(t.start).addScaledVector(n,r)}intersectsLine(t){const e=this.distanceToPoint(t.start),i=this.distanceToPoint(t.end);return e<0&&i>0||i<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 i=e||lM.getNormalMatrix(t),n=this.coplanarPoint(mh).applyMatrix4(t),s=this.normal.applyMatrix3(i).normalize();return this.constant=-n.dot(s),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 na=new _s,hM=new Mt(.5,.5),hc=new D;class $d{constructor(t=new ra,e=new ra,i=new ra,n=new ra,s=new ra,r=new ra){this.planes=[t,e,i,n,s,r]}set(t,e,i,n,s,r){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(i),o[3].copy(n),o[4].copy(s),o[5].copy(r),this}copy(t){const e=this.planes;for(let i=0;i<6;i++)e[i].copy(t.planes[i]);return this}setFromProjectionMatrix(t,e=Zn,i=!1){const n=this.planes,s=t.elements,r=s[0],o=s[1],c=s[2],l=s[3],h=s[4],u=s[5],d=s[6],f=s[7],p=s[8],v=s[9],m=s[10],g=s[11],_=s[12],w=s[13],M=s[14],S=s[15];if(n[0].setComponents(l-r,f-h,g-p,S-_).normalize(),n[1].setComponents(l+r,f+h,g+p,S+_).normalize(),n[2].setComponents(l+o,f+u,g+v,S+w).normalize(),n[3].setComponents(l-o,f-u,g-v,S-w).normalize(),i)n[4].setComponents(c,d,m,M).normalize(),n[5].setComponents(l-c,f-d,g-m,S-M).normalize();else if(n[4].setComponents(l-c,f-d,g-m,S-M).normalize(),e===Zn)n[5].setComponents(l+c,f+d,g+m,S+M).normalize();else if(e===Eo)n[5].setComponents(c,d,m,M).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(),na.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),na.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(na)}intersectsSprite(t){na.center.set(0,0,0);const e=hM.distanceTo(t.center);return na.radius=.7071067811865476+e,na.applyMatrix4(t.matrixWorld),this.intersectsSphere(na)}intersectsSphere(t){const e=this.planes,i=t.center,n=-t.radius;for(let s=0;s<6;s++)if(e[s].distanceToPoint(i)<n)return!1;return!0}intersectsBox(t){const e=this.planes;for(let i=0;i<6;i++){const n=e[i];if(hc.x=n.normal.x>0?t.max.x:t.min.x,hc.y=n.normal.y>0?t.max.y:t.min.y,hc.z=n.normal.z>0?t.max.z:t.min.z,n.distanceToPoint(hc)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let i=0;i<6;i++)if(e[i].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class uM extends Ss{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new st(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 ll=new D,hl=new D,If=new Zt,Hr=new Co,uc=new _s,gh=new D,Pf=new D;class yg extends Pe{constructor(t=new ue,e=new uM){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,i=[0];for(let n=1,s=e.count;n<s;n++)ll.fromBufferAttribute(e,n-1),hl.fromBufferAttribute(e,n),i[n]=i[n-1],i[n]+=ll.distanceTo(hl);t.setAttribute("lineDistance",new _e(i,1))}else Tt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const i=this.geometry,n=this.matrixWorld,s=t.params.Line.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),uc.copy(i.boundingSphere),uc.applyMatrix4(n),uc.radius+=s,t.ray.intersectsSphere(uc)===!1)return;If.copy(n).invert(),Hr.copy(t.ray).applyMatrix4(If);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=i.index,d=i.attributes.position;if(h!==null){const f=Math.max(0,r.start),p=Math.min(h.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=h.getX(v),_=h.getX(v+1),w=dc(this,t,Hr,c,g,_,v);w&&e.push(w)}if(this.isLineLoop){const v=h.getX(p-1),m=h.getX(f),g=dc(this,t,Hr,c,v,m,p-1);g&&e.push(g)}}else{const f=Math.max(0,r.start),p=Math.min(d.count,r.start+r.count);for(let v=f,m=p-1;v<m;v+=l){const g=dc(this,t,Hr,c,v,v+1,v);g&&e.push(g)}if(this.isLineLoop){const v=dc(this,t,Hr,c,p-1,f,p-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function dc(a,t,e,i,n,s,r){const o=a.geometry.attributes.position;if(ll.fromBufferAttribute(o,n),hl.fromBufferAttribute(o,s),e.distanceSqToSegment(ll,hl,gh,Pf)>i)return;gh.applyMatrix4(a.matrixWorld);const l=t.ray.origin.distanceTo(gh);if(!(l<t.near||l>t.far))return{distance:l,point:Pf.clone().applyMatrix4(a.matrixWorld),index:r,face:null,faceIndex:null,barycoord:null,object:a}}const Lf=new D,Nf=new D;class OE extends yg{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,i=[];for(let n=0,s=e.count;n<s;n+=2)Lf.fromBufferAttribute(e,n),Nf.fromBufferAttribute(e,n+1),i[n]=n===0?0:i[n-1],i[n+1]=i[n]+Lf.distanceTo(Nf);t.setAttribute("lineDistance",new _e(i,1))}else Tt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class UE extends yg{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class _g extends Ss{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new st(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 Of=new Zt,$u=new Co,fc=new _s,pc=new D;class ds extends Pe{constructor(t=new ue,e=new _g){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 i=this.geometry,n=this.matrixWorld,s=t.params.Points.threshold,r=i.drawRange;if(i.boundingSphere===null&&i.computeBoundingSphere(),fc.copy(i.boundingSphere),fc.applyMatrix4(n),fc.radius+=s,t.ray.intersectsSphere(fc)===!1)return;Of.copy(n).invert(),$u.copy(t.ray).applyMatrix4(Of);const o=s/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=i.index,u=i.attributes.position;if(l!==null){const d=Math.max(0,r.start),f=Math.min(l.count,r.start+r.count);for(let p=d,v=f;p<v;p++){const m=l.getX(p);pc.fromBufferAttribute(u,m),Uf(pc,m,c,n,t,e,this)}}else{const d=Math.max(0,r.start),f=Math.min(u.count,r.start+r.count);for(let p=d,v=f;p<v;p++)pc.fromBufferAttribute(u,p),Uf(pc,p,c,n,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,i=Object.keys(e);if(i.length>0){const n=e[i[0]];if(n!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let s=0,r=n.length;s<r;s++){const o=n[s].name||String(s);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=s}}}}}function Uf(a,t,e,i,n,s,r){const o=$u.distanceSqToPoint(a);if(o<e){const c=new D;$u.closestPointToPoint(a,c),c.applyMatrix4(i);const l=n.ray.origin.distanceTo(c);if(l<n.near||l>n.far)return;s.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:r})}}class Sg extends xi{constructor(t=[],e=Sa,i,n,s,r,o,c,l,h){super(t,e,i,n,s,r,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class ws extends xi{constructor(t,e,i,n,s,r,o,c,l){super(t,e,i,n,s,r,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ks extends xi{constructor(t,e,i=vn,n,s,r,o=we,c=we,l,h=Ms,u=1){if(h!==Ms&&h!==ma)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,n,s,r,o,c,h,i,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new Xd(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 dM extends Ks{constructor(t,e=vn,i=Sa,n,s,r=we,o=we,c,l=Ms){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,i,n,s,r,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class wg extends xi{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class an extends ue{constructor(t=1,e=1,i=1,n=1,s=1,r=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:i,widthSegments:n,heightSegments:s,depthSegments:r};const o=this;n=Math.floor(n),s=Math.floor(s),r=Math.floor(r);const c=[],l=[],h=[],u=[];let d=0,f=0;p("z","y","x",-1,-1,i,e,t,r,s,0),p("z","y","x",1,-1,i,e,-t,r,s,1),p("x","z","y",1,1,t,i,e,n,r,2),p("x","z","y",1,-1,t,i,-e,n,r,3),p("x","y","z",1,-1,t,e,i,n,s,4),p("x","y","z",-1,-1,t,e,-i,n,s,5),this.setIndex(c),this.setAttribute("position",new _e(l,3)),this.setAttribute("normal",new _e(h,3)),this.setAttribute("uv",new _e(u,2));function p(v,m,g,_,w,M,S,b,T,x,A){const I=M/T,C=S/x,L=M/2,W=S/2,X=b/2,P=T+1,B=x+1;let k=0,K=0;const tt=new D;for(let J=0;J<B;J++){const it=J*C-W;for(let rt=0;rt<P;rt++){const Gt=rt*I-L;tt[v]=Gt*_,tt[m]=it*w,tt[g]=X,l.push(tt.x,tt.y,tt.z),tt[v]=0,tt[m]=0,tt[g]=b>0?1:-1,h.push(tt.x,tt.y,tt.z),u.push(rt/T),u.push(1-J/x),k+=1}}for(let J=0;J<x;J++)for(let it=0;it<T;it++){const rt=d+it+P*J,Gt=d+it+P*(J+1),Jt=d+(it+1)+P*(J+1),qt=d+(it+1)+P*J;c.push(rt,Gt,qt),c.push(Gt,Jt,qt),K+=6}o.addGroup(f,K,A),f+=K,d+=k}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new an(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Zd extends ue{constructor(t=1,e=32,i=0,n=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:i,thetaLength:n},e=Math.max(3,e);const s=[],r=[],o=[],c=[],l=new D,h=new Mt;r.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=i+u/e*n;l.x=t*Math.cos(f),l.y=t*Math.sin(f),r.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(r[d]/t+1)/2,h.y=(r[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)s.push(u,u+1,0);this.setIndex(s),this.setAttribute("position",new _e(r,3)),this.setAttribute("normal",new _e(o,3)),this.setAttribute("uv",new _e(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Zd(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class es extends ue{constructor(t=1,e=1,i=1,n=32,s=1,r=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:i,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:o,thetaLength:c};const l=this;n=Math.floor(n),s=Math.floor(s);const h=[],u=[],d=[],f=[];let p=0;const v=[],m=i/2;let g=0;_(),r===!1&&(t>0&&w(!0),e>0&&w(!1)),this.setIndex(h),this.setAttribute("position",new _e(u,3)),this.setAttribute("normal",new _e(d,3)),this.setAttribute("uv",new _e(f,2));function _(){const M=new D,S=new D;let b=0;const T=(e-t)/i;for(let x=0;x<=s;x++){const A=[],I=x/s,C=I*(e-t)+t;for(let L=0;L<=n;L++){const W=L/n,X=W*c+o,P=Math.sin(X),B=Math.cos(X);S.x=C*P,S.y=-I*i+m,S.z=C*B,u.push(S.x,S.y,S.z),M.set(P,T,B).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-I),A.push(p++)}v.push(A)}for(let x=0;x<n;x++)for(let A=0;A<s;A++){const I=v[A][x],C=v[A+1][x],L=v[A+1][x+1],W=v[A][x+1];(t>0||A!==0)&&(h.push(I,C,W),b+=3),(e>0||A!==s-1)&&(h.push(C,L,W),b+=3)}l.addGroup(g,b,0),g+=b}function w(M){const S=p,b=new Mt,T=new D;let x=0;const A=M===!0?t:e,I=M===!0?1:-1;for(let L=1;L<=n;L++)u.push(0,m*I,0),d.push(0,I,0),f.push(.5,.5),p++;const C=p;for(let L=0;L<=n;L++){const X=L/n*c+o,P=Math.cos(X),B=Math.sin(X);T.x=A*B,T.y=m*I,T.z=A*P,u.push(T.x,T.y,T.z),d.push(0,I,0),b.x=P*.5+.5,b.y=B*.5*I+.5,f.push(b.x,b.y),p++}for(let L=0;L<n;L++){const W=S+L,X=C+L;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),x+=3}l.addGroup(g,x,M===!0?1:2),g+=x}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new es(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class br extends es{constructor(t=1,e=1,i=32,n=1,s=!1,r=0,o=Math.PI*2){super(0,t,e,i,n,s,r,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:i,heightSegments:n,openEnded:s,thetaStart:r,thetaLength:o}}static fromJSON(t){return new br(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Al extends ue{constructor(t=[new Mt(0,-.5),new Mt(.5,0),new Mt(0,.5)],e=12,i=0,n=Math.PI*2){super(),this.type="LatheGeometry",this.parameters={points:t,segments:e,phiStart:i,phiLength:n},e=Math.floor(e),n=Qt(n,0,Math.PI*2);const s=[],r=[],o=[],c=[],l=[],h=1/e,u=new D,d=new Mt,f=new D,p=new D,v=new D;let m=0,g=0;for(let _=0;_<=t.length-1;_++)switch(_){case 0:m=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,f.x=g*1,f.y=-m,f.z=g*0,v.copy(f),f.normalize(),c.push(f.x,f.y,f.z);break;case t.length-1:c.push(v.x,v.y,v.z);break;default:m=t[_+1].x-t[_].x,g=t[_+1].y-t[_].y,f.x=g*1,f.y=-m,f.z=g*0,p.copy(f),f.x+=v.x,f.y+=v.y,f.z+=v.z,f.normalize(),c.push(f.x,f.y,f.z),v.copy(p)}for(let _=0;_<=e;_++){const w=i+_*h*n,M=Math.sin(w),S=Math.cos(w);for(let b=0;b<=t.length-1;b++){u.x=t[b].x*M,u.y=t[b].y,u.z=t[b].x*S,r.push(u.x,u.y,u.z),d.x=_/e,d.y=b/(t.length-1),o.push(d.x,d.y);const T=c[3*b+0]*M,x=c[3*b+1],A=c[3*b+0]*S;l.push(T,x,A)}}for(let _=0;_<e;_++)for(let w=0;w<t.length-1;w++){const M=w+_*t.length,S=M,b=M+t.length,T=M+t.length+1,x=M+1;s.push(S,b,x),s.push(T,x,b)}this.setIndex(s),this.setAttribute("position",new _e(r,3)),this.setAttribute("uv",new _e(o,2)),this.setAttribute("normal",new _e(l,3))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Al(t.points,t.segments,t.phiStart,t.phiLength)}}class ki extends ue{constructor(t=1,e=1,i=1,n=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:i,heightSegments:n};const s=t/2,r=e/2,o=Math.floor(i),c=Math.floor(n),l=o+1,h=c+1,u=t/o,d=e/c,f=[],p=[],v=[],m=[];for(let g=0;g<h;g++){const _=g*d-r;for(let w=0;w<l;w++){const M=w*u-s;p.push(M,-_,0),v.push(0,0,1),m.push(w/o),m.push(1-g/c)}}for(let g=0;g<c;g++)for(let _=0;_<o;_++){const w=_+l*g,M=_+l*(g+1),S=_+1+l*(g+1),b=_+1+l*g;f.push(w,M,b),f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(v,3)),this.setAttribute("uv",new _e(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ki(t.width,t.height,t.widthSegments,t.heightSegments)}}class Qe extends ue{constructor(t=1,e=32,i=16,n=0,s=Math.PI*2,r=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:i,phiStart:n,phiLength:s,thetaStart:r,thetaLength:o},e=Math.max(3,Math.floor(e)),i=Math.max(2,Math.floor(i));const c=Math.min(r+o,Math.PI);let l=0;const h=[],u=new D,d=new D,f=[],p=[],v=[],m=[];for(let g=0;g<=i;g++){const _=[],w=g/i,M=r+w*o,S=t*Math.cos(M),b=Math.sqrt(t*t-S*S);let T=0;g===0&&r===0?T=.5/e:g===i&&c===Math.PI&&(T=-.5/e);for(let x=0;x<=e;x++){const A=x/e,I=n+A*s;u.x=-b*Math.cos(I),u.y=S,u.z=b*Math.sin(I),p.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),m.push(A+T,1-w),_.push(l++)}h.push(_)}for(let g=0;g<i;g++)for(let _=0;_<e;_++){const w=h[g][_+1],M=h[g][_],S=h[g+1][_],b=h[g+1][_+1];(g!==0||r>0)&&f.push(w,M,b),(g!==i-1||c<Math.PI)&&f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new _e(p,3)),this.setAttribute("normal",new _e(v,3)),this.setAttribute("uv",new _e(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Qe(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}class Jd extends ue{constructor(t=1,e=.4,i=12,n=48,s=Math.PI*2,r=0,o=Math.PI*2){super(),this.type="TorusGeometry",this.parameters={radius:t,tube:e,radialSegments:i,tubularSegments:n,arc:s,thetaStart:r,thetaLength:o},i=Math.floor(i),n=Math.floor(n);const c=[],l=[],h=[],u=[],d=new D,f=new D,p=new D;for(let v=0;v<=i;v++){const m=r+v/i*o;for(let g=0;g<=n;g++){const _=g/n*s;f.x=(t+e*Math.cos(m))*Math.cos(_),f.y=(t+e*Math.cos(m))*Math.sin(_),f.z=e*Math.sin(m),l.push(f.x,f.y,f.z),d.x=t*Math.cos(_),d.y=t*Math.sin(_),p.subVectors(f,d).normalize(),h.push(p.x,p.y,p.z),u.push(g/n),u.push(v/i)}}for(let v=1;v<=i;v++)for(let m=1;m<=n;m++){const g=(n+1)*v+m-1,_=(n+1)*(v-1)+m-1,w=(n+1)*(v-1)+m,M=(n+1)*v+m;c.push(g,_,M),c.push(_,w,M)}this.setIndex(c),this.setAttribute("position",new _e(l,3)),this.setAttribute("normal",new _e(h,3)),this.setAttribute("uv",new _e(u,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Jd(t.radius,t.tube,t.radialSegments,t.tubularSegments,t.arc)}}function Sr(a){const t={};for(const e in a){t[e]={};for(const i in a[e]){const n=a[e][i];if(Ff(n))n.isRenderTargetTexture?(Tt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][i]=null):t[e][i]=n.clone();else if(Array.isArray(n))if(Ff(n[0])){const s=[];for(let r=0,o=n.length;r<o;r++)s[r]=n[r].clone();t[e][i]=s}else t[e][i]=n.slice();else t[e][i]=n}}return t}function Pi(a){const t={};for(let e=0;e<a.length;e++){const i=Sr(a[e]);for(const n in i)t[n]=i[n]}return t}function Ff(a){return a&&(a.isColor||a.isMatrix3||a.isMatrix4||a.isVector2||a.isVector3||a.isVector4||a.isTexture||a.isQuaternion)}function fM(a){const t=[];for(let e=0;e<a.length;e++)t.push(a[e].clone());return t}function bg(a){const t=a.getRenderTarget();return t===null?a.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:ne.workingColorSpace}const pM={clone:Sr,merge:Pi};var mM=`void main() {
|
|
701
701
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
702
702
|
}`,gM=`void main() {
|
|
703
703
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
704
|
-
}`;class ae extends Ss{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=mM,this.fragmentShader=gM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Sr(t.uniforms),this.uniformsGroups=fM(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?e.uniforms[n]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[n]={type:"m4",value:r.toArray()}:e.uniforms[n]={value:r}}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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const i in t.uniforms){const n=t.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=e[n.value]||null;break;case"c":this.uniforms[i].value=new st().setHex(n.value);break;case"v2":this.uniforms[i].value=new Mt().fromArray(n.value);break;case"v3":this.uniforms[i].value=new D().fromArray(n.value);break;case"v4":this.uniforms[i].value=new ie().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Xt().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Zt().fromArray(n.value);break;default:this.uniforms[i].value=n.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 i in t.extensions)this.extensions[i]=t.extensions[i];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Eg extends ae{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class la extends Ss{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new st(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 st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nl,this.normalScale=new Mt(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 xs,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 vM extends la{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 Mt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return jt(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 st(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 st(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new st(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 Er extends Ss{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nl,this.normalScale=new Mt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xs,this.combine=Nd,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 MM extends Ss{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cv,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 xM extends Ss{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 mc(a,t){return!a||a.constructor===t?a:typeof t.BYTES_PER_ELEMENT=="number"?new t(a):Array.prototype.slice.call(a)}function yM(a){function t(n,s){return a[n]-a[s]}const e=a.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(t),i}function kf(a,t,e){const i=a.length,n=new a.constructor(i);for(let s=0,r=0;r!==i;++s){const o=e[s]*t;for(let c=0;c!==t;++c)n[r++]=a[o+c]}return n}function _M(a,t,e,i){let n=1,s=a[0];for(;s!==void 0&&s[i]===void 0;)s=a[n++];if(s===void 0)return;let r=s[i];if(r!==void 0)if(Array.isArray(r))do r=s[i],r!==void 0&&(t.push(s.time),e.push(...r)),s=a[n++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[i],r!==void 0&&(t.push(s.time),r.toArray(e,e.length)),s=a[n++];while(s!==void 0);else do r=s[i],r!==void 0&&(t.push(s.time),e.push(r)),s=a[n++];while(s!==void 0)}class Io{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let r;i:{n:if(!(t<n)){for(let o=i+2;;){if(n===void 0){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=e[++i],t<n)break e}r=e.length;break i}if(!(t>=s)){const o=e[1];t<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=e[--i-1],t>=s)break e}r=i,i=0;break i}break t}for(;i<r;){const o=i+r>>>1;t<e[o]?r=o:i=o+1}if(n=e[i],s=e[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let r=0;r!==n;++r)e[r]=i[s+r];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class SM extends Io{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ir,endingEnd:ir}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,r=t+1,o=n[s],c=n[r];if(o===void 0)switch(this.getSettings_().endingStart){case nr:s=t,o=2*e-i;break;case il:s=n.length-2,o=e+n[s]-n[s+1];break;default:s=t,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case nr:r=t,c=2*i-e;break;case il:r=1,c=i+n[1]-n[0];break;default:r=t-1,c=e}const l=(i-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-e)/(n-e),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,_=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,w=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*r[h+S]+_*r[l+S]+w*r[c+S]+M*r[u+S];return s}}class Ag extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(i-e)/(n-e),u=1-h;for(let d=0;d!==o;++d)s[d]=r[l+d]*u+r[c+d]*h;return s}}class wM extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class bM extends Io{interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-e)/(n-e),v=1-p;for(let m=0;m!==o;++m)s[m]=r[l+m]*v+r[c+m]*p;return s}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=r[l+p],m=r[c+p],g=f*d+p*2,_=u[g],w=u[g+1],M=t*d+p*2,S=h[M],b=h[M+1];let T=(i-e)/(n-e),x,A,I,C,P;for(let X=0;X<8;X++){x=T*T,A=x*T,I=1-T,C=I*I,P=C*I;const N=P*e+3*C*T*_+3*I*x*S+A*n-i;if(Math.abs(N)<1e-10)break;const V=3*C*(_-e)+6*I*T*(S-_)+3*x*(n-S);if(Math.abs(V)<1e-10)break;T=T-N/V,T=Math.max(0,Math.min(1,T))}s[p]=P*v+3*C*T*w+3*I*x*b+A*m}return s}}class Pn{constructor(t,e,i,n){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=mc(e,this.TimeBufferType),this.values=mc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:mc(t.times,Array),values:mc(t.values,Array)};const n=t.getInterpolation();n!==t.DefaultInterpolation&&(i.interpolation=n)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new wM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ag(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new SM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new bM(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 el:e=this.InterpolantFactoryMethodDiscrete;break;case Yu:e=this.InterpolantFactoryMethodLinear;break;case Wl:e=this.InterpolantFactoryMethodSmooth;break;case nf:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const i="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(i);return Tt("KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return el;case this.InterpolantFactoryMethodLinear:return Yu;case this.InterpolantFactoryMethodSmooth:return Wl;case this.InterpolantFactoryMethodBezier:return nf}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<t;)++s;for(;r!==-1&&i[r]>e;)--r;if(++r,s!==0||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Ht("KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Ht("KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Ht("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(r!==null&&r>c){Ht("KeyframeTrack: Out of order keys.",this,o,c,r),t=!1;break}r=c}if(n!==void 0&&vv(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Ht("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(),i=this.getValueSize(),n=this.getInterpolation()===Wl,s=t.length-1;let r=1;for(let o=1;o<s;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==r){t[r]=t[o];const u=o*i,d=r*i;for(let f=0;f!==i;++f)e[d+f]=e[u+f]}++r}}if(s>0){t[r]=t[s];for(let o=s*i,c=r*i,l=0;l!==i;++l)e[c+l]=e[o+l];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,n=new i(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Pn.prototype.ValueTypeName="";Pn.prototype.TimeBufferType=Float32Array;Pn.prototype.ValueBufferType=Float32Array;Pn.prototype.DefaultInterpolation=Yu;class Ar extends Pn{constructor(t,e,i){super(t,e,i)}}Ar.prototype.ValueTypeName="bool";Ar.prototype.ValueBufferType=Array;Ar.prototype.DefaultInterpolation=el;Ar.prototype.InterpolantFactoryMethodLinear=void 0;Ar.prototype.InterpolantFactoryMethodSmooth=void 0;class Tg extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}Tg.prototype.ValueTypeName="color";class jd extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}jd.prototype.ValueTypeName="number";class EM extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(i-e)/(n-e);let l=t*o;for(let h=l+o;l!==h;l+=4)sn.slerpFlat(s,0,r,l-o,r,l,c);return s}}class Qd extends Pn{constructor(t,e,i,n){super(t,e,i,n)}InterpolantFactoryMethodLinear(t){return new EM(this.times,this.values,this.getValueSize(),t)}}Qd.prototype.ValueTypeName="quaternion";Qd.prototype.InterpolantFactoryMethodSmooth=void 0;class Tr extends Pn{constructor(t,e,i){super(t,e,i)}}Tr.prototype.ValueTypeName="string";Tr.prototype.ValueBufferType=Array;Tr.prototype.DefaultInterpolation=el;Tr.prototype.InterpolantFactoryMethodLinear=void 0;Tr.prototype.InterpolantFactoryMethodSmooth=void 0;class Rg extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}Rg.prototype.ValueTypeName="vector";class zf{constructor(t="",e=-1,i=[],n=Hd){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Dn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let r=0,o=i.length;r!==o;++r)e.push(TM(i[r]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,r=i.length;s!==r;++s)e.push(Pn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,r=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=yM(c);c=kf(c,1,h),l=kf(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),r.push(new jd(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/i))}return new this(t,-1,r)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const n=t;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const r=[];for(const o in n)r.push(this.CreateFromMorphTargetSequence(o,n[o],e,i));return r}resetDuration(){const t=this.tracks;let e=0;for(let i=0,n=t.length;i!==n;++i){const s=this.tracks[i];e=Math.max(e,s.times[s.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 i=0;i<this.tracks.length;i++)t.push(this.tracks[i].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 AM(a){switch(a.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return jd;case"vector":case"vector2":case"vector3":case"vector4":return Rg;case"color":return Tg;case"quaternion":return Qd;case"bool":case"boolean":return Ar;case"string":return Tr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+a)}function TM(a){if(a.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=AM(a.type);if(a.times===void 0){const e=[],i=[];_M(a.keys,e,i,"value"),a.times=e,a.values=i}return t.parse!==void 0?t.parse(a):new t(a.name,a.times,a.values,a.interpolation)}const gs={enabled:!1,files:{},add:function(a,t){this.enabled!==!1&&(Bf(a)||(this.files[a]=t))},get:function(a){if(this.enabled!==!1&&!Bf(a))return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};function Bf(a){try{const t=a.slice(a.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class RM{constructor(t,e,i){const n=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,n.onProgress!==void 0&&n.onProgress(h,r,o),r===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const DM=new RM;class Po{constructor(t){this.manager=t!==void 0?t:DM,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 i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}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}}Po.DEFAULT_MATERIAL_NAME="__DEFAULT";const os={};class CM extends Error{constructor(t,e){super(t),this.response=e}}class FE extends Po{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=gs.get(`file:${t}`);if(s!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0);return}if(os[t]!==void 0){os[t].push({onLoad:e,onProgress:i,onError:n});return}os[t]=[],os[t].push({onLoad:e,onProgress:i,onError:n});const r=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(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Tt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=os[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 m=new ReadableStream({start(g){_();function _(){u.read().then(({done:w,value:M})=>{if(w)g.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let b=0,T=h.length;b<T;b++){const x=h[b];x.onProgress&&x.onProgress(S)}g.enqueue(M),_()}},w=>{g.error(w)})}}});return new Response(m)}else throw new CM(`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=>{gs.add(`file:${t}`,l);const h=os[t];delete os[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=os[t];if(h===void 0)throw this.manager.itemError(t),l;delete os[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 qa=new WeakMap;class IM extends Po{constructor(t){super(t)}load(t,e,i,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=gs.get(`image:${t}`);if(r!==void 0){if(r.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0);else{let u=qa.get(r);u===void 0&&(u=[],qa.set(r,u)),u.push({onLoad:e,onError:n})}return r}const o=Ao("img");function c(){h(),e&&e(this);const u=qa.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}qa.delete(this),s.manager.itemEnd(t)}function l(u){h(),n&&n(u),gs.remove(`image:${t}`);const d=qa.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}qa.delete(this),s.manager.itemError(t),s.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),gs.add(`image:${t}`,o),s.manager.itemStart(t),o.src=t,o}}class kE extends Po{constructor(t){super(t)}load(t,e,i,n){const s=new xi,r=new IM(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},i,n),s}}class Tl extends Pe{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new st(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 PM extends Tl{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.groundColor=new st(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 vh=new Zt,Hf=new D,Gf=new D;class t0{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 Mt(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new Zt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $d,this._frameExtents=new Mt(1,1),this._viewportCount=1,this._viewports=[new ie(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Hf.setFromMatrixPosition(t.matrixWorld),e.position.copy(Hf),Gf.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Gf),e.updateMatrixWorld(),vh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Eo||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(vh)}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 gc=new D,vc=new sn,Fn=new D;class Dg extends Pe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Zt,this.projectionMatrix=new Zt,this.projectionMatrixInverse=new Zt,this.coordinateSystem=Zn,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(gc,vc,Fn),Fn.x===1&&Fn.y===1&&Fn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gc,vc,Fn.set(1,1,1)).invert()}updateWorldMatrix(t,e,i=!1){super.updateWorldMatrix(t,e,i),this.matrixWorld.decompose(gc,vc,Fn),Fn.x===1&&Fn.y===1&&Fn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gc,vc,Fn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ps=new D,Vf=new Mt,Wf=new Mt;class Vi extends Dg{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=_r*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(oo*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return _r*2*Math.atan(Math.tan(oo*.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,i){Ps.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ps.x,Ps.y).multiplyScalar(-t/Ps.z),Ps.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ps.x,Ps.y).multiplyScalar(-t/Ps.z)}getViewSize(t,e){return this.getViewBounds(t,Vf,Wf),e.subVectors(Wf,Vf)}setViewOffset(t,e,i,n,s,r){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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(oo*.5*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*n/c,e-=r.offsetY*i/l,n*=r.width/c,i*=r.height/l}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,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 LM extends t0{constructor(){super(new Vi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=_r*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(i!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class zE extends Tl{constructor(t,e,i=0,n=Math.PI/3,s=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.target=new Pe,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new LM}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 NM extends t0{constructor(){super(new Vi(90,1,.5,500)),this.isPointLightShadow=!0}}class Cg extends Tl{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new NM}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 In extends Dg{constructor(t=-1,e=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=r,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,i,n,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,r=i+t,o=n+e,c=n-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;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(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 OM extends t0{constructor(){super(new In(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Xf extends Tl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.target=new Pe,this.shadow=new OM}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 BE{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 Mh=new WeakMap;class HE extends Po{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Tt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Tt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=gs.get(`image-bitmap:${t}`);if(r!==void 0){if(s.manager.itemStart(t),r.then){r.then(l=>{Mh.has(r)===!0?(n&&n(Mh.get(r)),s.manager.itemError(t),s.manager.itemEnd(t)):(e&&e(l),s.manager.itemEnd(t))});return}setTimeout(function(){e&&e(r),s.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(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(`image-bitmap:${t}`,l),e&&e(l),s.manager.itemEnd(t)}).catch(function(l){n&&n(l),Mh.set(c,l),gs.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});gs.add(`image-bitmap:${t}`,c),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Ya=-90,Ka=1;class e0 extends Pe{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Vi(Ya,Ka,t,e);n.layers=this.layers,this.add(n);const s=new Vi(Ya,Ka,t,e);s.layers=this.layers,this.add(s);const r=new Vi(Ya,Ka,t,e);r.layers=this.layers,this.add(r);const o=new Vi(Ya,Ka,t,e);o.layers=this.layers,this.add(o);const c=new Vi(Ya,Ka,t,e);c.layers=this.layers,this.add(c);const l=new Vi(Ya,Ka,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,r,o,c]=e;for(const l of e)this.remove(l);if(t===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Eo)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,r,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=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(i,0,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,1,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(i,2,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,3,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(i,4,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=v,t.setRenderTarget(i,5,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class UM extends Vi{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class FM{constructor(t,e,i){this.binding=t,this.valueSize=i;let n,s,r;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let r=this.cumulativeWeight;if(r===0){for(let o=0;o!==n;++o)i[s+o]=i[o];r=e}else{r+=e;const o=e/r;this._mixBufferRegion(i,s,0,o,n)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,r=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=e*this._origIndex;this._mixBufferRegion(i,n,c,1-s,e)}r>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(i[c]!==i[c+e]){o.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,r=n;s!==r;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let r=0;r!==s;++r)t[e+r]=t[i+r]}_slerp(t,e,i,n){sn.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;sn.multiplyQuaternionsFlat(t,r,t,e,t,i),sn.slerpFlat(t,e,t,e,t,r,n)}_lerp(t,e,i,n,s){const r=1-n;for(let o=0;o!==s;++o){const c=e+o;t[c]=t[c]*r+t[i+o]*n}}_lerpAdditive(t,e,i,n,s){for(let r=0;r!==s;++r){const o=e+r;t[o]=t[o]+t[i+r]*n}}}const i0="\\[\\]\\.:\\/",kM=new RegExp("["+i0+"]","g"),n0="[^"+i0+"]",zM="[^"+i0.replace("\\.","")+"]",BM=/((?:WC+[\/:])*)/.source.replace("WC",n0),HM=/(WCOD+)?/.source.replace("WCOD",zM),GM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",n0),VM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",n0),WM=new RegExp("^"+BM+HM+GM+VM+"$"),XM=["material","materials","bones","map"];class qM{constructor(t,e,i){const n=i||xe.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class xe{constructor(t,e,i){this.path=e,this.parsedPath=i||xe.parseTrackName(e),this.node=xe.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new xe.Composite(t,e,i):new xe(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(kM,"")}static parseTrackName(t){const e=WM.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);XM.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(s){for(let r=0;r<s.length;r++){const o=s[r];if(o.name===e||o.uuid===e)return o;const c=i(o.children);if(c)return c}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_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 i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=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,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=xe.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Tt("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=e.objectIndex;switch(i){case"materials":if(!t.material){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Ht("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){Ht("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){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Ht("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[i]===void 0){Ht("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(l!==void 0){if(t[l]===void 0){Ht("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const r=t[n];if(r===void 0){const l=e.nodeName;Ht("PropertyBinding: Trying to update property for track: "+l+"."+n+" 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(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(c=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}xe.Composite=qM;xe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};xe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};xe.prototype.GetterByBindingType=[xe.prototype._getValue_direct,xe.prototype._getValue_array,xe.prototype._getValue_arrayElement,xe.prototype._getValue_toArray];xe.prototype.SetterByBindingTypeAndVersioning=[[xe.prototype._setValue_direct,xe.prototype._setValue_direct_setNeedsUpdate,xe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_array,xe.prototype._setValue_array_setNeedsUpdate,xe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_arrayElement,xe.prototype._setValue_arrayElement_setNeedsUpdate,xe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_fromArray,xe.prototype._setValue_fromArray_setNeedsUpdate,xe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class YM{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,r=s.length,o=new Array(r),c={endingStart:ir,endingEnd:ir};for(let l=0;l!==r;++l){const h=s[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=av,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),i===!0){const n=this._clip.duration,s=t._clip.duration,r=s/n,o=n/s;t._restoreTimeScale=t.timeScale,this._restoreTimeScale=this.timeScale,t.warp(1,r,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,s=n.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+i,l[0]=t/r,l[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const c=(t-s)*i;c<0||i===0?e=0:(this._startTime=null,e=i*c)}e*=this._updateTimeScale(t);const r=this._updateTime(e),o=this._updateWeight(t);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case ov:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(r),l[h].accumulateAdditive(o);break;case Hd:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(r),l[h].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(e===0?this.paused=!0:(this._restoreTimeScale!==null&&(e=this._restoreTimeScale),this.timeScale=e),this.stopWarping())}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const r=i===rv;if(t===0)return s===-1?n:r&&(s&1)===1?e-n:n;if(i===dg){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),n>=e||n<0){const o=Math.floor(n/e);n-=e*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){const l=t<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=n;if(r&&(s&1)===1)return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=nr,n.endingEnd=nr):(t?n.endingStart=this.zeroSlopeAtStart?nr:ir:n.endingStart=il,e?n.endingEnd=this.zeroSlopeAtEnd?nr:ir:n.endingEnd=il)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let r=this._weightInterpolant;r===null&&(r=n._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=e,o[1]=s+t,c[1]=i,this}}const KM=new Float32Array(1);class $M extends Zs{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,o=t._interpolants,c=i.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==s;++u){const d=n[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,r[u]=p;else{if(p=r[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}const v=e&&e._propertyBindings[u].binding.parsedPath;p=new FM(xe.create(i,f,v),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),r[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,i)}const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(r===void 0)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const o=r.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,o=r[s],c=o.knownActions,l=c[c.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),t._byClipCacheIndex=null;const u=o.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],c.length===0&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];r===void 0&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,o=r[n],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete o[s],Object.keys(o).length===0&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return i===void 0&&(i=new Ag(new Float32Array(2),new Float32Array(2),1,KM),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r=typeof t=="string"?zf.findByName(n,t):t;const o=r!==null?r.uuid:t,c=this._actionsByClip[o];let l=null;if(i===void 0&&(r!==null?i=r.blendMode:i=Hd),c!==void 0){const u=c.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=c.knownActions[0],r===null&&(r=l._clip)}if(r===null)return null;const h=new YM(this,r,e,i);return this._bindAction(h,l),this._addInactiveAction(h,o,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s=typeof t=="string"?zf.findByName(i,t):t,r=s?s.uuid:t,o=this._actionsByClip[r];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let i=e-1;i>=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){const r=s.knownActions;for(let o=0,c=r.length;o!==c;++o){const l=r[o];this._deactivateAction(l);const h=l._cacheIndex,u=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(l)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const r in i){const o=i[r].actionByRoot,c=o[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(const r in s){const o=s[r];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(t,e){const i=this.existingAction(t,e);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}const qf=new Zt;class xh{constructor(t,e,i=0,n=1/0){this.ray=new Co(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new qd,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):Ht("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return qf.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(qf),this}intersectObject(t,e=!0,i=[]){return Zu(t,this,i,e),i.sort(Yf),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Zu(t[n],this,i,e);return i.sort(Yf),i}}function Yf(a,t){return a.distance-t.distance}function Zu(a,t,e,i){let n=!0;if(a.layers.test(t.layers)&&a.raycast(t,e)===!1&&(n=!1),n===!0&&i===!0){const s=a.children;for(let r=0,o=s.length;r<o;r++)Zu(s[r],t,e,!0)}}class Ig{static{Ig.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const s=this.elements;return s[0]=t,s[2]=e,s[1]=i,s[3]=n,this}}function Kf(a,t,e,i){const n=ZM(i);switch(e){case hg:return a*t;case El:return a*t/n.components*n.byteLength;case kd:return a*t/n.components*n.byteLength;case wa:return a*t*2/n.components*n.byteLength;case zd:return a*t*2/n.components*n.byteLength;case ug:return a*t*3/n.components*n.byteLength;case _i:return a*t*4/n.components*n.byteLength;case Bd:return a*t*4/n.components*n.byteLength;case Bc:case Hc:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*8;case Gc:case Vc:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Mu:case yu:return Math.max(a,16)*Math.max(t,8)/4;case vu:case xu:return Math.max(a,8)*Math.max(t,8)/2;case _u:case Su:case bu:case Eu:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*8;case wu:case Qc:case Au:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Tu:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Ru:return Math.floor((a+4)/5)*Math.floor((t+3)/4)*16;case Du:return Math.floor((a+4)/5)*Math.floor((t+4)/5)*16;case Cu:return Math.floor((a+5)/6)*Math.floor((t+4)/5)*16;case Iu:return Math.floor((a+5)/6)*Math.floor((t+5)/6)*16;case Pu:return Math.floor((a+7)/8)*Math.floor((t+4)/5)*16;case Lu:return Math.floor((a+7)/8)*Math.floor((t+5)/6)*16;case Nu:return Math.floor((a+7)/8)*Math.floor((t+7)/8)*16;case Ou:return Math.floor((a+9)/10)*Math.floor((t+4)/5)*16;case Uu:return Math.floor((a+9)/10)*Math.floor((t+5)/6)*16;case Fu:return Math.floor((a+9)/10)*Math.floor((t+7)/8)*16;case ku:return Math.floor((a+9)/10)*Math.floor((t+9)/10)*16;case zu:return Math.floor((a+11)/12)*Math.floor((t+9)/10)*16;case Bu:return Math.floor((a+11)/12)*Math.floor((t+11)/12)*16;case Hu:case Gu:case Vu:return Math.ceil(a/4)*Math.ceil(t/4)*16;case Wu:case Xu:return Math.ceil(a/4)*Math.ceil(t/4)*8;case tl:case qu:return Math.ceil(a/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ZM(a){switch(a){case nn:case rg:return{byteLength:1,components:1};case wo:case og:case ze:return{byteLength:2,components:1};case Ud:case Fd:return{byteLength:2,components:4};case vn:case Od:case Di:return{byteLength:4,components:1};case cg:case lg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ld}}));typeof window<"u"&&(window.__THREE__?Tt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ld);/**
|
|
704
|
+
}`;class ae extends Ss{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=mM,this.fragmentShader=gM,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,t!==void 0&&this.setValues(t)}copy(t){return super.copy(t),this.fragmentShader=t.fragmentShader,this.vertexShader=t.vertexShader,this.uniforms=Sr(t.uniforms),this.uniformsGroups=fM(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 n in this.uniforms){const r=this.uniforms[n].value;r&&r.isTexture?e.uniforms[n]={type:"t",value:r.toJSON(t).uuid}:r&&r.isColor?e.uniforms[n]={type:"c",value:r.getHex()}:r&&r.isVector2?e.uniforms[n]={type:"v2",value:r.toArray()}:r&&r.isVector3?e.uniforms[n]={type:"v3",value:r.toArray()}:r&&r.isVector4?e.uniforms[n]={type:"v4",value:r.toArray()}:r&&r.isMatrix3?e.uniforms[n]={type:"m3",value:r.toArray()}:r&&r.isMatrix4?e.uniforms[n]={type:"m4",value:r.toArray()}:e.uniforms[n]={value:r}}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 i={};for(const n in this.extensions)this.extensions[n]===!0&&(i[n]=!0);return Object.keys(i).length>0&&(e.extensions=i),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const i in t.uniforms){const n=t.uniforms[i];switch(this.uniforms[i]={},n.type){case"t":this.uniforms[i].value=e[n.value]||null;break;case"c":this.uniforms[i].value=new st().setHex(n.value);break;case"v2":this.uniforms[i].value=new Mt().fromArray(n.value);break;case"v3":this.uniforms[i].value=new D().fromArray(n.value);break;case"v4":this.uniforms[i].value=new ie().fromArray(n.value);break;case"m3":this.uniforms[i].value=new Xt().fromArray(n.value);break;case"m4":this.uniforms[i].value=new Zt().fromArray(n.value);break;default:this.uniforms[i].value=n.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 i in t.extensions)this.extensions[i]=t.extensions[i];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class Eg extends ae{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class la extends Ss{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new st(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 st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nl,this.normalScale=new Mt(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 xs,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 vM extends la{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 Mt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Qt(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 st(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 st(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new st(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 Er extends Ss{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new st(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new st(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=nl,this.normalScale=new Mt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xs,this.combine=Nd,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 MM extends Ss{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=cv,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 xM extends Ss{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 mc(a,t){return!a||a.constructor===t?a:typeof t.BYTES_PER_ELEMENT=="number"?new t(a):Array.prototype.slice.call(a)}function yM(a){function t(n,s){return a[n]-a[s]}const e=a.length,i=new Array(e);for(let n=0;n!==e;++n)i[n]=n;return i.sort(t),i}function kf(a,t,e){const i=a.length,n=new a.constructor(i);for(let s=0,r=0;r!==i;++s){const o=e[s]*t;for(let c=0;c!==t;++c)n[r++]=a[o+c]}return n}function _M(a,t,e,i){let n=1,s=a[0];for(;s!==void 0&&s[i]===void 0;)s=a[n++];if(s===void 0)return;let r=s[i];if(r!==void 0)if(Array.isArray(r))do r=s[i],r!==void 0&&(t.push(s.time),e.push(...r)),s=a[n++];while(s!==void 0);else if(r.toArray!==void 0)do r=s[i],r!==void 0&&(t.push(s.time),r.toArray(e,e.length)),s=a[n++];while(s!==void 0);else do r=s[i],r!==void 0&&(t.push(s.time),e.push(r)),s=a[n++];while(s!==void 0)}class Io{constructor(t,e,i,n){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=n!==void 0?n:new e.constructor(i),this.sampleValues=e,this.valueSize=i,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let i=this._cachedIndex,n=e[i],s=e[i-1];t:{e:{let r;i:{n:if(!(t<n)){for(let o=i+2;;){if(n===void 0){if(t<s)break n;return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}if(i===o)break;if(s=n,n=e[++i],t<n)break e}r=e.length;break i}if(!(t>=s)){const o=e[1];t<o&&(i=2,s=o);for(let c=i-2;;){if(s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===c)break;if(n=s,s=e[--i-1],t>=s)break e}r=i,i=0;break i}break t}for(;i<r;){const o=i+r>>>1;t<e[o]?r=o:i=o+1}if(n=e[i],s=e[i-1],s===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===void 0)return i=e.length,this._cachedIndex=i,this.copySampleValue_(i-1)}this._cachedIndex=i,this.intervalChanged_(i,s,n)}return this.interpolate_(i,s,t,n)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,i=this.sampleValues,n=this.valueSize,s=t*n;for(let r=0;r!==n;++r)e[r]=i[s+r];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class SM extends Io{constructor(t,e,i,n){super(t,e,i,n),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:ir,endingEnd:ir}}intervalChanged_(t,e,i){const n=this.parameterPositions;let s=t-2,r=t+1,o=n[s],c=n[r];if(o===void 0)switch(this.getSettings_().endingStart){case nr:s=t,o=2*e-i;break;case il:s=n.length-2,o=e+n[s]-n[s+1];break;default:s=t,o=i}if(c===void 0)switch(this.getSettings_().endingEnd){case nr:r=t,c=2*i-e;break;case il:r=1,c=i+n[1]-n[0];break;default:r=t-1,c=e}const l=(i-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-i),this._offsetPrev=s*h,this._offsetNext=r*h}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,p=(i-e)/(n-e),v=p*p,m=v*p,g=-d*m+2*d*v-d*p,_=(1+d)*m+(-1.5-2*d)*v+(-.5+d)*p+1,w=(-1-f)*m+(1.5+f)*v+.5*p,M=f*m-f*v;for(let S=0;S!==o;++S)s[S]=g*r[h+S]+_*r[l+S]+w*r[c+S]+M*r[u+S];return s}}class Ag extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(i-e)/(n-e),u=1-h;for(let d=0;d!==o;++d)s[d]=r[l+d]*u+r[c+d]*h;return s}}class wM extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t){return this.copySampleValue_(t-1)}}class bM extends Io{interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const p=(i-e)/(n-e),v=1-p;for(let m=0;m!==o;++m)s[m]=r[l+m]*v+r[c+m]*p;return s}const d=o*2,f=t-1;for(let p=0;p!==o;++p){const v=r[l+p],m=r[c+p],g=f*d+p*2,_=u[g],w=u[g+1],M=t*d+p*2,S=h[M],b=h[M+1];let T=(i-e)/(n-e),x,A,I,C,L;for(let W=0;W<8;W++){x=T*T,A=x*T,I=1-T,C=I*I,L=C*I;const P=L*e+3*C*T*_+3*I*x*S+A*n-i;if(Math.abs(P)<1e-10)break;const B=3*C*(_-e)+6*I*T*(S-_)+3*x*(n-S);if(Math.abs(B)<1e-10)break;T=T-P/B,T=Math.max(0,Math.min(1,T))}s[p]=L*v+3*C*T*w+3*I*x*b+A*m}return s}}class Pn{constructor(t,e,i,n){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=mc(e,this.TimeBufferType),this.values=mc(i,this.ValueBufferType),this.setInterpolation(n||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let i;if(e.toJSON!==this.toJSON)i=e.toJSON(t);else{i={name:t.name,times:mc(t.times,Array),values:mc(t.values,Array)};const n=t.getInterpolation();n!==t.DefaultInterpolation&&(i.interpolation=n)}return i.type=t.ValueTypeName,i}InterpolantFactoryMethodDiscrete(t){return new wM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new Ag(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new SM(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new bM(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 el:e=this.InterpolantFactoryMethodDiscrete;break;case Yu:e=this.InterpolantFactoryMethodLinear;break;case Wl:e=this.InterpolantFactoryMethodSmooth;break;case nf:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const i="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(i);return Tt("KeyframeTrack:",i),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return el;case this.InterpolantFactoryMethodLinear:return Yu;case this.InterpolantFactoryMethodSmooth:return Wl;case this.InterpolantFactoryMethodBezier:return nf}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let i=0,n=e.length;i!==n;++i)e[i]*=t}return this}trim(t,e){const i=this.times,n=i.length;let s=0,r=n-1;for(;s!==n&&i[s]<t;)++s;for(;r!==-1&&i[r]>e;)--r;if(++r,s!==0||r!==n){s>=r&&(r=Math.max(r,1),s=r-1);const o=this.getValueSize();this.times=i.slice(s,r),this.values=this.values.slice(s*o,r*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(Ht("KeyframeTrack: Invalid value size in track.",this),t=!1);const i=this.times,n=this.values,s=i.length;s===0&&(Ht("KeyframeTrack: Track is empty.",this),t=!1);let r=null;for(let o=0;o!==s;o++){const c=i[o];if(typeof c=="number"&&isNaN(c)){Ht("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(r!==null&&r>c){Ht("KeyframeTrack: Out of order keys.",this,o,c,r),t=!1;break}r=c}if(n!==void 0&&vv(n))for(let o=0,c=n.length;o!==c;++o){const l=n[o];if(isNaN(l)){Ht("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(),i=this.getValueSize(),n=this.getInterpolation()===Wl,s=t.length-1;let r=1;for(let o=1;o<s;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(n)c=!0;else{const u=o*i,d=u-i,f=u+i;for(let p=0;p!==i;++p){const v=e[u+p];if(v!==e[d+p]||v!==e[f+p]){c=!0;break}}}if(c){if(o!==r){t[r]=t[o];const u=o*i,d=r*i;for(let f=0;f!==i;++f)e[d+f]=e[u+f]}++r}}if(s>0){t[r]=t[s];for(let o=s*i,c=r*i,l=0;l!==i;++l)e[c+l]=e[o+l];++r}return r!==t.length?(this.times=t.slice(0,r),this.values=e.slice(0,r*i)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),i=this.constructor,n=new i(this.name,t,e);return n.createInterpolant=this.createInterpolant,n}}Pn.prototype.ValueTypeName="";Pn.prototype.TimeBufferType=Float32Array;Pn.prototype.ValueBufferType=Float32Array;Pn.prototype.DefaultInterpolation=Yu;class Ar extends Pn{constructor(t,e,i){super(t,e,i)}}Ar.prototype.ValueTypeName="bool";Ar.prototype.ValueBufferType=Array;Ar.prototype.DefaultInterpolation=el;Ar.prototype.InterpolantFactoryMethodLinear=void 0;Ar.prototype.InterpolantFactoryMethodSmooth=void 0;class Tg extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}Tg.prototype.ValueTypeName="color";class jd extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}jd.prototype.ValueTypeName="number";class EM extends Io{constructor(t,e,i,n){super(t,e,i,n)}interpolate_(t,e,i,n){const s=this.resultBuffer,r=this.sampleValues,o=this.valueSize,c=(i-e)/(n-e);let l=t*o;for(let h=l+o;l!==h;l+=4)sn.slerpFlat(s,0,r,l-o,r,l,c);return s}}class Qd extends Pn{constructor(t,e,i,n){super(t,e,i,n)}InterpolantFactoryMethodLinear(t){return new EM(this.times,this.values,this.getValueSize(),t)}}Qd.prototype.ValueTypeName="quaternion";Qd.prototype.InterpolantFactoryMethodSmooth=void 0;class Tr extends Pn{constructor(t,e,i){super(t,e,i)}}Tr.prototype.ValueTypeName="string";Tr.prototype.ValueBufferType=Array;Tr.prototype.DefaultInterpolation=el;Tr.prototype.InterpolantFactoryMethodLinear=void 0;Tr.prototype.InterpolantFactoryMethodSmooth=void 0;class Rg extends Pn{constructor(t,e,i,n){super(t,e,i,n)}}Rg.prototype.ValueTypeName="vector";class zf{constructor(t="",e=-1,i=[],n=Hd){this.name=t,this.tracks=i,this.duration=e,this.blendMode=n,this.uuid=Dn(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],i=t.tracks,n=1/(t.fps||1);for(let r=0,o=i.length;r!==o;++r)e.push(TM(i[r]).scale(n));const s=new this(t.name,t.duration,e,t.blendMode);return s.uuid=t.uuid,s.userData=JSON.parse(t.userData||"{}"),s}static toJSON(t){const e=[],i=t.tracks,n={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let s=0,r=i.length;s!==r;++s)e.push(Pn.toJSON(i[s]));return n}static CreateFromMorphTargetSequence(t,e,i,n){const s=e.length,r=[];for(let o=0;o<s;o++){let c=[],l=[];c.push((o+s-1)%s,o,(o+1)%s),l.push(0,1,0);const h=yM(c);c=kf(c,1,h),l=kf(l,1,h),!n&&c[0]===0&&(c.push(s),l.push(l[0])),r.push(new jd(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/i))}return new this(t,-1,r)}static findByName(t,e){let i=t;if(!Array.isArray(t)){const n=t;i=n.geometry&&n.geometry.animations||n.animations}for(let n=0;n<i.length;n++)if(i[n].name===e)return i[n];return null}static CreateClipsFromMorphTargetSequences(t,e,i){const n={},s=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(s);if(h&&h.length>1){const u=h[1];let d=n[u];d||(n[u]=d=[]),d.push(l)}}const r=[];for(const o in n)r.push(this.CreateFromMorphTargetSequence(o,n[o],e,i));return r}resetDuration(){const t=this.tracks;let e=0;for(let i=0,n=t.length;i!==n;++i){const s=this.tracks[i];e=Math.max(e,s.times[s.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 i=0;i<this.tracks.length;i++)t.push(this.tracks[i].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 AM(a){switch(a.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return jd;case"vector":case"vector2":case"vector3":case"vector4":return Rg;case"color":return Tg;case"quaternion":return Qd;case"bool":case"boolean":return Ar;case"string":return Tr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+a)}function TM(a){if(a.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=AM(a.type);if(a.times===void 0){const e=[],i=[];_M(a.keys,e,i,"value"),a.times=e,a.values=i}return t.parse!==void 0?t.parse(a):new t(a.name,a.times,a.values,a.interpolation)}const gs={enabled:!1,files:{},add:function(a,t){this.enabled!==!1&&(Bf(a)||(this.files[a]=t))},get:function(a){if(this.enabled!==!1&&!Bf(a))return this.files[a]},remove:function(a){delete this.files[a]},clear:function(){this.files={}}};function Bf(a){try{const t=a.slice(a.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class RM{constructor(t,e,i){const n=this;let s=!1,r=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=i,this._abortController=null,this.itemStart=function(h){o++,s===!1&&n.onStart!==void 0&&n.onStart(h,r,o),s=!0},this.itemEnd=function(h){r++,n.onProgress!==void 0&&n.onProgress(h,r,o),r===o&&(s=!1,n.onLoad!==void 0&&n.onLoad())},this.itemError=function(h){n.onError!==void 0&&n.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],p=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return p}return null},this.abort=function(){return this.abortController.abort(),this._abortController=null,this}}get abortController(){return this._abortController||(this._abortController=new AbortController),this._abortController}}const DM=new RM;class Po{constructor(t){this.manager=t!==void 0?t:DM,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 i=this;return new Promise(function(n,s){i.load(t,n,e,s)})}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}}Po.DEFAULT_MATERIAL_NAME="__DEFAULT";const os={};class CM extends Error{constructor(t,e){super(t),this.response=e}}class FE extends Po{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=gs.get(`file:${t}`);if(s!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(s),this.manager.itemEnd(t)},0);return}if(os[t]!==void 0){os[t].push({onLoad:e,onProgress:i,onError:n});return}os[t]=[],os[t].push({onLoad:e,onProgress:i,onError:n});const r=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(r).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&Tt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=os[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 m=new ReadableStream({start(g){_();function _(){u.read().then(({done:w,value:M})=>{if(w)g.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:p,loaded:v,total:f});for(let b=0,T=h.length;b<T;b++){const x=h[b];x.onProgress&&x.onProgress(S)}g.enqueue(M),_()}},w=>{g.error(w)})}}});return new Response(m)}else throw new CM(`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=>{gs.add(`file:${t}`,l);const h=os[t];delete os[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=os[t];if(h===void 0)throw this.manager.itemError(t),l;delete os[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 qa=new WeakMap;class IM extends Po{constructor(t){super(t)}load(t,e,i,n){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=gs.get(`image:${t}`);if(r!==void 0){if(r.complete===!0)s.manager.itemStart(t),setTimeout(function(){e&&e(r),s.manager.itemEnd(t)},0);else{let u=qa.get(r);u===void 0&&(u=[],qa.set(r,u)),u.push({onLoad:e,onError:n})}return r}const o=Ao("img");function c(){h(),e&&e(this);const u=qa.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}qa.delete(this),s.manager.itemEnd(t)}function l(u){h(),n&&n(u),gs.remove(`image:${t}`);const d=qa.get(this)||[];for(let f=0;f<d.length;f++){const p=d[f];p.onError&&p.onError(u)}qa.delete(this),s.manager.itemError(t),s.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),gs.add(`image:${t}`,o),s.manager.itemStart(t),o.src=t,o}}class kE extends Po{constructor(t){super(t)}load(t,e,i,n){const s=new xi,r=new IM(this.manager);return r.setCrossOrigin(this.crossOrigin),r.setPath(this.path),r.load(t,function(o){s.image=o,s.needsUpdate=!0,e!==void 0&&e(s)},i,n),s}}class Tl extends Pe{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new st(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 PM extends Tl{constructor(t,e,i){super(t,i),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.groundColor=new st(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 vh=new Zt,Hf=new D,Gf=new D;class t0{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 Mt(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new Zt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new $d,this._frameExtents=new Mt(1,1),this._viewportCount=1,this._viewports=[new ie(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,i=this.matrix;Hf.setFromMatrixPosition(t.matrixWorld),e.position.copy(Hf),Gf.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(Gf),e.updateMatrixWorld(),vh.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(vh,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Eo||e.reversedDepth?i.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):i.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),i.multiply(vh)}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 gc=new D,vc=new sn,Fn=new D;class Dg extends Pe{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Zt,this.projectionMatrix=new Zt,this.projectionMatrixInverse=new Zt,this.coordinateSystem=Zn,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(gc,vc,Fn),Fn.x===1&&Fn.y===1&&Fn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gc,vc,Fn.set(1,1,1)).invert()}updateWorldMatrix(t,e,i=!1){super.updateWorldMatrix(t,e,i),this.matrixWorld.decompose(gc,vc,Fn),Fn.x===1&&Fn.y===1&&Fn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(gc,vc,Fn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ps=new D,Vf=new Mt,Wf=new Mt;class Vi extends Dg{constructor(t=50,e=1,i=.1,n=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=i,this.far=n,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=_r*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(oo*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return _r*2*Math.atan(Math.tan(oo*.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,i){Ps.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ps.x,Ps.y).multiplyScalar(-t/Ps.z),Ps.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ps.x,Ps.y).multiplyScalar(-t/Ps.z)}getViewSize(t,e){return this.getViewBounds(t,Vf,Wf),e.subVectors(Wf,Vf)}setViewOffset(t,e,i,n,s,r){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=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(oo*.5*this.fov)/this.zoom,i=2*e,n=this.aspect*i,s=-.5*n;const r=this.view;if(this.view!==null&&this.view.enabled){const c=r.fullWidth,l=r.fullHeight;s+=r.offsetX*n/c,e-=r.offsetY*i/l,n*=r.width/c,i*=r.height/l}const o=this.filmOffset;o!==0&&(s+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(s,s+n,e,e-i,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 LM extends t0{constructor(){super(new Vi(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,i=_r*2*t.angle*this.focus,n=this.mapSize.width/this.mapSize.height*this.aspect,s=t.distance||e.far;(i!==e.fov||n!==e.aspect||s!==e.far)&&(e.fov=i,e.aspect=n,e.far=s,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class zE extends Tl{constructor(t,e,i=0,n=Math.PI/3,s=0,r=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.target=new Pe,this.distance=i,this.angle=n,this.penumbra=s,this.decay=r,this.map=null,this.shadow=new LM}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 NM extends t0{constructor(){super(new Vi(90,1,.5,500)),this.isPointLightShadow=!0}}class Cg extends Tl{constructor(t,e,i=0,n=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=i,this.decay=n,this.shadow=new NM}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 In extends Dg{constructor(t=-1,e=1,i=1,n=-1,s=.1,r=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=i,this.bottom=n,this.near=s,this.far=r,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,i,n,s,r){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=i,this.view.offsetY=n,this.view.width=s,this.view.height=r,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,n=(this.top+this.bottom)/2;let s=i-t,r=i+t,o=n+e,c=n-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;s+=l*this.view.offsetX,r=s+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(s,r,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(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 OM extends t0{constructor(){super(new In(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Xf extends Tl{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Pe.DEFAULT_UP),this.updateMatrix(),this.target=new Pe,this.shadow=new OM}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 BE{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 Mh=new WeakMap;class HE extends Po{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&Tt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&Tt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,i,n){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const s=this,r=gs.get(`image-bitmap:${t}`);if(r!==void 0){if(s.manager.itemStart(t),r.then){r.then(l=>{Mh.has(r)===!0?(n&&n(Mh.get(r)),s.manager.itemError(t),s.manager.itemEnd(t)):(e&&e(l),s.manager.itemEnd(t))});return}setTimeout(function(){e&&e(r),s.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(s.options,{colorSpaceConversion:"none"}))}).then(function(l){gs.add(`image-bitmap:${t}`,l),e&&e(l),s.manager.itemEnd(t)}).catch(function(l){n&&n(l),Mh.set(c,l),gs.remove(`image-bitmap:${t}`),s.manager.itemError(t),s.manager.itemEnd(t)});gs.add(`image-bitmap:${t}`,c),s.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const Ya=-90,Ka=1;class e0 extends Pe{constructor(t,e,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const n=new Vi(Ya,Ka,t,e);n.layers=this.layers,this.add(n);const s=new Vi(Ya,Ka,t,e);s.layers=this.layers,this.add(s);const r=new Vi(Ya,Ka,t,e);r.layers=this.layers,this.add(r);const o=new Vi(Ya,Ka,t,e);o.layers=this.layers,this.add(o);const c=new Vi(Ya,Ka,t,e);c.layers=this.layers,this.add(c);const l=new Vi(Ya,Ka,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[i,n,s,r,o,c]=e;for(const l of e)this.remove(l);if(t===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),n.up.set(0,1,0),n.lookAt(-1,0,0),s.up.set(0,0,-1),s.lookAt(0,1,0),r.up.set(0,0,1),r.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===Eo)i.up.set(0,-1,0),i.lookAt(-1,0,0),n.up.set(0,-1,0),n.lookAt(1,0,0),s.up.set(0,0,1),s.lookAt(0,1,0),r.up.set(0,0,-1),r.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:n}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[s,r,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=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(i,0,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,s),t.setRenderTarget(i,1,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(i,2,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(i,3,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(i,4,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),i.texture.generateMipmaps=v,t.setRenderTarget(i,5,n),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class UM extends Vi{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}class FM{constructor(t,e,i){this.binding=t,this.valueSize=i;let n,s,r;switch(e){case"quaternion":n=this._slerp,s=this._slerpAdditive,r=this._setAdditiveIdentityQuaternion,this.buffer=new Float64Array(i*6),this._workIndex=5;break;case"string":case"bool":n=this._select,s=this._select,r=this._setAdditiveIdentityOther,this.buffer=new Array(i*5);break;default:n=this._lerp,s=this._lerpAdditive,r=this._setAdditiveIdentityNumeric,this.buffer=new Float64Array(i*5)}this._mixBufferRegion=n,this._mixBufferRegionAdditive=s,this._setIdentity=r,this._origIndex=3,this._addIndex=4,this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,this.useCount=0,this.referenceCount=0}accumulate(t,e){const i=this.buffer,n=this.valueSize,s=t*n+n;let r=this.cumulativeWeight;if(r===0){for(let o=0;o!==n;++o)i[s+o]=i[o];r=e}else{r+=e;const o=e/r;this._mixBufferRegion(i,s,0,o,n)}this.cumulativeWeight=r}accumulateAdditive(t){const e=this.buffer,i=this.valueSize,n=i*this._addIndex;this.cumulativeWeightAdditive===0&&this._setIdentity(),this._mixBufferRegionAdditive(e,n,0,t,i),this.cumulativeWeightAdditive+=t}apply(t){const e=this.valueSize,i=this.buffer,n=t*e+e,s=this.cumulativeWeight,r=this.cumulativeWeightAdditive,o=this.binding;if(this.cumulativeWeight=0,this.cumulativeWeightAdditive=0,s<1){const c=e*this._origIndex;this._mixBufferRegion(i,n,c,1-s,e)}r>0&&this._mixBufferRegionAdditive(i,n,this._addIndex*e,1,e);for(let c=e,l=e+e;c!==l;++c)if(i[c]!==i[c+e]){o.setValue(i,n);break}}saveOriginalState(){const t=this.binding,e=this.buffer,i=this.valueSize,n=i*this._origIndex;t.getValue(e,n);for(let s=i,r=n;s!==r;++s)e[s]=e[n+s%i];this._setIdentity(),this.cumulativeWeight=0,this.cumulativeWeightAdditive=0}restoreOriginalState(){const t=this.valueSize*3;this.binding.setValue(this.buffer,t)}_setAdditiveIdentityNumeric(){const t=this._addIndex*this.valueSize,e=t+this.valueSize;for(let i=t;i<e;i++)this.buffer[i]=0}_setAdditiveIdentityQuaternion(){this._setAdditiveIdentityNumeric(),this.buffer[this._addIndex*this.valueSize+3]=1}_setAdditiveIdentityOther(){const t=this._origIndex*this.valueSize,e=this._addIndex*this.valueSize;for(let i=0;i<this.valueSize;i++)this.buffer[e+i]=this.buffer[t+i]}_select(t,e,i,n,s){if(n>=.5)for(let r=0;r!==s;++r)t[e+r]=t[i+r]}_slerp(t,e,i,n){sn.slerpFlat(t,e,t,e,t,i,n)}_slerpAdditive(t,e,i,n,s){const r=this._workIndex*s;sn.multiplyQuaternionsFlat(t,r,t,e,t,i),sn.slerpFlat(t,e,t,e,t,r,n)}_lerp(t,e,i,n,s){const r=1-n;for(let o=0;o!==s;++o){const c=e+o;t[c]=t[c]*r+t[i+o]*n}}_lerpAdditive(t,e,i,n,s){for(let r=0;r!==s;++r){const o=e+r;t[o]=t[o]+t[i+r]*n}}}const i0="\\[\\]\\.:\\/",kM=new RegExp("["+i0+"]","g"),n0="[^"+i0+"]",zM="[^"+i0.replace("\\.","")+"]",BM=/((?:WC+[\/:])*)/.source.replace("WC",n0),HM=/(WCOD+)?/.source.replace("WCOD",zM),GM=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",n0),VM=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",n0),WM=new RegExp("^"+BM+HM+GM+VM+"$"),XM=["material","materials","bones","map"];class qM{constructor(t,e,i){const n=i||xe.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,n)}getValue(t,e){this.bind();const i=this._targetGroup.nCachedObjects_,n=this._bindings[i];n!==void 0&&n.getValue(t,e)}setValue(t,e){const i=this._bindings;for(let n=this._targetGroup.nCachedObjects_,s=i.length;n!==s;++n)i[n].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,i=t.length;e!==i;++e)t[e].unbind()}}class xe{constructor(t,e,i){this.path=e,this.parsedPath=i||xe.parseTrackName(e),this.node=xe.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,i){return t&&t.isAnimationObjectGroup?new xe.Composite(t,e,i):new xe(t,e,i)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(kM,"")}static parseTrackName(t){const e=WM.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const i={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},n=i.nodeName&&i.nodeName.lastIndexOf(".");if(n!==void 0&&n!==-1){const s=i.nodeName.substring(n+1);XM.indexOf(s)!==-1&&(i.nodeName=i.nodeName.substring(0,n),i.objectName=s)}if(i.propertyName===null||i.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return i}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const i=t.skeleton.getBoneByName(e);if(i!==void 0)return i}if(t.children){const i=function(s){for(let r=0;r<s.length;r++){const o=s[r];if(o.name===e||o.uuid===e)return o;const c=i(o.children);if(c)return c}return null},n=i(t.children);if(n)return n}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)t[e++]=i[n]}_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 i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const i=this.resolvedProperty;for(let n=0,s=i.length;n!==s;++n)i[n]=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,i=e.objectName,n=e.propertyName;let s=e.propertyIndex;if(t||(t=xe.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){Tt("PropertyBinding: No target node found for track: "+this.path+".");return}if(i){let l=e.objectIndex;switch(i){case"materials":if(!t.material){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){Ht("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){Ht("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){Ht("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){Ht("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[i]===void 0){Ht("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[i]}if(l!==void 0){if(t[l]===void 0){Ht("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const r=t[n];if(r===void 0){const l=e.nodeName;Ht("PropertyBinding: Trying to update property for track: "+l+"."+n+" 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(s!==void 0){if(n==="morphTargetInfluences"){if(!t.geometry){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){Ht("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[s]!==void 0&&(s=t.morphTargetDictionary[s])}c=this.BindingType.ArrayElement,this.resolvedProperty=r,this.propertyIndex=s}else r.fromArray!==void 0&&r.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=r):Array.isArray(r)?(c=this.BindingType.EntireArray,this.resolvedProperty=r):this.propertyName=n;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}xe.Composite=qM;xe.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};xe.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};xe.prototype.GetterByBindingType=[xe.prototype._getValue_direct,xe.prototype._getValue_array,xe.prototype._getValue_arrayElement,xe.prototype._getValue_toArray];xe.prototype.SetterByBindingTypeAndVersioning=[[xe.prototype._setValue_direct,xe.prototype._setValue_direct_setNeedsUpdate,xe.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_array,xe.prototype._setValue_array_setNeedsUpdate,xe.prototype._setValue_array_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_arrayElement,xe.prototype._setValue_arrayElement_setNeedsUpdate,xe.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[xe.prototype._setValue_fromArray,xe.prototype._setValue_fromArray_setNeedsUpdate,xe.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];class YM{constructor(t,e,i=null,n=e.blendMode){this._mixer=t,this._clip=e,this._localRoot=i,this.blendMode=n;const s=e.tracks,r=s.length,o=new Array(r),c={endingStart:ir,endingEnd:ir};for(let l=0;l!==r;++l){const h=s[l].createInterpolant(null);o[l]=h,h.settings=c}this._interpolantSettings=c,this._interpolants=o,this._propertyBindings=new Array(r),this._cacheIndex=null,this._byClipCacheIndex=null,this._timeScaleInterpolant=null,this._restoreTimeScale=null,this._weightInterpolant=null,this.loop=av,this._loopCount=-1,this._startTime=null,this.time=0,this.timeScale=1,this._effectiveTimeScale=1,this.weight=1,this._effectiveWeight=1,this.repetitions=1/0,this.paused=!1,this.enabled=!0,this.clampWhenFinished=!1,this.zeroSlopeAtStart=!0,this.zeroSlopeAtEnd=!0}play(){return this._mixer._activateAction(this),this}stop(){return this._mixer._deactivateAction(this),this.reset()}reset(){return this.paused=!1,this.enabled=!0,this.time=0,this._loopCount=-1,this._startTime=null,this.stopFading().stopWarping()}isRunning(){return this.enabled&&!this.paused&&this.timeScale!==0&&this._startTime===null&&this._mixer._isActiveAction(this)}isScheduled(){return this._mixer._isActiveAction(this)}startAt(t){return this._startTime=t,this}setLoop(t,e){return this.loop=t,this.repetitions=e,this}setEffectiveWeight(t){return this.weight=t,this._effectiveWeight=this.enabled?t:0,this.stopFading()}getEffectiveWeight(){return this._effectiveWeight}fadeIn(t){return this._scheduleFading(t,0,1)}fadeOut(t){return this._scheduleFading(t,1,0)}crossFadeFrom(t,e,i=!1){if(t.fadeOut(e),this.fadeIn(e),i===!0){const n=this._clip.duration,s=t._clip.duration,r=s/n,o=n/s;t._restoreTimeScale=t.timeScale,this._restoreTimeScale=this.timeScale,t.warp(1,r,e),this.warp(o,1,e)}return this}crossFadeTo(t,e,i=!1){return t.crossFadeFrom(this,e,i)}stopFading(){const t=this._weightInterpolant;return t!==null&&(this._weightInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this}setEffectiveTimeScale(t){return this.timeScale=t,this._effectiveTimeScale=this.paused?0:t,this.stopWarping()}getEffectiveTimeScale(){return this._effectiveTimeScale}setDuration(t){return this.timeScale=this._clip.duration/t,this.stopWarping()}syncWith(t){return this.time=t.time,this.timeScale=t.timeScale,this.stopWarping()}halt(t){return this.warp(this._effectiveTimeScale,0,t)}warp(t,e,i){const n=this._mixer,s=n.time,r=this.timeScale;let o=this._timeScaleInterpolant;o===null&&(o=n._lendControlInterpolant(),this._timeScaleInterpolant=o);const c=o.parameterPositions,l=o.sampleValues;return c[0]=s,c[1]=s+i,l[0]=t/r,l[1]=e/r,this}stopWarping(){const t=this._timeScaleInterpolant;return t!==null&&(this._timeScaleInterpolant=null,this._mixer._takeBackControlInterpolant(t)),this._restoreTimeScale=null,this}getMixer(){return this._mixer}getClip(){return this._clip}getRoot(){return this._localRoot||this._mixer._root}_update(t,e,i,n){if(!this.enabled){this._updateWeight(t);return}const s=this._startTime;if(s!==null){const c=(t-s)*i;c<0||i===0?e=0:(this._startTime=null,e=i*c)}e*=this._updateTimeScale(t);const r=this._updateTime(e),o=this._updateWeight(t);if(o>0){const c=this._interpolants,l=this._propertyBindings;switch(this.blendMode){case ov:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(r),l[h].accumulateAdditive(o);break;case Hd:default:for(let h=0,u=c.length;h!==u;++h)c[h].evaluate(r),l[h].accumulate(n,o)}}}_updateWeight(t){let e=0;if(this.enabled){e=this.weight;const i=this._weightInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(this.stopFading(),n===0&&(this.enabled=!1))}}return this._effectiveWeight=e,e}_updateTimeScale(t){let e=0;if(!this.paused){e=this.timeScale;const i=this._timeScaleInterpolant;if(i!==null){const n=i.evaluate(t)[0];e*=n,t>i.parameterPositions[1]&&(e===0?this.paused=!0:(this._restoreTimeScale!==null&&(e=this._restoreTimeScale),this.timeScale=e),this.stopWarping())}}return this._effectiveTimeScale=e,e}_updateTime(t){const e=this._clip.duration,i=this.loop;let n=this.time+t,s=this._loopCount;const r=i===rv;if(t===0)return s===-1?n:r&&(s&1)===1?e-n:n;if(i===dg){s===-1&&(this._loopCount=0,this._setEndings(!0,!0,!1));t:{if(n>=e)n=e;else if(n<0)n=0;else{this.time=n;break t}this.clampWhenFinished?this.paused=!0:this.enabled=!1,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t<0?-1:1})}}else{if(s===-1&&(t>=0?(s=0,this._setEndings(!0,this.repetitions===0,r)):this._setEndings(this.repetitions===0,!0,r)),n>=e||n<0){const o=Math.floor(n/e);n-=e*o,s+=Math.abs(o);const c=this.repetitions-s;if(c<=0)this.clampWhenFinished?this.paused=!0:this.enabled=!1,n=t>0?e:0,this.time=n,this._mixer.dispatchEvent({type:"finished",action:this,direction:t>0?1:-1});else{if(c===1){const l=t<0;this._setEndings(l,!l,r)}else this._setEndings(!1,!1,r);this._loopCount=s,this.time=n,this._mixer.dispatchEvent({type:"loop",action:this,loopDelta:o})}}else this._loopCount=s,this.time=n;if(r&&(s&1)===1)return e-n}return n}_setEndings(t,e,i){const n=this._interpolantSettings;i?(n.endingStart=nr,n.endingEnd=nr):(t?n.endingStart=this.zeroSlopeAtStart?nr:ir:n.endingStart=il,e?n.endingEnd=this.zeroSlopeAtEnd?nr:ir:n.endingEnd=il)}_scheduleFading(t,e,i){const n=this._mixer,s=n.time;let r=this._weightInterpolant;r===null&&(r=n._lendControlInterpolant(),this._weightInterpolant=r);const o=r.parameterPositions,c=r.sampleValues;return o[0]=s,c[0]=e,o[1]=s+t,c[1]=i,this}}const KM=new Float32Array(1);class $M extends Zs{constructor(t){super(),this._root=t,this._initMemoryManager(),this._accuIndex=0,this.time=0,this.timeScale=1,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}_bindAction(t,e){const i=t._localRoot||this._root,n=t._clip.tracks,s=n.length,r=t._propertyBindings,o=t._interpolants,c=i.uuid,l=this._bindingsByRootAndName;let h=l[c];h===void 0&&(h={},l[c]=h);for(let u=0;u!==s;++u){const d=n[u],f=d.name;let p=h[f];if(p!==void 0)++p.referenceCount,r[u]=p;else{if(p=r[u],p!==void 0){p._cacheIndex===null&&(++p.referenceCount,this._addInactiveBinding(p,c,f));continue}const v=e&&e._propertyBindings[u].binding.parsedPath;p=new FM(xe.create(i,f,v),d.ValueTypeName,d.getValueSize()),++p.referenceCount,this._addInactiveBinding(p,c,f),r[u]=p}o[u].resultBuffer=p.buffer}}_activateAction(t){if(!this._isActiveAction(t)){if(t._cacheIndex===null){const i=(t._localRoot||this._root).uuid,n=t._clip.uuid,s=this._actionsByClip[n];this._bindAction(t,s&&s.knownActions[0]),this._addInactiveAction(t,n,i)}const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];s.useCount++===0&&(this._lendBinding(s),s.saveOriginalState())}this._lendAction(t)}}_deactivateAction(t){if(this._isActiveAction(t)){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.useCount===0&&(s.restoreOriginalState(),this._takeBackBinding(s))}this._takeBackAction(t)}}_initMemoryManager(){this._actions=[],this._nActiveActions=0,this._actionsByClip={},this._bindings=[],this._nActiveBindings=0,this._bindingsByRootAndName={},this._controlInterpolants=[],this._nActiveControlInterpolants=0;const t=this;this.stats={actions:{get total(){return t._actions.length},get inUse(){return t._nActiveActions}},bindings:{get total(){return t._bindings.length},get inUse(){return t._nActiveBindings}},controlInterpolants:{get total(){return t._controlInterpolants.length},get inUse(){return t._nActiveControlInterpolants}}}}_isActiveAction(t){const e=t._cacheIndex;return e!==null&&e<this._nActiveActions}_addInactiveAction(t,e,i){const n=this._actions,s=this._actionsByClip;let r=s[e];if(r===void 0)r={knownActions:[t],actionByRoot:{}},t._byClipCacheIndex=0,s[e]=r;else{const o=r.knownActions;t._byClipCacheIndex=o.length,o.push(t)}t._cacheIndex=n.length,n.push(t),r.actionByRoot[i]=t}_removeInactiveAction(t){const e=this._actions,i=e[e.length-1],n=t._cacheIndex;i._cacheIndex=n,e[n]=i,e.pop(),t._cacheIndex=null;const s=t._clip.uuid,r=this._actionsByClip,o=r[s],c=o.knownActions,l=c[c.length-1],h=t._byClipCacheIndex;l._byClipCacheIndex=h,c[h]=l,c.pop(),t._byClipCacheIndex=null;const u=o.actionByRoot,d=(t._localRoot||this._root).uuid;delete u[d],c.length===0&&delete r[s],this._removeInactiveBindingsForAction(t)}_removeInactiveBindingsForAction(t){const e=t._propertyBindings;for(let i=0,n=e.length;i!==n;++i){const s=e[i];--s.referenceCount===0&&this._removeInactiveBinding(s)}}_lendAction(t){const e=this._actions,i=t._cacheIndex,n=this._nActiveActions++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackAction(t){const e=this._actions,i=t._cacheIndex,n=--this._nActiveActions,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_addInactiveBinding(t,e,i){const n=this._bindingsByRootAndName,s=this._bindings;let r=n[e];r===void 0&&(r={},n[e]=r),r[i]=t,t._cacheIndex=s.length,s.push(t)}_removeInactiveBinding(t){const e=this._bindings,i=t.binding,n=i.rootNode.uuid,s=i.path,r=this._bindingsByRootAndName,o=r[n],c=e[e.length-1],l=t._cacheIndex;c._cacheIndex=l,e[l]=c,e.pop(),delete o[s],Object.keys(o).length===0&&delete r[n]}_lendBinding(t){const e=this._bindings,i=t._cacheIndex,n=this._nActiveBindings++,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_takeBackBinding(t){const e=this._bindings,i=t._cacheIndex,n=--this._nActiveBindings,s=e[n];t._cacheIndex=n,e[n]=t,s._cacheIndex=i,e[i]=s}_lendControlInterpolant(){const t=this._controlInterpolants,e=this._nActiveControlInterpolants++;let i=t[e];return i===void 0&&(i=new Ag(new Float32Array(2),new Float32Array(2),1,KM),i.__cacheIndex=e,t[e]=i),i}_takeBackControlInterpolant(t){const e=this._controlInterpolants,i=t.__cacheIndex,n=--this._nActiveControlInterpolants,s=e[n];t.__cacheIndex=n,e[n]=t,s.__cacheIndex=i,e[i]=s}clipAction(t,e,i){const n=e||this._root,s=n.uuid;let r=typeof t=="string"?zf.findByName(n,t):t;const o=r!==null?r.uuid:t,c=this._actionsByClip[o];let l=null;if(i===void 0&&(r!==null?i=r.blendMode:i=Hd),c!==void 0){const u=c.actionByRoot[s];if(u!==void 0&&u.blendMode===i)return u;l=c.knownActions[0],r===null&&(r=l._clip)}if(r===null)return null;const h=new YM(this,r,e,i);return this._bindAction(h,l),this._addInactiveAction(h,o,s),h}existingAction(t,e){const i=e||this._root,n=i.uuid,s=typeof t=="string"?zf.findByName(i,t):t,r=s?s.uuid:t,o=this._actionsByClip[r];return o!==void 0&&o.actionByRoot[n]||null}stopAllAction(){const t=this._actions,e=this._nActiveActions;for(let i=e-1;i>=0;--i)t[i].stop();return this}update(t){t*=this.timeScale;const e=this._actions,i=this._nActiveActions,n=this.time+=t,s=Math.sign(t),r=this._accuIndex^=1;for(let l=0;l!==i;++l)e[l]._update(n,t,s,r);const o=this._bindings,c=this._nActiveBindings;for(let l=0;l!==c;++l)o[l].apply(r);return this}setTime(t){this.time=0;for(let e=0;e<this._actions.length;e++)this._actions[e].time=0;return this.update(t)}getRoot(){return this._root}uncacheClip(t){const e=this._actions,i=t.uuid,n=this._actionsByClip,s=n[i];if(s!==void 0){const r=s.knownActions;for(let o=0,c=r.length;o!==c;++o){const l=r[o];this._deactivateAction(l);const h=l._cacheIndex,u=e[e.length-1];l._cacheIndex=null,l._byClipCacheIndex=null,u._cacheIndex=h,e[h]=u,e.pop(),this._removeInactiveBindingsForAction(l)}delete n[i]}}uncacheRoot(t){const e=t.uuid,i=this._actionsByClip;for(const r in i){const o=i[r].actionByRoot,c=o[e];c!==void 0&&(this._deactivateAction(c),this._removeInactiveAction(c))}const n=this._bindingsByRootAndName,s=n[e];if(s!==void 0)for(const r in s){const o=s[r];o.restoreOriginalState(),this._removeInactiveBinding(o)}}uncacheAction(t,e){const i=this.existingAction(t,e);i!==null&&(this._deactivateAction(i),this._removeInactiveAction(i))}}const qf=new Zt;class xh{constructor(t,e,i=0,n=1/0){this.ray=new Co(t,e),this.near=i,this.far=n,this.camera=null,this.layers=new qd,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):Ht("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return qf.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(qf),this}intersectObject(t,e=!0,i=[]){return Zu(t,this,i,e),i.sort(Yf),i}intersectObjects(t,e=!0,i=[]){for(let n=0,s=t.length;n<s;n++)Zu(t[n],this,i,e);return i.sort(Yf),i}}function Yf(a,t){return a.distance-t.distance}function Zu(a,t,e,i){let n=!0;if(a.layers.test(t.layers)&&a.raycast(t,e)===!1&&(n=!1),n===!0&&i===!0){const s=a.children;for(let r=0,o=s.length;r<o;r++)Zu(s[r],t,e,!0)}}class Ig{static{Ig.prototype.isMatrix2=!0}constructor(t,e,i,n){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,i,n)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let i=0;i<4;i++)this.elements[i]=t[i+e];return this}set(t,e,i,n){const s=this.elements;return s[0]=t,s[2]=e,s[1]=i,s[3]=n,this}}function Kf(a,t,e,i){const n=ZM(i);switch(e){case hg:return a*t;case El:return a*t/n.components*n.byteLength;case kd:return a*t/n.components*n.byteLength;case wa:return a*t*2/n.components*n.byteLength;case zd:return a*t*2/n.components*n.byteLength;case ug:return a*t*3/n.components*n.byteLength;case _i:return a*t*4/n.components*n.byteLength;case Bd:return a*t*4/n.components*n.byteLength;case Bc:case Hc:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*8;case Gc:case Vc:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Mu:case yu:return Math.max(a,16)*Math.max(t,8)/4;case vu:case xu:return Math.max(a,8)*Math.max(t,8)/2;case _u:case Su:case bu:case Eu:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*8;case wu:case Qc:case Au:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Tu:return Math.floor((a+3)/4)*Math.floor((t+3)/4)*16;case Ru:return Math.floor((a+4)/5)*Math.floor((t+3)/4)*16;case Du:return Math.floor((a+4)/5)*Math.floor((t+4)/5)*16;case Cu:return Math.floor((a+5)/6)*Math.floor((t+4)/5)*16;case Iu:return Math.floor((a+5)/6)*Math.floor((t+5)/6)*16;case Pu:return Math.floor((a+7)/8)*Math.floor((t+4)/5)*16;case Lu:return Math.floor((a+7)/8)*Math.floor((t+5)/6)*16;case Nu:return Math.floor((a+7)/8)*Math.floor((t+7)/8)*16;case Ou:return Math.floor((a+9)/10)*Math.floor((t+4)/5)*16;case Uu:return Math.floor((a+9)/10)*Math.floor((t+5)/6)*16;case Fu:return Math.floor((a+9)/10)*Math.floor((t+7)/8)*16;case ku:return Math.floor((a+9)/10)*Math.floor((t+9)/10)*16;case zu:return Math.floor((a+11)/12)*Math.floor((t+9)/10)*16;case Bu:return Math.floor((a+11)/12)*Math.floor((t+11)/12)*16;case Hu:case Gu:case Vu:return Math.ceil(a/4)*Math.ceil(t/4)*16;case Wu:case Xu:return Math.ceil(a/4)*Math.ceil(t/4)*8;case tl:case qu:return Math.ceil(a/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ZM(a){switch(a){case nn:case rg:return{byteLength:1,components:1};case wo:case og:case ze:return{byteLength:2,components:1};case Ud:case Fd:return{byteLength:2,components:4};case vn:case Od:case Di:return{byteLength:4,components:1};case cg:case lg:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${a}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ld}}));typeof window<"u"&&(window.__THREE__?Tt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ld);/**
|
|
705
705
|
* @license
|
|
706
706
|
* Copyright 2010-2026 Three.js Authors
|
|
707
707
|
* SPDX-License-Identifier: MIT
|
|
@@ -4371,7 +4371,7 @@ void main() {
|
|
|
4371
4371
|
#include <tonemapping_fragment>
|
|
4372
4372
|
#include <colorspace_fragment>
|
|
4373
4373
|
#include <fog_fragment>
|
|
4374
|
-
}`,Wt={alphahash_fragment:jM,alphahash_pars_fragment:QM,alphamap_fragment:tx,alphamap_pars_fragment:ex,alphatest_fragment:ix,alphatest_pars_fragment:nx,aomap_fragment:sx,aomap_pars_fragment:ax,batching_pars_vertex:rx,batching_vertex:ox,begin_vertex:cx,beginnormal_vertex:lx,bsdfs:hx,iridescence_fragment:ux,bumpmap_pars_fragment:dx,clipping_planes_fragment:fx,clipping_planes_pars_fragment:px,clipping_planes_pars_vertex:mx,clipping_planes_vertex:gx,color_fragment:vx,color_pars_fragment:Mx,color_pars_vertex:xx,color_vertex:yx,common:_x,cube_uv_reflection_fragment:Sx,defaultnormal_vertex:wx,displacementmap_pars_vertex:bx,displacementmap_vertex:Ex,emissivemap_fragment:Ax,emissivemap_pars_fragment:Tx,colorspace_fragment:Rx,colorspace_pars_fragment:Dx,envmap_fragment:Cx,envmap_common_pars_fragment:Ix,envmap_pars_fragment:Px,envmap_pars_vertex:Lx,envmap_physical_pars_fragment:Wx,envmap_vertex:Nx,fog_vertex:Ox,fog_pars_vertex:Ux,fog_fragment:Fx,fog_pars_fragment:kx,gradientmap_pars_fragment:zx,lightmap_pars_fragment:Bx,lights_lambert_fragment:Hx,lights_lambert_pars_fragment:Gx,lights_pars_begin:Vx,lights_toon_fragment:Xx,lights_toon_pars_fragment:qx,lights_phong_fragment:Yx,lights_phong_pars_fragment:Kx,lights_physical_fragment:$x,lights_physical_pars_fragment:Zx,lights_fragment_begin:Jx,lights_fragment_maps:jx,lights_fragment_end:Qx,lightprobes_pars_fragment:ty,logdepthbuf_fragment:ey,logdepthbuf_pars_fragment:iy,logdepthbuf_pars_vertex:ny,logdepthbuf_vertex:sy,map_fragment:ay,map_pars_fragment:ry,map_particle_fragment:oy,map_particle_pars_fragment:cy,metalnessmap_fragment:ly,metalnessmap_pars_fragment:hy,morphinstance_vertex:uy,morphcolor_vertex:dy,morphnormal_vertex:fy,morphtarget_pars_vertex:py,morphtarget_vertex:my,normal_fragment_begin:gy,normal_fragment_maps:vy,normal_pars_fragment:My,normal_pars_vertex:xy,normal_vertex:yy,normalmap_pars_fragment:_y,clearcoat_normal_fragment_begin:Sy,clearcoat_normal_fragment_maps:wy,clearcoat_pars_fragment:by,iridescence_pars_fragment:Ey,opaque_fragment:Ay,packing:Ty,premultiplied_alpha_fragment:Ry,project_vertex:Dy,dithering_fragment:Cy,dithering_pars_fragment:Iy,roughnessmap_fragment:Py,roughnessmap_pars_fragment:Ly,shadowmap_pars_fragment:Ny,shadowmap_pars_vertex:Oy,shadowmap_vertex:Uy,shadowmask_pars_fragment:Fy,skinbase_vertex:ky,skinning_pars_vertex:zy,skinning_vertex:By,skinnormal_vertex:Hy,specularmap_fragment:Gy,specularmap_pars_fragment:Vy,tonemapping_fragment:Wy,tonemapping_pars_fragment:Xy,transmission_fragment:qy,transmission_pars_fragment:Yy,uv_pars_fragment:Ky,uv_pars_vertex:$y,uv_vertex:Zy,worldpos_vertex:Jy,background_vert:jy,background_frag:Qy,backgroundCube_vert:t3,backgroundCube_frag:e3,cube_vert:i3,cube_frag:n3,depth_vert:s3,depth_frag:a3,distance_vert:r3,distance_frag:o3,equirect_vert:c3,equirect_frag:l3,linedashed_vert:h3,linedashed_frag:u3,meshbasic_vert:d3,meshbasic_frag:f3,meshlambert_vert:p3,meshlambert_frag:m3,meshmatcap_vert:g3,meshmatcap_frag:v3,meshnormal_vert:M3,meshnormal_frag:x3,meshphong_vert:y3,meshphong_frag:_3,meshphysical_vert:S3,meshphysical_frag:w3,meshtoon_vert:b3,meshtoon_frag:E3,points_vert:A3,points_frag:T3,shadow_vert:R3,shadow_frag:D3,sprite_vert:C3,sprite_frag:I3},pt={common:{diffuse:{value:new st(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xt}},envmap:{envMap:{value:null},envMapRotation:{value:new Xt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xt},normalScale:{value:new Mt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new st(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new st(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0},uvTransform:{value:new Xt}},sprite:{diffuse:{value:new st(16777215)},opacity:{value:1},center:{value:new Mt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}}},Wn={basic:{uniforms:Pi([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:Pi([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 st(0)},envMapIntensity:{value:1}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:Pi([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 st(0)},specular:{value:new st(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:Pi([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 st(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:Pi([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new st(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:Pi([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:Pi([pt.points,pt.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:Pi([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:Pi([pt.common,pt.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:Pi([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:Pi([pt.sprite,pt.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Wt.background_vert,fragmentShader:Wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xt}},vertexShader:Wt.backgroundCube_vert,fragmentShader:Wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Wt.cube_vert,fragmentShader:Wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Wt.equirect_vert,fragmentShader:Wt.equirect_frag},distance:{uniforms:Pi([pt.common,pt.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distance_vert,fragmentShader:Wt.distance_frag},shadow:{uniforms:Pi([pt.lights,pt.fog,{color:{value:new st(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};Wn.physical={uniforms:Pi([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xt},clearcoatNormalScale:{value:new Mt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xt},sheen:{value:0},sheenColor:{value:new st(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xt},transmissionSamplerSize:{value:new Mt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xt},attenuationDistance:{value:0},attenuationColor:{value:new st(0)},specularColor:{value:new st(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xt},anisotropyVector:{value:new Mt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const Mc={r:0,b:0,g:0},P3=new Zt,Lg=new Xt;Lg.set(-1,0,0,0,1,0,0,0,1);function L3(a,t,e,i,n,s){const r=new st(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(_){let w=_.isScene===!0?_.background:null;if(w&&w.isTexture){const M=_.backgroundBlurriness>0;w=t.get(w,M)}return w}function p(_){let w=!1;const M=f(_);M===null?m(r,o):M&&M.isColor&&(m(M,1),w=!0);const S=a.xr.getEnvironmentBlendMode();S==="additive"?e.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(a.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function v(_,w){const M=f(w);M&&(M.isCubeTexture||M.mapping===bl)?(l===void 0&&(l=new Dt(new an(1,1,1),new ae({name:"BackgroundCubeMaterial",uniforms:Sr(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Ue,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,b,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(P3.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Lg),l.material.toneMapped=ne.getTransfer(M.colorSpace)!==ve,(h!==M||u!==M.version||d!==a.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),l.layers.enableAll(),_.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Dt(new ki(2,2),new ae({name:"BackgroundMaterial",uniforms:Sr(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:Ys,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=ne.getTransfer(M.colorSpace)!==ve,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==a.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function m(_,w){_.getRGB(Mc,bg(a)),e.buffers.color.setClear(Mc.r,Mc.g,Mc.b,w,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(_,w=1){r.set(_),o=w,m(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(_){o=_,m(r,o)},render:p,addToRenderList:v,dispose:g}}function N3(a,t){const e=a.getParameter(a.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function o(C,P,X,z,N){let V=!1;const k=u(C,z,X,P);s!==k&&(s=k,l(s.object)),V=f(C,z,X,N),V&&p(C,z,X,N),N!==null&&t.update(N,a.ELEMENT_ARRAY_BUFFER),(V||r)&&(r=!1,M(C,P,X,z),N!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,t.get(N).buffer))}function c(){return a.createVertexArray()}function l(C){return a.bindVertexArray(C)}function h(C){return a.deleteVertexArray(C)}function u(C,P,X,z){const N=z.wireframe===!0;let V=i[P.id];V===void 0&&(V={},i[P.id]=V);const k=C.isInstancedMesh===!0?C.id:0;let K=V[k];K===void 0&&(K={},V[k]=K);let tt=K[X.id];tt===void 0&&(tt={},K[X.id]=tt);let J=tt[N];return J===void 0&&(J=d(c()),tt[N]=J),J}function d(C){const P=[],X=[],z=[];for(let N=0;N<e;N++)P[N]=0,X[N]=0,z[N]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:P,enabledAttributes:X,attributeDivisors:z,object:C,attributes:{},index:null}}function f(C,P,X,z){const N=s.attributes,V=P.attributes;let k=0;const K=X.getAttributes();for(const tt in K)if(K[tt].location>=0){const it=N[tt];let ot=V[tt];if(ot===void 0&&(tt==="instanceMatrix"&&C.instanceMatrix&&(ot=C.instanceMatrix),tt==="instanceColor"&&C.instanceColor&&(ot=C.instanceColor)),it===void 0||it.attribute!==ot||ot&&it.data!==ot.data)return!0;k++}return s.attributesNum!==k||s.index!==z}function p(C,P,X,z){const N={},V=P.attributes;let k=0;const K=X.getAttributes();for(const tt in K)if(K[tt].location>=0){let it=V[tt];it===void 0&&(tt==="instanceMatrix"&&C.instanceMatrix&&(it=C.instanceMatrix),tt==="instanceColor"&&C.instanceColor&&(it=C.instanceColor));const ot={};ot.attribute=it,it&&it.data&&(ot.data=it.data),N[tt]=ot,k++}s.attributes=N,s.attributesNum=k,s.index=z}function v(){const C=s.newAttributes;for(let P=0,X=C.length;P<X;P++)C[P]=0}function m(C){g(C,0)}function g(C,P){const X=s.newAttributes,z=s.enabledAttributes,N=s.attributeDivisors;X[C]=1,z[C]===0&&(a.enableVertexAttribArray(C),z[C]=1),N[C]!==P&&(a.vertexAttribDivisor(C,P),N[C]=P)}function _(){const C=s.newAttributes,P=s.enabledAttributes;for(let X=0,z=P.length;X<z;X++)P[X]!==C[X]&&(a.disableVertexAttribArray(X),P[X]=0)}function w(C,P,X,z,N,V,k){k===!0?a.vertexAttribIPointer(C,P,X,N,V):a.vertexAttribPointer(C,P,X,z,N,V)}function M(C,P,X,z){v();const N=z.attributes,V=X.getAttributes(),k=P.defaultAttributeValues;for(const K in V){const tt=V[K];if(tt.location>=0){let J=N[K];if(J===void 0&&(K==="instanceMatrix"&&C.instanceMatrix&&(J=C.instanceMatrix),K==="instanceColor"&&C.instanceColor&&(J=C.instanceColor)),J!==void 0){const it=J.normalized,ot=J.itemSize,Vt=t.get(J);if(Vt===void 0)continue;const Qt=Vt.buffer,qt=Vt.type,Y=Vt.bytesPerElement,rt=qt===a.INT||qt===a.UNSIGNED_INT||J.gpuType===Od;if(J.isInterleavedBufferAttribute){const nt=J.data,B=nt.stride,At=J.offset;if(nt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<tt.locationSize;Nt++)g(tt.location+Nt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Nt=0;Nt<tt.locationSize;Nt++)m(tt.location+Nt);a.bindBuffer(a.ARRAY_BUFFER,Qt);for(let Nt=0;Nt<tt.locationSize;Nt++)w(tt.location+Nt,ot/tt.locationSize,qt,it,B*Y,(At+ot/tt.locationSize*Nt)*Y,rt)}else{if(J.isInstancedBufferAttribute){for(let nt=0;nt<tt.locationSize;nt++)g(tt.location+nt,J.meshPerAttribute);C.isInstancedMesh!==!0&&z._maxInstanceCount===void 0&&(z._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let nt=0;nt<tt.locationSize;nt++)m(tt.location+nt);a.bindBuffer(a.ARRAY_BUFFER,Qt);for(let nt=0;nt<tt.locationSize;nt++)w(tt.location+nt,ot/tt.locationSize,qt,it,ot*Y,ot/tt.locationSize*nt*Y,rt)}}else if(k!==void 0){const it=k[K];if(it!==void 0)switch(it.length){case 2:a.vertexAttrib2fv(tt.location,it);break;case 3:a.vertexAttrib3fv(tt.location,it);break;case 4:a.vertexAttrib4fv(tt.location,it);break;default:a.vertexAttrib1fv(tt.location,it)}}}}_()}function S(){A();for(const C in i){const P=i[C];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C]}}function b(C){if(i[C.id]===void 0)return;const P=i[C.id];for(const X in P){const z=P[X];for(const N in z){const V=z[N];for(const k in V)h(V[k].object),delete V[k];delete z[N]}}delete i[C.id]}function T(C){for(const P in i){const X=i[P];for(const z in X){const N=X[z];if(N[C.id]===void 0)continue;const V=N[C.id];for(const k in V)h(V[k].object),delete V[k];delete N[C.id]}}}function x(C){for(const P in i){const X=i[P],z=C.isInstancedMesh===!0?C.id:0,N=X[z];if(N!==void 0){for(const V in N){const k=N[V];for(const K in k)h(k[K].object),delete k[K];delete N[V]}delete X[z],Object.keys(X).length===0&&delete i[P]}}}function A(){I(),r=!0,s!==n&&(s=n,l(s.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:_}}function O3(a,t,e){let i;function n(c){i=c}function s(c,l){a.drawArrays(i,c,l),e.update(l,i,1)}function r(c,l,h){h!==0&&(a.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=o}function U3(a,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const T=t.get("EXT_texture_filter_anisotropic");n=a.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(T){return!(T!==_i&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===ze&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(T!==nn&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Di&&!x)}function c(T){if(T==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Tt("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&&Tt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),p=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=a.getParameter(a.MAX_TEXTURE_SIZE),m=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),g=a.getParameter(a.MAX_VERTEX_ATTRIBS),_=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),w=a.getParameter(a.MAX_VARYING_VECTORS),M=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),S=a.getParameter(a.MAX_SAMPLES),b=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:_,maxVaryings:w,maxFragmentUniforms:M,maxSamples:S,samples:b}}function F3(a){const t=this;let e=null,i=0,n=!1,s=!1;const r=new ra,o=new Xt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=a.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const _=s?0:i,w=_*4;let M=g.clippingState||null;c.value=M,M=h(p,d,w,f);for(let S=0;S!==w;++S)M[S]=e[S];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,_=d.matrixWorldInverse;o.getNormalMatrix(_),(m===null||m.length<g)&&(m=new Float32Array(g));for(let w=0,M=f;w!==v;++w,M+=4)r.copy(u[w]).applyMatrix4(_,o),r.normal.toArray(m,M),m[M+3]=r.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}const Hs=4,$f=[.125,.215,.35,.446,.526,.582],ha=20,k3=256,Gr=new In,Zf=new st;let yh=null,_h=0,Sh=0,wh=!1;const z3=new D;class Ju{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,i=.1,n=100,s={}){const{size:r=256,position:o=z3}=s;yh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),Sh=this._renderer.getActiveMipmapLevel(),wh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,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=Qf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jf(),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(yh,_h,Sh),this._renderer.xr.enabled=wh,t.scissorTest=!1,$a(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Sa||t.mapping===yr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),yh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),Sh=this._renderer.getActiveMipmapLevel(),wh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:se,minFilter:se,generateMipmaps:!1,type:ze,format:_i,colorSpace:sl,depthBuffer:!1},n=Jf(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Jf(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=B3(s)),this._blurMaterial=G3(s,t,e),this._ggxMaterial=H3(s,t,e)}return n}_compileMaterial(t){const e=new Dt(new ue,t);this._renderer.compile(e,Gr)}_sceneToCubeUV(t,e,i,n,s){const c=new Vi(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Zf),u.toneMapping=Qn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Dt(new an,new gn({name:"PMREM.Background",side:Ue,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const _=t.background;_?_.isColor&&(m.color.copy(_),t.background=null,g=!0):(m.color.copy(Zf),g=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const S=this._cubeSize;$a(n,M*S,w>2?S:0,S,S),u.setRenderTarget(n),g&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=_}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===Sa||t.mapping===yr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qf()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jf());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const o=s.uniforms;o.envMap.value=t;const c=this._cubeSize;$a(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(r,Gr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[i];o.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=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[i],m=3*v*(i>p-Hs?i-p+Hs:0),g=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,$a(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,Gr),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,$a(t,m,g,3*v,2*v),n.setRenderTarget(t),n.render(o,Gr)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,o){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Ht("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ha-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ha;m>ha&&Tt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ha}`);const g=[];let _=0;for(let T=0;T<ha;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?_+=A:T<m&&(_+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const M=this._sizeLods[n],S=3*M*(n>w-Hs?n-w+Hs:0),b=4*(this._cubeSize-M);$a(e,S,b,3*M,2*M),c.setRenderTarget(e),c.render(u,Gr)}}function B3(a){const t=[],e=[],i=[];let n=a;const s=a-Hs+1+$f.length;for(let r=0;r<s;r++){const o=Math.pow(2,n);t.push(o);let c=1/o;r>a-Hs?c=$f[r-a+Hs-1]:r===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,m=2,g=1,_=new Float32Array(v*p*f),w=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let b=0;b<f;b++){const T=b%3*2/3-1,x=b>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];_.set(A,v*p*b),w.set(d,m*p*b);const I=[b,b,b,b,b,b];M.set(I,g*p*b)}const S=new ue;S.setAttribute("position",new te(_,v)),S.setAttribute("uv",new te(w,m)),S.setAttribute("faceIndex",new te(M,g)),i.push(new Dt(S,null)),n>Hs&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Jf(a,t,e){const i=new je(a,t,e);return i.texture.mapping=bl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function $a(a,t,e,i,n){a.viewport.set(t,e,i,n),a.scissor.set(t,e,i,n)}function H3(a,t,e){return new ae({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:k3,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Rl(),fragmentShader:`
|
|
4374
|
+
}`,Wt={alphahash_fragment:jM,alphahash_pars_fragment:QM,alphamap_fragment:tx,alphamap_pars_fragment:ex,alphatest_fragment:ix,alphatest_pars_fragment:nx,aomap_fragment:sx,aomap_pars_fragment:ax,batching_pars_vertex:rx,batching_vertex:ox,begin_vertex:cx,beginnormal_vertex:lx,bsdfs:hx,iridescence_fragment:ux,bumpmap_pars_fragment:dx,clipping_planes_fragment:fx,clipping_planes_pars_fragment:px,clipping_planes_pars_vertex:mx,clipping_planes_vertex:gx,color_fragment:vx,color_pars_fragment:Mx,color_pars_vertex:xx,color_vertex:yx,common:_x,cube_uv_reflection_fragment:Sx,defaultnormal_vertex:wx,displacementmap_pars_vertex:bx,displacementmap_vertex:Ex,emissivemap_fragment:Ax,emissivemap_pars_fragment:Tx,colorspace_fragment:Rx,colorspace_pars_fragment:Dx,envmap_fragment:Cx,envmap_common_pars_fragment:Ix,envmap_pars_fragment:Px,envmap_pars_vertex:Lx,envmap_physical_pars_fragment:Wx,envmap_vertex:Nx,fog_vertex:Ox,fog_pars_vertex:Ux,fog_fragment:Fx,fog_pars_fragment:kx,gradientmap_pars_fragment:zx,lightmap_pars_fragment:Bx,lights_lambert_fragment:Hx,lights_lambert_pars_fragment:Gx,lights_pars_begin:Vx,lights_toon_fragment:Xx,lights_toon_pars_fragment:qx,lights_phong_fragment:Yx,lights_phong_pars_fragment:Kx,lights_physical_fragment:$x,lights_physical_pars_fragment:Zx,lights_fragment_begin:Jx,lights_fragment_maps:jx,lights_fragment_end:Qx,lightprobes_pars_fragment:ty,logdepthbuf_fragment:ey,logdepthbuf_pars_fragment:iy,logdepthbuf_pars_vertex:ny,logdepthbuf_vertex:sy,map_fragment:ay,map_pars_fragment:ry,map_particle_fragment:oy,map_particle_pars_fragment:cy,metalnessmap_fragment:ly,metalnessmap_pars_fragment:hy,morphinstance_vertex:uy,morphcolor_vertex:dy,morphnormal_vertex:fy,morphtarget_pars_vertex:py,morphtarget_vertex:my,normal_fragment_begin:gy,normal_fragment_maps:vy,normal_pars_fragment:My,normal_pars_vertex:xy,normal_vertex:yy,normalmap_pars_fragment:_y,clearcoat_normal_fragment_begin:Sy,clearcoat_normal_fragment_maps:wy,clearcoat_pars_fragment:by,iridescence_pars_fragment:Ey,opaque_fragment:Ay,packing:Ty,premultiplied_alpha_fragment:Ry,project_vertex:Dy,dithering_fragment:Cy,dithering_pars_fragment:Iy,roughnessmap_fragment:Py,roughnessmap_pars_fragment:Ly,shadowmap_pars_fragment:Ny,shadowmap_pars_vertex:Oy,shadowmap_vertex:Uy,shadowmask_pars_fragment:Fy,skinbase_vertex:ky,skinning_pars_vertex:zy,skinning_vertex:By,skinnormal_vertex:Hy,specularmap_fragment:Gy,specularmap_pars_fragment:Vy,tonemapping_fragment:Wy,tonemapping_pars_fragment:Xy,transmission_fragment:qy,transmission_pars_fragment:Yy,uv_pars_fragment:Ky,uv_pars_vertex:$y,uv_vertex:Zy,worldpos_vertex:Jy,background_vert:jy,background_frag:Qy,backgroundCube_vert:t3,backgroundCube_frag:e3,cube_vert:i3,cube_frag:n3,depth_vert:s3,depth_frag:a3,distance_vert:r3,distance_frag:o3,equirect_vert:c3,equirect_frag:l3,linedashed_vert:h3,linedashed_frag:u3,meshbasic_vert:d3,meshbasic_frag:f3,meshlambert_vert:p3,meshlambert_frag:m3,meshmatcap_vert:g3,meshmatcap_frag:v3,meshnormal_vert:M3,meshnormal_frag:x3,meshphong_vert:y3,meshphong_frag:_3,meshphysical_vert:S3,meshphysical_frag:w3,meshtoon_vert:b3,meshtoon_frag:E3,points_vert:A3,points_frag:T3,shadow_vert:R3,shadow_frag:D3,sprite_vert:C3,sprite_frag:I3},pt={common:{diffuse:{value:new st(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Xt}},envmap:{envMap:{value:null},envMapRotation:{value:new Xt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Xt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Xt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Xt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Xt},normalScale:{value:new Mt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Xt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Xt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Xt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Xt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new st(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new D},probesMax:{value:new D},probesResolution:{value:new D}},points:{diffuse:{value:new st(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0},uvTransform:{value:new Xt}},sprite:{diffuse:{value:new st(16777215)},opacity:{value:1},center:{value:new Mt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Xt},alphaMap:{value:null},alphaMapTransform:{value:new Xt},alphaTest:{value:0}}},Wn={basic:{uniforms:Pi([pt.common,pt.specularmap,pt.envmap,pt.aomap,pt.lightmap,pt.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:Pi([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 st(0)},envMapIntensity:{value:1}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:Pi([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 st(0)},specular:{value:new st(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:Pi([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 st(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:Pi([pt.common,pt.aomap,pt.lightmap,pt.emissivemap,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.gradientmap,pt.fog,pt.lights,{emissive:{value:new st(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:Pi([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,pt.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:Pi([pt.points,pt.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:Pi([pt.common,pt.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:Pi([pt.common,pt.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:Pi([pt.common,pt.bumpmap,pt.normalmap,pt.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:Pi([pt.sprite,pt.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Xt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Wt.background_vert,fragmentShader:Wt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Xt}},vertexShader:Wt.backgroundCube_vert,fragmentShader:Wt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Wt.cube_vert,fragmentShader:Wt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Wt.equirect_vert,fragmentShader:Wt.equirect_frag},distance:{uniforms:Pi([pt.common,pt.displacementmap,{referencePosition:{value:new D},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distance_vert,fragmentShader:Wt.distance_frag},shadow:{uniforms:Pi([pt.lights,pt.fog,{color:{value:new st(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};Wn.physical={uniforms:Pi([Wn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Xt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Xt},clearcoatNormalScale:{value:new Mt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Xt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Xt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Xt},sheen:{value:0},sheenColor:{value:new st(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Xt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Xt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Xt},transmissionSamplerSize:{value:new Mt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Xt},attenuationDistance:{value:0},attenuationColor:{value:new st(0)},specularColor:{value:new st(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Xt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Xt},anisotropyVector:{value:new Mt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Xt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const Mc={r:0,b:0,g:0},P3=new Zt,Lg=new Xt;Lg.set(-1,0,0,0,1,0,0,0,1);function L3(a,t,e,i,n,s){const r=new st(0);let o=n===!0?0:1,c,l,h=null,u=0,d=null;function f(_){let w=_.isScene===!0?_.background:null;if(w&&w.isTexture){const M=_.backgroundBlurriness>0;w=t.get(w,M)}return w}function p(_){let w=!1;const M=f(_);M===null?m(r,o):M&&M.isColor&&(m(M,1),w=!0);const S=a.xr.getEnvironmentBlendMode();S==="additive"?e.buffers.color.setClear(0,0,0,1,s):S==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,s),(a.autoClear||w)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),a.clear(a.autoClearColor,a.autoClearDepth,a.autoClearStencil))}function v(_,w){const M=f(w);M&&(M.isCubeTexture||M.mapping===bl)?(l===void 0&&(l=new Dt(new an(1,1,1),new ae({name:"BackgroundCubeMaterial",uniforms:Sr(Wn.backgroundCube.uniforms),vertexShader:Wn.backgroundCube.vertexShader,fragmentShader:Wn.backgroundCube.fragmentShader,side:Ue,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,b,T){this.matrixWorld.copyPosition(T.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=w.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(P3.makeRotationFromEuler(w.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Lg),l.material.toneMapped=ne.getTransfer(M.colorSpace)!==ve,(h!==M||u!==M.version||d!==a.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),l.layers.enableAll(),_.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new Dt(new ki(2,2),new ae({name:"BackgroundMaterial",uniforms:Sr(Wn.background.uniforms),vertexShader:Wn.background.vertexShader,fragmentShader:Wn.background.fragmentShader,side:Ys,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=w.backgroundIntensity,c.material.toneMapped=ne.getTransfer(M.colorSpace)!==ve,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==a.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=a.toneMapping),c.layers.enableAll(),_.unshift(c,c.geometry,c.material,0,0,null))}function m(_,w){_.getRGB(Mc,bg(a)),e.buffers.color.setClear(Mc.r,Mc.g,Mc.b,w,s)}function g(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return r},setClearColor:function(_,w=1){r.set(_),o=w,m(r,o)},getClearAlpha:function(){return o},setClearAlpha:function(_){o=_,m(r,o)},render:p,addToRenderList:v,dispose:g}}function N3(a,t){const e=a.getParameter(a.MAX_VERTEX_ATTRIBS),i={},n=d(null);let s=n,r=!1;function o(C,L,W,X,P){let B=!1;const k=u(C,X,W,L);s!==k&&(s=k,l(s.object)),B=f(C,X,W,P),B&&p(C,X,W,P),P!==null&&t.update(P,a.ELEMENT_ARRAY_BUFFER),(B||r)&&(r=!1,M(C,L,W,X),P!==null&&a.bindBuffer(a.ELEMENT_ARRAY_BUFFER,t.get(P).buffer))}function c(){return a.createVertexArray()}function l(C){return a.bindVertexArray(C)}function h(C){return a.deleteVertexArray(C)}function u(C,L,W,X){const P=X.wireframe===!0;let B=i[L.id];B===void 0&&(B={},i[L.id]=B);const k=C.isInstancedMesh===!0?C.id:0;let K=B[k];K===void 0&&(K={},B[k]=K);let tt=K[W.id];tt===void 0&&(tt={},K[W.id]=tt);let J=tt[P];return J===void 0&&(J=d(c()),tt[P]=J),J}function d(C){const L=[],W=[],X=[];for(let P=0;P<e;P++)L[P]=0,W[P]=0,X[P]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function f(C,L,W,X){const P=s.attributes,B=L.attributes;let k=0;const K=W.getAttributes();for(const tt in K)if(K[tt].location>=0){const it=P[tt];let rt=B[tt];if(rt===void 0&&(tt==="instanceMatrix"&&C.instanceMatrix&&(rt=C.instanceMatrix),tt==="instanceColor"&&C.instanceColor&&(rt=C.instanceColor)),it===void 0||it.attribute!==rt||rt&&it.data!==rt.data)return!0;k++}return s.attributesNum!==k||s.index!==X}function p(C,L,W,X){const P={},B=L.attributes;let k=0;const K=W.getAttributes();for(const tt in K)if(K[tt].location>=0){let it=B[tt];it===void 0&&(tt==="instanceMatrix"&&C.instanceMatrix&&(it=C.instanceMatrix),tt==="instanceColor"&&C.instanceColor&&(it=C.instanceColor));const rt={};rt.attribute=it,it&&it.data&&(rt.data=it.data),P[tt]=rt,k++}s.attributes=P,s.attributesNum=k,s.index=X}function v(){const C=s.newAttributes;for(let L=0,W=C.length;L<W;L++)C[L]=0}function m(C){g(C,0)}function g(C,L){const W=s.newAttributes,X=s.enabledAttributes,P=s.attributeDivisors;W[C]=1,X[C]===0&&(a.enableVertexAttribArray(C),X[C]=1),P[C]!==L&&(a.vertexAttribDivisor(C,L),P[C]=L)}function _(){const C=s.newAttributes,L=s.enabledAttributes;for(let W=0,X=L.length;W<X;W++)L[W]!==C[W]&&(a.disableVertexAttribArray(W),L[W]=0)}function w(C,L,W,X,P,B,k){k===!0?a.vertexAttribIPointer(C,L,W,P,B):a.vertexAttribPointer(C,L,W,X,P,B)}function M(C,L,W,X){v();const P=X.attributes,B=W.getAttributes(),k=L.defaultAttributeValues;for(const K in B){const tt=B[K];if(tt.location>=0){let J=P[K];if(J===void 0&&(K==="instanceMatrix"&&C.instanceMatrix&&(J=C.instanceMatrix),K==="instanceColor"&&C.instanceColor&&(J=C.instanceColor)),J!==void 0){const it=J.normalized,rt=J.itemSize,Gt=t.get(J);if(Gt===void 0)continue;const Jt=Gt.buffer,qt=Gt.type,Y=Gt.bytesPerElement,at=qt===a.INT||qt===a.UNSIGNED_INT||J.gpuType===Od;if(J.isInterleavedBufferAttribute){const nt=J.data,z=nt.stride,At=J.offset;if(nt.isInstancedInterleavedBuffer){for(let Nt=0;Nt<tt.locationSize;Nt++)g(tt.location+Nt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Nt=0;Nt<tt.locationSize;Nt++)m(tt.location+Nt);a.bindBuffer(a.ARRAY_BUFFER,Jt);for(let Nt=0;Nt<tt.locationSize;Nt++)w(tt.location+Nt,rt/tt.locationSize,qt,it,z*Y,(At+rt/tt.locationSize*Nt)*Y,at)}else{if(J.isInstancedBufferAttribute){for(let nt=0;nt<tt.locationSize;nt++)g(tt.location+nt,J.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=J.meshPerAttribute*J.count)}else for(let nt=0;nt<tt.locationSize;nt++)m(tt.location+nt);a.bindBuffer(a.ARRAY_BUFFER,Jt);for(let nt=0;nt<tt.locationSize;nt++)w(tt.location+nt,rt/tt.locationSize,qt,it,rt*Y,rt/tt.locationSize*nt*Y,at)}}else if(k!==void 0){const it=k[K];if(it!==void 0)switch(it.length){case 2:a.vertexAttrib2fv(tt.location,it);break;case 3:a.vertexAttrib3fv(tt.location,it);break;case 4:a.vertexAttrib4fv(tt.location,it);break;default:a.vertexAttrib1fv(tt.location,it)}}}}_()}function S(){A();for(const C in i){const L=i[C];for(const W in L){const X=L[W];for(const P in X){const B=X[P];for(const k in B)h(B[k].object),delete B[k];delete X[P]}}delete i[C]}}function b(C){if(i[C.id]===void 0)return;const L=i[C.id];for(const W in L){const X=L[W];for(const P in X){const B=X[P];for(const k in B)h(B[k].object),delete B[k];delete X[P]}}delete i[C.id]}function T(C){for(const L in i){const W=i[L];for(const X in W){const P=W[X];if(P[C.id]===void 0)continue;const B=P[C.id];for(const k in B)h(B[k].object),delete B[k];delete P[C.id]}}}function x(C){for(const L in i){const W=i[L],X=C.isInstancedMesh===!0?C.id:0,P=W[X];if(P!==void 0){for(const B in P){const k=P[B];for(const K in k)h(k[K].object),delete k[K];delete P[B]}delete W[X],Object.keys(W).length===0&&delete i[L]}}}function A(){I(),r=!0,s!==n&&(s=n,l(s.object))}function I(){n.geometry=null,n.program=null,n.wireframe=!1}return{setup:o,reset:A,resetDefaultState:I,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:x,releaseStatesOfProgram:T,initAttributes:v,enableAttribute:m,disableUnusedAttributes:_}}function O3(a,t,e){let i;function n(c){i=c}function s(c,l){a.drawArrays(i,c,l),e.update(l,i,1)}function r(c,l,h){h!==0&&(a.drawArraysInstanced(i,c,l,h),e.update(l,i,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(i,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,i,1)}this.setMode=n,this.render=s,this.renderInstances=r,this.renderMultiDraw=o}function U3(a,t,e,i){let n;function s(){if(n!==void 0)return n;if(t.has("EXT_texture_filter_anisotropic")===!0){const T=t.get("EXT_texture_filter_anisotropic");n=a.getParameter(T.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else n=0;return n}function r(T){return!(T!==_i&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(T){const x=T===ze&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(T!==nn&&i.convert(T)!==a.getParameter(a.IMPLEMENTATION_COLOR_READ_TYPE)&&T!==Di&&!x)}function c(T){if(T==="highp"){if(a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision>0)return"highp";T="mediump"}return T==="mediump"&&a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision>0&&a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Tt("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&&Tt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),p=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=a.getParameter(a.MAX_TEXTURE_SIZE),m=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE),g=a.getParameter(a.MAX_VERTEX_ATTRIBS),_=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS),w=a.getParameter(a.MAX_VARYING_VECTORS),M=a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS),S=a.getParameter(a.MAX_SAMPLES),b=a.getParameter(a.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:s,getMaxPrecision:c,textureFormatReadable:r,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:p,maxTextureSize:v,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:_,maxVaryings:w,maxFragmentUniforms:M,maxSamples:S,samples:b}}function F3(a){const t=this;let e=null,i=0,n=!1,s=!1;const r=new ra,o=new Xt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||i!==0||n;return n=d,i=u.length,f},this.beginShadows=function(){s=!0,h(null)},this.endShadows=function(){s=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const p=u.clippingPlanes,v=u.clipIntersection,m=u.clipShadows,g=a.get(u);if(!n||p===null||p.length===0||s&&!m)s?h(null):l();else{const _=s?0:i,w=_*4;let M=g.clippingState||null;c.value=M,M=h(p,d,w,f);for(let S=0;S!==w;++S)M[S]=e[S];g.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=_}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=i>0),t.numPlanes=i,t.numIntersection=0}function h(u,d,f,p){const v=u!==null?u.length:0;let m=null;if(v!==0){if(m=c.value,p!==!0||m===null){const g=f+v*4,_=d.matrixWorldInverse;o.getNormalMatrix(_),(m===null||m.length<g)&&(m=new Float32Array(g));for(let w=0,M=f;w!==v;++w,M+=4)r.copy(u[w]).applyMatrix4(_,o),r.normal.toArray(m,M),m[M+3]=r.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,m}}const Hs=4,$f=[.125,.215,.35,.446,.526,.582],ha=20,k3=256,Gr=new In,Zf=new st;let yh=null,_h=0,Sh=0,wh=!1;const z3=new D;class Ju{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,i=.1,n=100,s={}){const{size:r=256,position:o=z3}=s;yh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),Sh=this._renderer.getActiveMipmapLevel(),wh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(r);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,i,n,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=Qf(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=jf(),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(yh,_h,Sh),this._renderer.xr.enabled=wh,t.scissorTest=!1,$a(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Sa||t.mapping===yr?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),yh=this._renderer.getRenderTarget(),_h=this._renderer.getActiveCubeFace(),Sh=this._renderer.getActiveMipmapLevel(),wh=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const i=e||this._allocateTargets();return this._textureToCubeUV(t,i),this._applyPMREM(i),this._cleanup(i),i}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,i={magFilter:se,minFilter:se,generateMipmaps:!1,type:ze,format:_i,colorSpace:sl,depthBuffer:!1},n=Jf(t,e,i);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=Jf(t,e,i);const{_lodMax:s}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=B3(s)),this._blurMaterial=G3(s,t,e),this._ggxMaterial=H3(s,t,e)}return n}_compileMaterial(t){const e=new Dt(new ue,t);this._renderer.compile(e,Gr)}_sceneToCubeUV(t,e,i,n,s){const c=new Vi(90,1,e,i),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(Zf),u.toneMapping=Qn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(n),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new Dt(new an,new gn({name:"PMREM.Background",side:Ue,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,m=v.material;let g=!1;const _=t.background;_?_.isColor&&(m.color.copy(_),t.background=null,g=!0):(m.color.copy(Zf),g=!0);for(let w=0;w<6;w++){const M=w%3;M===0?(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x+h[w],s.y,s.z)):M===1?(c.up.set(0,0,l[w]),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y+h[w],s.z)):(c.up.set(0,l[w],0),c.position.set(s.x,s.y,s.z),c.lookAt(s.x,s.y,s.z+h[w]));const S=this._cubeSize;$a(n,M*S,w>2?S:0,S,S),u.setRenderTarget(n),g&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=_}_textureToCubeUV(t,e){const i=this._renderer,n=t.mapping===Sa||t.mapping===yr;n?(this._cubemapMaterial===null&&(this._cubemapMaterial=Qf()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=jf());const s=n?this._cubemapMaterial:this._equirectMaterial,r=this._lodMeshes[0];r.material=s;const o=s.uniforms;o.envMap.value=t;const c=this._cubeSize;$a(e,0,0,3*c,2*c),i.setRenderTarget(e),i.render(r,Gr)}_applyPMREM(t){const e=this._renderer,i=e.autoClear;e.autoClear=!1;const n=this._lodMeshes.length;for(let s=1;s<n;s++)this._applyGGXFilter(t,s-1,s);e.autoClear=i}_applyGGXFilter(t,e,i){const n=this._renderer,s=this._pingPongRenderTarget,r=this._ggxMaterial,o=this._lodMeshes[i];o.material=r;const c=r.uniforms,l=i/(this._lodMeshes.length-1),h=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[i],m=3*v*(i>p-Hs?i-p+Hs:0),g=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=p-e,$a(s,m,g,3*v,2*v),n.setRenderTarget(s),n.render(o,Gr),c.envMap.value=s.texture,c.roughness.value=0,c.mipInt.value=p-i,$a(t,m,g,3*v,2*v),n.setRenderTarget(t),n.render(o,Gr)}_blur(t,e,i,n,s){const r=this._pingPongRenderTarget;this._halfBlur(t,r,e,i,n,"latitudinal",s),this._halfBlur(r,t,i,i,n,"longitudinal",s)}_halfBlur(t,e,i,n,s,r,o){const c=this._renderer,l=this._blurMaterial;r!=="latitudinal"&&r!=="longitudinal"&&Ht("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[n];u.material=l;const d=l.uniforms,f=this._sizeLods[i]-1,p=isFinite(s)?Math.PI/(2*f):2*Math.PI/(2*ha-1),v=s/p,m=isFinite(s)?1+Math.floor(h*v):ha;m>ha&&Tt(`sigmaRadians, ${s}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${ha}`);const g=[];let _=0;for(let T=0;T<ha;++T){const x=T/v,A=Math.exp(-x*x/2);g.push(A),T===0?_+=A:T<m&&(_+=2*A)}for(let T=0;T<g.length;T++)g[T]=g[T]/_;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=g,d.latitudinal.value=r==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:w}=this;d.dTheta.value=p,d.mipInt.value=w-i;const M=this._sizeLods[n],S=3*M*(n>w-Hs?n-w+Hs:0),b=4*(this._cubeSize-M);$a(e,S,b,3*M,2*M),c.setRenderTarget(e),c.render(u,Gr)}}function B3(a){const t=[],e=[],i=[];let n=a;const s=a-Hs+1+$f.length;for(let r=0;r<s;r++){const o=Math.pow(2,n);t.push(o);let c=1/o;r>a-Hs?c=$f[r-a+Hs-1]:r===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,m=2,g=1,_=new Float32Array(v*p*f),w=new Float32Array(m*p*f),M=new Float32Array(g*p*f);for(let b=0;b<f;b++){const T=b%3*2/3-1,x=b>2?0:-1,A=[T,x,0,T+2/3,x,0,T+2/3,x+1,0,T,x,0,T+2/3,x+1,0,T,x+1,0];_.set(A,v*p*b),w.set(d,m*p*b);const I=[b,b,b,b,b,b];M.set(I,g*p*b)}const S=new ue;S.setAttribute("position",new te(_,v)),S.setAttribute("uv",new te(w,m)),S.setAttribute("faceIndex",new te(M,g)),i.push(new Dt(S,null)),n>Hs&&n--}return{lodMeshes:i,sizeLods:t,sigmas:e}}function Jf(a,t,e){const i=new je(a,t,e);return i.texture.mapping=bl,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function $a(a,t,e,i,n){a.viewport.set(t,e,i,n),a.scissor.set(t,e,i,n)}function H3(a,t,e){return new ae({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:k3,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${a}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Rl(),fragmentShader:`
|
|
4375
4375
|
|
|
4376
4376
|
precision highp float;
|
|
4377
4377
|
precision highp int;
|
|
@@ -4660,7 +4660,7 @@ void main() {
|
|
|
4660
4660
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4661
4661
|
|
|
4662
4662
|
}
|
|
4663
|
-
`},n=new an(5,5,5),s=new ae({name:"CubemapFromEquirect",uniforms:Sr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ue,blending:jn});s.uniforms.tEquirect.value=e;const r=new Dt(n,s),o=e.minFilter;return e.minFilter===pa&&(e.minFilter=se),new e0(1,10,this).update(t,r),e.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(t,e=!0,i=!0,n=!0){const s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(s)}}function V3(a){let t=new WeakMap,e=new WeakMap,i=null;function n(d,f=!1){return d==null?null:f?r(d):s(d)}function s(d){if(d&&d.isTexture){const f=d.mapping;if(f===Hl||f===Gl)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 To(p.height);return v.fromEquirectangularTexture(a,d),t.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function r(d){if(d&&d.isTexture){const f=d.mapping,p=f===Hl||f===Gl,v=f===Sa||f===yr;if(p||v){let m=e.get(d);const g=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new Ju(a)),m=p?i.fromEquirectangular(d,m):i.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),m.texture;if(m!==void 0)return m.texture;{const _=d.image;return p&&_&&_.height>0||v&&_&&c(_)?(i===null&&(i=new Ju(a)),m=p?i.fromEquirectangular(d):i.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===Hl?d.mapping=Sa:f===Gl&&(d.mapping=yr),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,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:u}}function W3(a){const t={};function e(i){if(t[i]!==void 0)return t[i];const n=a.getExtension(i);return t[i]=n,n}return{has:function(i){return e(i)!==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(i){const n=e(i);return n===null&&hr("WebGLRenderer: "+i+" extension not supported."),n}}}function X3(a,t,e,i){const n={},s=new WeakMap;function r(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",r),delete n[d.id];const f=s.get(d);f&&(t.remove(f),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return n[d.id]===!0||(d.addEventListener("dispose",r),n[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.update(d[f],a.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,p=u.attributes.position;let v=0;if(p===void 0)return;if(f!==null){const _=f.array;v=f.version;for(let w=0,M=_.length;w<M;w+=3){const S=_[w+0],b=_[w+1],T=_[w+2];d.push(S,b,b,T,T,S)}}else{const _=p.array;v=p.version;for(let w=0,M=_.length/3-1;w<M;w+=3){const S=w+0,b=w+1,T=w+2;d.push(S,b,b,T,T,S)}}const m=new(p.count>=65535?Kd:vg)(d,1);m.version=v;const g=s.get(u);g&&t.remove(g),s.set(u,m)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return s.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function q3(a,t,e){let i;function n(u){i=u}let s,r;function o(u){s=u.type,r=u.bytesPerElement}function c(u,d){a.drawElements(i,d,s,u*r),e.update(d,i,1)}function l(u,d,f){f!==0&&(a.drawElementsInstanced(i,d,s,u*r,f),e.update(d,i,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,u,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];e.update(v,i,1)}this.setMode=n,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Y3(a){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,r,o){switch(e.calls++,r){case a.TRIANGLES:e.triangles+=o*(s/3);break;case a.LINES:e.lines+=o*(s/2);break;case a.LINE_STRIP:e.lines+=o*(s-1);break;case a.LINE_LOOP:e.lines+=o*s;break;case a.POINTS:e.points+=o*s;break;default:Ht("WebGLInfo: Unknown draw mode:",r);break}}function n(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:n,update:i}}function K3(a,t,e){const i=new WeakMap,n=new ie;function s(r,o,c){const l=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==u){let A=function(){T.dispose(),i.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,p=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let w=0;f===!0&&(w=1),p===!0&&(w=2),v===!0&&(w=3);let M=o.attributes.position.count*w,S=1;M>t.maxTextureSize&&(S=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*S*4*u),T=new pg(b,M,S,u);T.type=Di,T.needsUpdate=!0;const x=w*4;for(let I=0;I<u;I++){const C=m[I],
|
|
4663
|
+
`},n=new an(5,5,5),s=new ae({name:"CubemapFromEquirect",uniforms:Sr(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:Ue,blending:jn});s.uniforms.tEquirect.value=e;const r=new Dt(n,s),o=e.minFilter;return e.minFilter===pa&&(e.minFilter=se),new e0(1,10,this).update(t,r),e.minFilter=o,r.geometry.dispose(),r.material.dispose(),this}clear(t,e=!0,i=!0,n=!0){const s=t.getRenderTarget();for(let r=0;r<6;r++)t.setRenderTarget(this,r),t.clear(e,i,n);t.setRenderTarget(s)}}function V3(a){let t=new WeakMap,e=new WeakMap,i=null;function n(d,f=!1){return d==null?null:f?r(d):s(d)}function s(d){if(d&&d.isTexture){const f=d.mapping;if(f===Hl||f===Gl)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 To(p.height);return v.fromEquirectangularTexture(a,d),t.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function r(d){if(d&&d.isTexture){const f=d.mapping,p=f===Hl||f===Gl,v=f===Sa||f===yr;if(p||v){let m=e.get(d);const g=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==g)return i===null&&(i=new Ju(a)),m=p?i.fromEquirectangular(d,m):i.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),m.texture;if(m!==void 0)return m.texture;{const _=d.image;return p&&_&&_.height>0||v&&_&&c(_)?(i===null&&(i=new Ju(a)),m=p?i.fromEquirectangular(d):i.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===Hl?d.mapping=Sa:f===Gl&&(d.mapping=yr),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,i!==null&&(i.dispose(),i=null)}return{get:n,dispose:u}}function W3(a){const t={};function e(i){if(t[i]!==void 0)return t[i];const n=a.getExtension(i);return t[i]=n,n}return{has:function(i){return e(i)!==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(i){const n=e(i);return n===null&&hr("WebGLRenderer: "+i+" extension not supported."),n}}}function X3(a,t,e,i){const n={},s=new WeakMap;function r(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",r),delete n[d.id];const f=s.get(d);f&&(t.remove(f),s.delete(d)),i.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return n[d.id]===!0||(d.addEventListener("dispose",r),n[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.update(d[f],a.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,p=u.attributes.position;let v=0;if(p===void 0)return;if(f!==null){const _=f.array;v=f.version;for(let w=0,M=_.length;w<M;w+=3){const S=_[w+0],b=_[w+1],T=_[w+2];d.push(S,b,b,T,T,S)}}else{const _=p.array;v=p.version;for(let w=0,M=_.length/3-1;w<M;w+=3){const S=w+0,b=w+1,T=w+2;d.push(S,b,b,T,T,S)}}const m=new(p.count>=65535?Kd:vg)(d,1);m.version=v;const g=s.get(u);g&&t.remove(g),s.set(u,m)}function h(u){const d=s.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return s.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function q3(a,t,e){let i;function n(u){i=u}let s,r;function o(u){s=u.type,r=u.bytesPerElement}function c(u,d){a.drawElements(i,d,s,u*r),e.update(d,i,1)}function l(u,d,f){f!==0&&(a.drawElementsInstanced(i,d,s,u*r,f),e.update(d,i,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(i,d,0,s,u,0,f);let v=0;for(let m=0;m<f;m++)v+=d[m];e.update(v,i,1)}this.setMode=n,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Y3(a){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function i(s,r,o){switch(e.calls++,r){case a.TRIANGLES:e.triangles+=o*(s/3);break;case a.LINES:e.lines+=o*(s/2);break;case a.LINE_STRIP:e.lines+=o*(s-1);break;case a.LINE_LOOP:e.lines+=o*s;break;case a.POINTS:e.points+=o*s;break;default:Ht("WebGLInfo: Unknown draw mode:",r);break}}function n(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:n,update:i}}function K3(a,t,e){const i=new WeakMap,n=new ie;function s(r,o,c){const l=r.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=i.get(o);if(d===void 0||d.count!==u){let A=function(){T.dispose(),i.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,p=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],g=o.morphAttributes.normal||[],_=o.morphAttributes.color||[];let w=0;f===!0&&(w=1),p===!0&&(w=2),v===!0&&(w=3);let M=o.attributes.position.count*w,S=1;M>t.maxTextureSize&&(S=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*S*4*u),T=new pg(b,M,S,u);T.type=Di,T.needsUpdate=!0;const x=w*4;for(let I=0;I<u;I++){const C=m[I],L=g[I],W=_[I],X=M*S*4*I;for(let P=0;P<C.count;P++){const B=P*x;f===!0&&(n.fromBufferAttribute(C,P),b[X+B+0]=n.x,b[X+B+1]=n.y,b[X+B+2]=n.z,b[X+B+3]=0),p===!0&&(n.fromBufferAttribute(L,P),b[X+B+4]=n.x,b[X+B+5]=n.y,b[X+B+6]=n.z,b[X+B+7]=0),v===!0&&(n.fromBufferAttribute(W,P),b[X+B+8]=n.x,b[X+B+9]=n.y,b[X+B+10]=n.z,b[X+B+11]=W.itemSize===4?n.w:1)}}d={count:u,texture:T,size:new Mt(M,S)},i.set(o,d),o.addEventListener("dispose",A)}if(r.isInstancedMesh===!0&&r.morphTexture!==null)c.getUniforms().setValue(a,"morphTexture",r.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(a,"morphTargetBaseInfluence",p),c.getUniforms().setValue(a,"morphTargetInfluences",l)}c.getUniforms().setValue(a,"morphTargetsTexture",d.texture,e),c.getUniforms().setValue(a,"morphTargetsTextureSize",d.size)}return{update:s}}function $3(a,t,e,i,n){let s=new WeakMap;function r(l){const h=n.render.frame,u=l.geometry,d=t.get(l,u);if(s.get(d)!==h&&(t.update(d),s.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),s.get(l)!==h&&(e.update(l.instanceMatrix,a.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,a.ARRAY_BUFFER),s.set(l,h))),l.isSkinnedMesh){const f=l.skeleton;s.get(f)!==h&&(f.update(),s.set(f,h))}return d}function o(){s=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),i.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:r,dispose:o}}const Z3={[jm]:"LINEAR_TONE_MAPPING",[Qm]:"REINHARD_TONE_MAPPING",[tg]:"CINEON_TONE_MAPPING",[eg]:"ACES_FILMIC_TONE_MAPPING",[ng]:"AGX_TONE_MAPPING",[sg]:"NEUTRAL_TONE_MAPPING",[ig]:"CUSTOM_TONE_MAPPING"};function J3(a,t,e,i,n,s){const r=new je(t,e,{type:a,depthBuffer:n,stencilBuffer:s,samples:i?4:0,depthTexture:n?new Ks(t,e):void 0}),o=new je(t,e,{type:ze,depthBuffer:!1,stencilBuffer:!1}),c=new ue;c.setAttribute("position",new _e([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new _e([0,2,0,0,2,0],2));const l=new Eg({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4664
4664
|
precision highp float;
|
|
4665
4665
|
|
|
4666
4666
|
uniform mat4 modelViewMatrix;
|
|
@@ -4750,14 +4750,14 @@ void main() {
|
|
|
4750
4750
|
`)+`
|
|
4751
4751
|
`+m,g=["#define varying in",e.glslVersion===rl?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===rl?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
4752
4752
|
`)+`
|
|
4753
|
-
`+g);const w=_+m+r,M=_+g+o,S=rp(n,n.VERTEX_SHADER,w),b=rp(n,n.FRAGMENT_SHADER,M);n.attachShader(v,S),n.attachShader(v,b),e.index0AttributeName!==void 0?n.bindAttribLocation(v,0,e.index0AttributeName):e.hasPositionAttribute===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function T(C){if(a.debug.checkShaderErrors){const
|
|
4753
|
+
`+g);const w=_+m+r,M=_+g+o,S=rp(n,n.VERTEX_SHADER,w),b=rp(n,n.FRAGMENT_SHADER,M);n.attachShader(v,S),n.attachShader(v,b),e.index0AttributeName!==void 0?n.bindAttribLocation(v,0,e.index0AttributeName):e.hasPositionAttribute===!0&&n.bindAttribLocation(v,0,"position"),n.linkProgram(v);function T(C){if(a.debug.checkShaderErrors){const L=n.getProgramInfoLog(v)||"",W=n.getShaderInfoLog(S)||"",X=n.getShaderInfoLog(b)||"",P=L.trim(),B=W.trim(),k=X.trim();let K=!0,tt=!0;if(n.getProgramParameter(v,n.LINK_STATUS)===!1)if(K=!1,typeof a.debug.onShaderError=="function")a.debug.onShaderError(n,v,S,b);else{const J=cp(n,S,"vertex"),it=cp(n,b,"fragment");Ht("WebGLProgram: Shader Error "+n.getError()+" - VALIDATE_STATUS "+n.getProgramParameter(v,n.VALIDATE_STATUS)+`
|
|
4754
4754
|
|
|
4755
4755
|
Material Name: `+C.name+`
|
|
4756
4756
|
Material Type: `+C.type+`
|
|
4757
4757
|
|
|
4758
|
-
Program Info Log: `+
|
|
4758
|
+
Program Info Log: `+P+`
|
|
4759
4759
|
`+J+`
|
|
4760
|
-
`+it)}else N!==""?Tt("WebGLProgram: Program Info Log:",N):(V===""||k==="")&&(tt=!1);tt&&(C.diagnostics={runnable:K,programLog:N,vertexShader:{log:V,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(S),n.deleteShader(b),x=new Xc(n,v),A=j_(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let I=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,G_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=V_++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}let pS=0;class mS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,i){const n=this._getShaderCacheForMaterial(t);return n.has(e)===!1&&(n.add(e),e.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=e.get(t);return i===void 0&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return i===void 0&&(i=new gS(t),e.set(t,i)),i}}class gS{constructor(t){this.id=pS++,this.code=t,this.usedTimes=0}}function vS(a){return a===wa||a===Qc||a===tl}function MS(a,t,e,i,n,s){const r=new qd,o=new mS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,I,C,P,X){const z=C.fog,N=P.geometry,V=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,K=t.get(x.envMap||V,k),tt=K&&K.mapping===bl?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Tt("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const it=N.morphAttributes.position||N.morphAttributes.normal||N.morphAttributes.color,ot=it!==void 0?it.length:0;let Vt=0;N.morphAttributes.position!==void 0&&(Vt=1),N.morphAttributes.normal!==void 0&&(Vt=2),N.morphAttributes.color!==void 0&&(Vt=3);let Qt,qt,Y,rt;if(J){const St=Wn[J];Qt=St.vertexShader,qt=St.fragmentShader}else{Qt=x.vertexShader,qt=x.fragmentShader;const St=o.getVertexShaderStage(x),Ve=o.getFragmentShaderStage(x);o.update(x,St,Ve),Y=St.id,rt=Ve.id}const nt=a.getRenderTarget(),B=a.state.buffers.depth.getReversed(),At=P.isInstancedMesh===!0,Nt=P.isBatchedMesh===!0,Ct=!!x.map,yt=!!x.matcap,Ft=!!K,kt=!!x.aoMap,zt=!!x.lightMap,fe=!!x.bumpMap&&x.wireframe===!1,pe=!!x.normalMap,He=!!x.displacementMap,Le=!!x.emissiveMap,Ge=!!x.metalnessMap,ti=!!x.roughnessMap,O=x.anisotropy>0,zi=x.clearcoat>0,me=x.dispersion>0,R=x.iridescence>0,y=x.sheen>0,F=x.transmission>0,W=O&&!!x.anisotropyMap,$=zi&&!!x.clearcoatMap,at=zi&&!!x.clearcoatNormalMap,lt=zi&&!!x.clearcoatRoughnessMap,Z=R&&!!x.iridescenceMap,Q=R&&!!x.iridescenceThicknessMap,ht=y&&!!x.sheenColorMap,It=y&&!!x.sheenRoughnessMap,ft=!!x.specularMap,ut=!!x.specularColorMap,Ut=!!x.specularIntensityMap,Bt=F&&!!x.transmissionMap,Kt=F&&!!x.thicknessMap,L=!!x.gradientMap,ct=!!x.alphaMap,j=x.alphaTest>0,dt=!!x.alphaHash,vt=!!x.extensions;let et=Qn;x.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(et=a.toneMapping);const Rt={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:Qt,fragmentShader:qt,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Nt,batchingColor:Nt&&P._colorsTexture!==null,instancing:At,instancingColor:At&&P.instanceColor!==null,instancingMorph:At&&P.morphTexture!==null,outputColorSpace:nt===null?a.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:ne.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ct,matcap:yt,envMap:Ft,envMapMode:Ft&&K.mapping,envMapCubeUVHeight:tt,aoMap:kt,lightMap:zt,bumpMap:fe,normalMap:pe,displacementMap:He,emissiveMap:Le,normalMapObjectSpace:pe&&x.normalMapType===lv,normalMapTangentSpace:pe&&x.normalMapType===nl,packedNormalMap:pe&&x.normalMapType===nl&&vS(x.normalMap.format),metalnessMap:Ge,roughnessMap:ti,anisotropy:O,anisotropyMap:W,clearcoat:zi,clearcoatMap:$,clearcoatNormalMap:at,clearcoatRoughnessMap:lt,dispersion:me,iridescence:R,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:y,sheenColorMap:ht,sheenRoughnessMap:It,specularMap:ft,specularColorMap:ut,specularIntensityMap:Ut,transmission:F,transmissionMap:Bt,thicknessMap:Kt,gradientMap:L,opaque:x.transparent===!1&&x.blending===Xs&&x.alphaToCoverage===!1,alphaMap:ct,alphaTest:j,alphaHash:dt,combine:x.combine,mapUv:Ct&&p(x.map.channel),aoMapUv:kt&&p(x.aoMap.channel),lightMapUv:zt&&p(x.lightMap.channel),bumpMapUv:fe&&p(x.bumpMap.channel),normalMapUv:pe&&p(x.normalMap.channel),displacementMapUv:He&&p(x.displacementMap.channel),emissiveMapUv:Le&&p(x.emissiveMap.channel),metalnessMapUv:Ge&&p(x.metalnessMap.channel),roughnessMapUv:ti&&p(x.roughnessMap.channel),anisotropyMapUv:W&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:at&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:It&&p(x.sheenRoughnessMap.channel),specularMapUv:ft&&p(x.specularMap.channel),specularColorMapUv:ut&&p(x.specularColorMap.channel),specularIntensityMapUv:Ut&&p(x.specularIntensityMap.channel),transmissionMapUv:Bt&&p(x.transmissionMap.channel),thicknessMapUv:Kt&&p(x.thicknessMap.channel),alphaMapUv:ct&&p(x.alphaMap.channel),vertexTangents:!!N.attributes.tangent&&(pe||O),vertexNormals:!!N.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!N.attributes.color&&N.attributes.color.itemSize===4,pointsUvs:P.isPoints===!0&&!!N.attributes.uv&&(Ct||ct),fog:!!z,useFog:x.fog===!0,fogExp2:!!z&&z.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||N.attributes.normal===void 0&&pe===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:B,skinning:P.isSkinnedMesh===!0,hasPositionAttribute:N.attributes.position!==void 0,morphTargets:N.morphAttributes.position!==void 0,morphNormals:N.morphAttributes.normal!==void 0,morphColors:N.morphAttributes.color!==void 0,morphTargetsCount:ot,morphTextureStride:Vt,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:a.shadowMap.enabled&&I.length>0,shadowMapType:a.shadowMap.type,toneMapping:et,decodeVideoTexture:Ct&&x.map.isVideoTexture===!0&&ne.getTransfer(x.map.colorSpace)===ve,decodeVideoTextureEmissive:Le&&x.emissiveMap.isVideoTexture===!0&&ne.getTransfer(x.emissiveMap.colorSpace)===ve,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===en,flipSided:x.side===Ue,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:vt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&x.extensions.multiDraw===!0||Nt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Rt.vertexUv1s=c.has(1),Rt.vertexUv2s=c.has(2),Rt.vertexUv3s=c.has(3),c.clear(),Rt}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)A.push(I),A.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(g(A,x),_(A,x),A.push(a.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function _(x,A){r.disableAll(),A.instancing&&r.enable(0),A.instancingColor&&r.enable(1),A.instancingMorph&&r.enable(2),A.matcap&&r.enable(3),A.envMap&&r.enable(4),A.normalMapObjectSpace&&r.enable(5),A.normalMapTangentSpace&&r.enable(6),A.clearcoat&&r.enable(7),A.iridescence&&r.enable(8),A.alphaTest&&r.enable(9),A.vertexColors&&r.enable(10),A.vertexAlphas&&r.enable(11),A.vertexUv1s&&r.enable(12),A.vertexUv2s&&r.enable(13),A.vertexUv3s&&r.enable(14),A.vertexTangents&&r.enable(15),A.anisotropy&&r.enable(16),A.alphaHash&&r.enable(17),A.batching&&r.enable(18),A.dispersion&&r.enable(19),A.batchingColor&&r.enable(20),A.gradientMap&&r.enable(21),A.packedNormalMap&&r.enable(22),A.vertexNormals&&r.enable(23),x.push(r.mask),r.disableAll(),A.fog&&r.enable(0),A.useFog&&r.enable(1),A.flatShading&&r.enable(2),A.logarithmicDepthBuffer&&r.enable(3),A.reversedDepthBuffer&&r.enable(4),A.skinning&&r.enable(5),A.morphTargets&&r.enable(6),A.morphNormals&&r.enable(7),A.morphColors&&r.enable(8),A.premultipliedAlpha&&r.enable(9),A.shadowMapEnabled&&r.enable(10),A.doubleSided&&r.enable(11),A.flipSided&&r.enable(12),A.useDepthPacking&&r.enable(13),A.dithering&&r.enable(14),A.transmission&&r.enable(15),A.sheen&&r.enable(16),A.opaque&&r.enable(17),A.pointsUvs&&r.enable(18),A.decodeVideoTexture&&r.enable(19),A.decodeVideoTextureEmissive&&r.enable(20),A.alphaToCoverage&&r.enable(21),A.numLightProbeGrids>0&&r.enable(22),A.hasPositionAttribute&&r.enable(23),x.push(r.mask)}function w(x){const A=f[x.type];let I;if(A){const C=Wn[A];I=pM.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new fS(a,A,x,n),l.push(I),h.set(A,I)),I}function S(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:l,dispose:T}}function xS(){let a=new WeakMap;function t(r){return a.has(r)}function e(r){let o=a.get(r);return o===void 0&&(o={},a.set(r,o)),o}function i(r){a.delete(r)}function n(r,o,c){a.get(r)[o]=c}function s(){a=new WeakMap}return{has:t,get:e,remove:i,update:n,dispose:s}}function yS(a,t){return a.groupOrder!==t.groupOrder?a.groupOrder-t.groupOrder:a.renderOrder!==t.renderOrder?a.renderOrder-t.renderOrder:a.material.id!==t.material.id?a.material.id-t.material.id:a.materialVariant!==t.materialVariant?a.materialVariant-t.materialVariant:a.z!==t.z?a.z-t.z:a.id-t.id}function fp(a,t){return a.groupOrder!==t.groupOrder?a.groupOrder-t.groupOrder:a.renderOrder!==t.renderOrder?a.renderOrder-t.renderOrder:a.z!==t.z?t.z-a.z:a.id-t.id}function pp(){const a=[];let t=0;const e=[],i=[],n=[];function s(){t=0,e.length=0,i.length=0,n.length=0}function r(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let _=a[t];return _===void 0?(_={id:d.id,object:d,geometry:f,material:p,materialVariant:r(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},a[t]=_):(_.id=d.id,_.object=d,_.geometry=f,_.material=p,_.materialVariant=r(d),_.groupOrder=v,_.renderOrder=d.renderOrder,_.z=m,_.group=g),t++,_}function c(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.push(_):p.transparent===!0?n.push(_):e.push(_)}function l(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.unshift(_):p.transparent===!0?n.unshift(_):e.unshift(_)}function h(d,f,p){e.length>1&&e.sort(d||yS),i.length>1&&i.sort(f||fp),n.length>1&&n.sort(f||fp),p&&(e.reverse(),i.reverse(),n.reverse())}function u(){for(let d=t,f=a.length;d<f;d++){const p=a[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function _S(){let a=new WeakMap;function t(i,n){const s=a.get(i);let r;return s===void 0?(r=new pp,a.set(i,[r])):n>=s.length?(r=new pp,s.push(r)):r=s[n],r}function e(){a=new WeakMap}return{get:t,dispose:e}}function SS(){const a={};return{get:function(t){if(a[t.id]!==void 0)return a[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new D,color:new st};break;case"SpotLight":e={position:new D,direction:new D,color:new st,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new D,color:new st,distance:0,decay:0};break;case"HemisphereLight":e={direction:new D,skyColor:new st,groundColor:new st};break;case"RectAreaLight":e={color:new st,position:new D,halfWidth:new D,halfHeight:new D};break}return a[t.id]=e,e}}}function wS(){const a={};return{get:function(t){if(a[t.id]!==void 0)return a[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[t.id]=e,e}}}let bS=0;function ES(a,t){return(t.castShadow?2:0)-(a.castShadow?2:0)+(t.map?1:0)-(a.map?1:0)}function AS(a){const t=new SS,e=wS(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);const n=new D,s=new Zt,r=new Zt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,_=0,w=0,M=0,S=0,b=0,T=0;l.sort(ES);for(let A=0,I=l.length;A<I;A++){const C=l[A],P=C.color,X=C.intensity,z=C.distance;let N=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===wa?N=C.shadow.map.texture:N=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=P.r*X,u+=P.g*X,d+=P.b*X;else if(C.isLightProbe){for(let V=0;V<9;V++)i.probe[V].addScaledVector(C.sh.coefficients[V],X);T++}else if(C.isDirectionalLight){const V=t.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const k=C.shadow,K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.directionalShadow[f]=K,i.directionalShadowMap[f]=N,i.directionalShadowMatrix[f]=C.shadow.matrix,_++}i.directional[f]=V,f++}else if(C.isSpotLight){const V=t.get(C);V.position.setFromMatrixPosition(C.matrixWorld),V.color.copy(P).multiplyScalar(X),V.distance=z,V.coneCos=Math.cos(C.angle),V.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),V.decay=C.decay,i.spot[v]=V;const k=C.shadow;if(C.map&&(i.spotLightMap[S]=C.map,S++,k.updateMatrices(C),C.castShadow&&b++),i.spotLightMatrix[v]=k.matrix,C.castShadow){const K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.spotShadow[v]=K,i.spotShadowMap[v]=N,M++}v++}else if(C.isRectAreaLight){const V=t.get(C);V.color.copy(P).multiplyScalar(X),V.halfWidth.set(C.width*.5,0,0),V.halfHeight.set(0,C.height*.5,0),i.rectArea[m]=V,m++}else if(C.isPointLight){const V=t.get(C);if(V.color.copy(C.color).multiplyScalar(C.intensity),V.distance=C.distance,V.decay=C.decay,C.castShadow){const k=C.shadow,K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,K.shadowCameraNear=k.camera.near,K.shadowCameraFar=k.camera.far,i.pointShadow[p]=K,i.pointShadowMap[p]=N,i.pointShadowMatrix[p]=C.shadow.matrix,w++}i.point[p]=V,p++}else if(C.isHemisphereLight){const V=t.get(C);V.skyColor.copy(C.color).multiplyScalar(X),V.groundColor.copy(C.groundColor).multiplyScalar(X),i.hemi[g]=V,g++}}m>0&&(a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pt.LTC_FLOAT_1,i.rectAreaLTC2=pt.LTC_FLOAT_2):(i.rectAreaLTC1=pt.LTC_HALF_1,i.rectAreaLTC2=pt.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==_||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==S||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=_,i.directionalShadowMap.length=_,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=_,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=M+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=_,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=S,x.numLightProbes=T,i.version=bS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,_=l.length;g<_;g++){const w=l[g];if(w.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(w.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(w.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),r.identity(),s.copy(w.matrixWorld),s.premultiply(m),r.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(r),M.halfHeight.applyMatrix4(r),p++}else if(w.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),d++}else if(w.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function mp(a){const t=new AS(a),e=[],i=[],n=[];function s(d){u.camera=d,e.length=0,i.length=0,n.length=0}function r(d){e.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:c}}function TS(a){let t=new WeakMap;function e(n,s=0){const r=t.get(n);let o;return r===void 0?(o=new mp(a),t.set(n,[o])):s>=r.length?(o=new mp(a),r.push(o)):o=r[s],o}function i(){t=new WeakMap}return{get:e,dispose:i}}const RS=`void main() {
|
|
4760
|
+
`+it)}else P!==""?Tt("WebGLProgram: Program Info Log:",P):(B===""||k==="")&&(tt=!1);tt&&(C.diagnostics={runnable:K,programLog:P,vertexShader:{log:B,prefix:m},fragmentShader:{log:k,prefix:g}})}n.deleteShader(S),n.deleteShader(b),x=new Xc(n,v),A=j_(n,v)}let x;this.getUniforms=function(){return x===void 0&&T(this),x};let A;this.getAttributes=function(){return A===void 0&&T(this),A};let I=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=n.getProgramParameter(v,G_)),I},this.destroy=function(){i.releaseStatesOfProgram(this),n.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=V_++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=b,this}let pS=0;class mS{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,i){const n=this._getShaderCacheForMaterial(t);return n.has(e)===!1&&(n.add(e),e.usedTimes++),n.has(i)===!1&&(n.add(i),i.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const i of e)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.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 i=e.get(t);return i===void 0&&(i=new Set,e.set(t,i)),i}_getShaderStage(t){const e=this.shaderCache;let i=e.get(t);return i===void 0&&(i=new gS(t),e.set(t,i)),i}}class gS{constructor(t){this.id=pS++,this.code=t,this.usedTimes=0}}function vS(a){return a===wa||a===Qc||a===tl}function MS(a,t,e,i,n,s){const r=new qd,o=new mS,c=new Set,l=[],h=new Map,u=i.logarithmicDepthBuffer;let d=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(x){return c.add(x),x===0?"uv":`uv${x}`}function v(x,A,I,C,L,W){const X=C.fog,P=L.geometry,B=x.isMeshStandardMaterial||x.isMeshLambertMaterial||x.isMeshPhongMaterial?C.environment:null,k=x.isMeshStandardMaterial||x.isMeshLambertMaterial&&!x.envMap||x.isMeshPhongMaterial&&!x.envMap,K=t.get(x.envMap||B,k),tt=K&&K.mapping===bl?K.image.height:null,J=f[x.type];x.precision!==null&&(d=i.getMaxPrecision(x.precision),d!==x.precision&&Tt("WebGLProgram.getParameters:",x.precision,"not supported, using",d,"instead."));const it=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,rt=it!==void 0?it.length:0;let Gt=0;P.morphAttributes.position!==void 0&&(Gt=1),P.morphAttributes.normal!==void 0&&(Gt=2),P.morphAttributes.color!==void 0&&(Gt=3);let Jt,qt,Y,at;if(J){const St=Wn[J];Jt=St.vertexShader,qt=St.fragmentShader}else{Jt=x.vertexShader,qt=x.fragmentShader;const St=o.getVertexShaderStage(x),Ve=o.getFragmentShaderStage(x);o.update(x,St,Ve),Y=St.id,at=Ve.id}const nt=a.getRenderTarget(),z=a.state.buffers.depth.getReversed(),At=L.isInstancedMesh===!0,Nt=L.isBatchedMesh===!0,Ct=!!x.map,yt=!!x.matcap,Ft=!!K,kt=!!x.aoMap,zt=!!x.lightMap,fe=!!x.bumpMap&&x.wireframe===!1,pe=!!x.normalMap,He=!!x.displacementMap,Le=!!x.emissiveMap,Ge=!!x.metalnessMap,ti=!!x.roughnessMap,O=x.anisotropy>0,zi=x.clearcoat>0,me=x.dispersion>0,R=x.iridescence>0,y=x.sheen>0,F=x.transmission>0,V=O&&!!x.anisotropyMap,$=zi&&!!x.clearcoatMap,ot=zi&&!!x.clearcoatNormalMap,lt=zi&&!!x.clearcoatRoughnessMap,Z=R&&!!x.iridescenceMap,Q=R&&!!x.iridescenceThicknessMap,ht=y&&!!x.sheenColorMap,It=y&&!!x.sheenRoughnessMap,ft=!!x.specularMap,ut=!!x.specularColorMap,Ut=!!x.specularIntensityMap,Bt=F&&!!x.transmissionMap,Kt=F&&!!x.thicknessMap,N=!!x.gradientMap,ct=!!x.alphaMap,j=x.alphaTest>0,dt=!!x.alphaHash,vt=!!x.extensions;let et=Qn;x.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(et=a.toneMapping);const Rt={shaderID:J,shaderType:x.type,shaderName:x.name,vertexShader:Jt,fragmentShader:qt,defines:x.defines,customVertexShaderID:Y,customFragmentShaderID:at,isRawShaderMaterial:x.isRawShaderMaterial===!0,glslVersion:x.glslVersion,precision:d,batching:Nt,batchingColor:Nt&&L._colorsTexture!==null,instancing:At,instancingColor:At&&L.instanceColor!==null,instancingMorph:At&&L.morphTexture!==null,outputColorSpace:nt===null?a.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:ne.workingColorSpace,alphaToCoverage:!!x.alphaToCoverage,map:Ct,matcap:yt,envMap:Ft,envMapMode:Ft&&K.mapping,envMapCubeUVHeight:tt,aoMap:kt,lightMap:zt,bumpMap:fe,normalMap:pe,displacementMap:He,emissiveMap:Le,normalMapObjectSpace:pe&&x.normalMapType===lv,normalMapTangentSpace:pe&&x.normalMapType===nl,packedNormalMap:pe&&x.normalMapType===nl&&vS(x.normalMap.format),metalnessMap:Ge,roughnessMap:ti,anisotropy:O,anisotropyMap:V,clearcoat:zi,clearcoatMap:$,clearcoatNormalMap:ot,clearcoatRoughnessMap:lt,dispersion:me,iridescence:R,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:y,sheenColorMap:ht,sheenRoughnessMap:It,specularMap:ft,specularColorMap:ut,specularIntensityMap:Ut,transmission:F,transmissionMap:Bt,thicknessMap:Kt,gradientMap:N,opaque:x.transparent===!1&&x.blending===Xs&&x.alphaToCoverage===!1,alphaMap:ct,alphaTest:j,alphaHash:dt,combine:x.combine,mapUv:Ct&&p(x.map.channel),aoMapUv:kt&&p(x.aoMap.channel),lightMapUv:zt&&p(x.lightMap.channel),bumpMapUv:fe&&p(x.bumpMap.channel),normalMapUv:pe&&p(x.normalMap.channel),displacementMapUv:He&&p(x.displacementMap.channel),emissiveMapUv:Le&&p(x.emissiveMap.channel),metalnessMapUv:Ge&&p(x.metalnessMap.channel),roughnessMapUv:ti&&p(x.roughnessMap.channel),anisotropyMapUv:V&&p(x.anisotropyMap.channel),clearcoatMapUv:$&&p(x.clearcoatMap.channel),clearcoatNormalMapUv:ot&&p(x.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:lt&&p(x.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&p(x.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&p(x.iridescenceThicknessMap.channel),sheenColorMapUv:ht&&p(x.sheenColorMap.channel),sheenRoughnessMapUv:It&&p(x.sheenRoughnessMap.channel),specularMapUv:ft&&p(x.specularMap.channel),specularColorMapUv:ut&&p(x.specularColorMap.channel),specularIntensityMapUv:Ut&&p(x.specularIntensityMap.channel),transmissionMapUv:Bt&&p(x.transmissionMap.channel),thicknessMapUv:Kt&&p(x.thicknessMap.channel),alphaMapUv:ct&&p(x.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(pe||O),vertexNormals:!!P.attributes.normal,vertexColors:x.vertexColors,vertexAlphas:x.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!P.attributes.uv&&(Ct||ct),fog:!!X,useFog:x.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:x.wireframe===!1&&(x.flatShading===!0||P.attributes.normal===void 0&&pe===!1&&(x.isMeshLambertMaterial||x.isMeshPhongMaterial||x.isMeshStandardMaterial||x.isMeshPhysicalMaterial)),sizeAttenuation:x.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:rt,morphTextureStride:Gt,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:W.length,numClippingPlanes:s.numPlanes,numClipIntersection:s.numIntersection,dithering:x.dithering,shadowMapEnabled:a.shadowMap.enabled&&I.length>0,shadowMapType:a.shadowMap.type,toneMapping:et,decodeVideoTexture:Ct&&x.map.isVideoTexture===!0&&ne.getTransfer(x.map.colorSpace)===ve,decodeVideoTextureEmissive:Le&&x.emissiveMap.isVideoTexture===!0&&ne.getTransfer(x.emissiveMap.colorSpace)===ve,premultipliedAlpha:x.premultipliedAlpha,doubleSided:x.side===en,flipSided:x.side===Ue,useDepthPacking:x.depthPacking>=0,depthPacking:x.depthPacking||0,index0AttributeName:x.index0AttributeName,extensionClipCullDistance:vt&&x.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(vt&&x.extensions.multiDraw===!0||Nt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:x.customProgramCacheKey()};return Rt.vertexUv1s=c.has(1),Rt.vertexUv2s=c.has(2),Rt.vertexUv3s=c.has(3),c.clear(),Rt}function m(x){const A=[];if(x.shaderID?A.push(x.shaderID):(A.push(x.customVertexShaderID),A.push(x.customFragmentShaderID)),x.defines!==void 0)for(const I in x.defines)A.push(I),A.push(x.defines[I]);return x.isRawShaderMaterial===!1&&(g(A,x),_(A,x),A.push(a.outputColorSpace)),A.push(x.customProgramCacheKey),A.join()}function g(x,A){x.push(A.precision),x.push(A.outputColorSpace),x.push(A.envMapMode),x.push(A.envMapCubeUVHeight),x.push(A.mapUv),x.push(A.alphaMapUv),x.push(A.lightMapUv),x.push(A.aoMapUv),x.push(A.bumpMapUv),x.push(A.normalMapUv),x.push(A.displacementMapUv),x.push(A.emissiveMapUv),x.push(A.metalnessMapUv),x.push(A.roughnessMapUv),x.push(A.anisotropyMapUv),x.push(A.clearcoatMapUv),x.push(A.clearcoatNormalMapUv),x.push(A.clearcoatRoughnessMapUv),x.push(A.iridescenceMapUv),x.push(A.iridescenceThicknessMapUv),x.push(A.sheenColorMapUv),x.push(A.sheenRoughnessMapUv),x.push(A.specularMapUv),x.push(A.specularColorMapUv),x.push(A.specularIntensityMapUv),x.push(A.transmissionMapUv),x.push(A.thicknessMapUv),x.push(A.combine),x.push(A.fogExp2),x.push(A.sizeAttenuation),x.push(A.morphTargetsCount),x.push(A.morphAttributeCount),x.push(A.numDirLights),x.push(A.numPointLights),x.push(A.numSpotLights),x.push(A.numSpotLightMaps),x.push(A.numHemiLights),x.push(A.numRectAreaLights),x.push(A.numDirLightShadows),x.push(A.numPointLightShadows),x.push(A.numSpotLightShadows),x.push(A.numSpotLightShadowsWithMaps),x.push(A.numLightProbes),x.push(A.shadowMapType),x.push(A.toneMapping),x.push(A.numClippingPlanes),x.push(A.numClipIntersection),x.push(A.depthPacking)}function _(x,A){r.disableAll(),A.instancing&&r.enable(0),A.instancingColor&&r.enable(1),A.instancingMorph&&r.enable(2),A.matcap&&r.enable(3),A.envMap&&r.enable(4),A.normalMapObjectSpace&&r.enable(5),A.normalMapTangentSpace&&r.enable(6),A.clearcoat&&r.enable(7),A.iridescence&&r.enable(8),A.alphaTest&&r.enable(9),A.vertexColors&&r.enable(10),A.vertexAlphas&&r.enable(11),A.vertexUv1s&&r.enable(12),A.vertexUv2s&&r.enable(13),A.vertexUv3s&&r.enable(14),A.vertexTangents&&r.enable(15),A.anisotropy&&r.enable(16),A.alphaHash&&r.enable(17),A.batching&&r.enable(18),A.dispersion&&r.enable(19),A.batchingColor&&r.enable(20),A.gradientMap&&r.enable(21),A.packedNormalMap&&r.enable(22),A.vertexNormals&&r.enable(23),x.push(r.mask),r.disableAll(),A.fog&&r.enable(0),A.useFog&&r.enable(1),A.flatShading&&r.enable(2),A.logarithmicDepthBuffer&&r.enable(3),A.reversedDepthBuffer&&r.enable(4),A.skinning&&r.enable(5),A.morphTargets&&r.enable(6),A.morphNormals&&r.enable(7),A.morphColors&&r.enable(8),A.premultipliedAlpha&&r.enable(9),A.shadowMapEnabled&&r.enable(10),A.doubleSided&&r.enable(11),A.flipSided&&r.enable(12),A.useDepthPacking&&r.enable(13),A.dithering&&r.enable(14),A.transmission&&r.enable(15),A.sheen&&r.enable(16),A.opaque&&r.enable(17),A.pointsUvs&&r.enable(18),A.decodeVideoTexture&&r.enable(19),A.decodeVideoTextureEmissive&&r.enable(20),A.alphaToCoverage&&r.enable(21),A.numLightProbeGrids>0&&r.enable(22),A.hasPositionAttribute&&r.enable(23),x.push(r.mask)}function w(x){const A=f[x.type];let I;if(A){const C=Wn[A];I=pM.clone(C.uniforms)}else I=x.uniforms;return I}function M(x,A){let I=h.get(A);return I!==void 0?++I.usedTimes:(I=new fS(a,A,x,n),l.push(I),h.set(A,I)),I}function S(x){if(--x.usedTimes===0){const A=l.indexOf(x);l[A]=l[l.length-1],l.pop(),h.delete(x.cacheKey),x.destroy()}}function b(x){o.remove(x)}function T(){o.dispose()}return{getParameters:v,getProgramCacheKey:m,getUniforms:w,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:l,dispose:T}}function xS(){let a=new WeakMap;function t(r){return a.has(r)}function e(r){let o=a.get(r);return o===void 0&&(o={},a.set(r,o)),o}function i(r){a.delete(r)}function n(r,o,c){a.get(r)[o]=c}function s(){a=new WeakMap}return{has:t,get:e,remove:i,update:n,dispose:s}}function yS(a,t){return a.groupOrder!==t.groupOrder?a.groupOrder-t.groupOrder:a.renderOrder!==t.renderOrder?a.renderOrder-t.renderOrder:a.material.id!==t.material.id?a.material.id-t.material.id:a.materialVariant!==t.materialVariant?a.materialVariant-t.materialVariant:a.z!==t.z?a.z-t.z:a.id-t.id}function fp(a,t){return a.groupOrder!==t.groupOrder?a.groupOrder-t.groupOrder:a.renderOrder!==t.renderOrder?a.renderOrder-t.renderOrder:a.z!==t.z?t.z-a.z:a.id-t.id}function pp(){const a=[];let t=0;const e=[],i=[],n=[];function s(){t=0,e.length=0,i.length=0,n.length=0}function r(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,p,v,m,g){let _=a[t];return _===void 0?(_={id:d.id,object:d,geometry:f,material:p,materialVariant:r(d),groupOrder:v,renderOrder:d.renderOrder,z:m,group:g},a[t]=_):(_.id=d.id,_.object=d,_.geometry=f,_.material=p,_.materialVariant=r(d),_.groupOrder=v,_.renderOrder=d.renderOrder,_.z=m,_.group=g),t++,_}function c(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.push(_):p.transparent===!0?n.push(_):e.push(_)}function l(d,f,p,v,m,g){const _=o(d,f,p,v,m,g);p.transmission>0?i.unshift(_):p.transparent===!0?n.unshift(_):e.unshift(_)}function h(d,f,p){e.length>1&&e.sort(d||yS),i.length>1&&i.sort(f||fp),n.length>1&&n.sort(f||fp),p&&(e.reverse(),i.reverse(),n.reverse())}function u(){for(let d=t,f=a.length;d<f;d++){const p=a[d];if(p.id===null)break;p.id=null,p.object=null,p.geometry=null,p.material=null,p.group=null}}return{opaque:e,transmissive:i,transparent:n,init:s,push:c,unshift:l,finish:u,sort:h}}function _S(){let a=new WeakMap;function t(i,n){const s=a.get(i);let r;return s===void 0?(r=new pp,a.set(i,[r])):n>=s.length?(r=new pp,s.push(r)):r=s[n],r}function e(){a=new WeakMap}return{get:t,dispose:e}}function SS(){const a={};return{get:function(t){if(a[t.id]!==void 0)return a[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new D,color:new st};break;case"SpotLight":e={position:new D,direction:new D,color:new st,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new D,color:new st,distance:0,decay:0};break;case"HemisphereLight":e={direction:new D,skyColor:new st,groundColor:new st};break;case"RectAreaLight":e={color:new st,position:new D,halfWidth:new D,halfHeight:new D};break}return a[t.id]=e,e}}}function wS(){const a={};return{get:function(t){if(a[t.id]!==void 0)return a[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Mt,shadowCameraNear:1,shadowCameraFar:1e3};break}return a[t.id]=e,e}}}let bS=0;function ES(a,t){return(t.castShadow?2:0)-(a.castShadow?2:0)+(t.map?1:0)-(a.map?1:0)}function AS(a){const t=new SS,e=wS(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)i.probe.push(new D);const n=new D,s=new Zt,r=new Zt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)i.probe[A].set(0,0,0);let f=0,p=0,v=0,m=0,g=0,_=0,w=0,M=0,S=0,b=0,T=0;l.sort(ES);for(let A=0,I=l.length;A<I;A++){const C=l[A],L=C.color,W=C.intensity,X=C.distance;let P=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===wa?P=C.shadow.map.texture:P=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=L.r*W,u+=L.g*W,d+=L.b*W;else if(C.isLightProbe){for(let B=0;B<9;B++)i.probe[B].addScaledVector(C.sh.coefficients[B],W);T++}else if(C.isDirectionalLight){const B=t.get(C);if(B.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const k=C.shadow,K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.directionalShadow[f]=K,i.directionalShadowMap[f]=P,i.directionalShadowMatrix[f]=C.shadow.matrix,_++}i.directional[f]=B,f++}else if(C.isSpotLight){const B=t.get(C);B.position.setFromMatrixPosition(C.matrixWorld),B.color.copy(L).multiplyScalar(W),B.distance=X,B.coneCos=Math.cos(C.angle),B.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),B.decay=C.decay,i.spot[v]=B;const k=C.shadow;if(C.map&&(i.spotLightMap[S]=C.map,S++,k.updateMatrices(C),C.castShadow&&b++),i.spotLightMatrix[v]=k.matrix,C.castShadow){const K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,i.spotShadow[v]=K,i.spotShadowMap[v]=P,M++}v++}else if(C.isRectAreaLight){const B=t.get(C);B.color.copy(L).multiplyScalar(W),B.halfWidth.set(C.width*.5,0,0),B.halfHeight.set(0,C.height*.5,0),i.rectArea[m]=B,m++}else if(C.isPointLight){const B=t.get(C);if(B.color.copy(C.color).multiplyScalar(C.intensity),B.distance=C.distance,B.decay=C.decay,C.castShadow){const k=C.shadow,K=e.get(C);K.shadowIntensity=k.intensity,K.shadowBias=k.bias,K.shadowNormalBias=k.normalBias,K.shadowRadius=k.radius,K.shadowMapSize=k.mapSize,K.shadowCameraNear=k.camera.near,K.shadowCameraFar=k.camera.far,i.pointShadow[p]=K,i.pointShadowMap[p]=P,i.pointShadowMatrix[p]=C.shadow.matrix,w++}i.point[p]=B,p++}else if(C.isHemisphereLight){const B=t.get(C);B.skyColor.copy(C.color).multiplyScalar(W),B.groundColor.copy(C.groundColor).multiplyScalar(W),i.hemi[g]=B,g++}}m>0&&(a.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=pt.LTC_FLOAT_1,i.rectAreaLTC2=pt.LTC_FLOAT_2):(i.rectAreaLTC1=pt.LTC_HALF_1,i.rectAreaLTC2=pt.LTC_HALF_2)),i.ambient[0]=h,i.ambient[1]=u,i.ambient[2]=d;const x=i.hash;(x.directionalLength!==f||x.pointLength!==p||x.spotLength!==v||x.rectAreaLength!==m||x.hemiLength!==g||x.numDirectionalShadows!==_||x.numPointShadows!==w||x.numSpotShadows!==M||x.numSpotMaps!==S||x.numLightProbes!==T)&&(i.directional.length=f,i.spot.length=v,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=_,i.directionalShadowMap.length=_,i.pointShadow.length=w,i.pointShadowMap.length=w,i.spotShadow.length=M,i.spotShadowMap.length=M,i.directionalShadowMatrix.length=_,i.pointShadowMatrix.length=w,i.spotLightMatrix.length=M+S-b,i.spotLightMap.length=S,i.numSpotLightShadowsWithMaps=b,i.numLightProbes=T,x.directionalLength=f,x.pointLength=p,x.spotLength=v,x.rectAreaLength=m,x.hemiLength=g,x.numDirectionalShadows=_,x.numPointShadows=w,x.numSpotShadows=M,x.numSpotMaps=S,x.numLightProbes=T,i.version=bS++)}function c(l,h){let u=0,d=0,f=0,p=0,v=0;const m=h.matrixWorldInverse;for(let g=0,_=l.length;g<_;g++){const w=l[g];if(w.isDirectionalLight){const M=i.directional[u];M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),u++}else if(w.isSpotLight){const M=i.spot[f];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(w.matrixWorld),n.setFromMatrixPosition(w.target.matrixWorld),M.direction.sub(n),M.direction.transformDirection(m),f++}else if(w.isRectAreaLight){const M=i.rectArea[p];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),r.identity(),s.copy(w.matrixWorld),s.premultiply(m),r.extractRotation(s),M.halfWidth.set(w.width*.5,0,0),M.halfHeight.set(0,w.height*.5,0),M.halfWidth.applyMatrix4(r),M.halfHeight.applyMatrix4(r),p++}else if(w.isPointLight){const M=i.point[d];M.position.setFromMatrixPosition(w.matrixWorld),M.position.applyMatrix4(m),d++}else if(w.isHemisphereLight){const M=i.hemi[v];M.direction.setFromMatrixPosition(w.matrixWorld),M.direction.transformDirection(m),v++}}}return{setup:o,setupView:c,state:i}}function mp(a){const t=new AS(a),e=[],i=[],n=[];function s(d){u.camera=d,e.length=0,i.length=0,n.length=0}function r(d){e.push(d)}function o(d){i.push(d)}function c(d){n.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:i,lightProbeGridArray:n,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:s,state:u,setupLights:l,setupLightsView:h,pushLight:r,pushShadow:o,pushLightProbeGrid:c}}function TS(a){let t=new WeakMap;function e(n,s=0){const r=t.get(n);let o;return r===void 0?(o=new mp(a),t.set(n,[o])):s>=r.length?(o=new mp(a),r.push(o)):o=r[s],o}function i(){t=new WeakMap}return{get:e,dispose:i}}const RS=`void main() {
|
|
4761
4761
|
gl_Position = vec4( position, 1.0 );
|
|
4762
4762
|
}`,DS=`uniform sampler2D shadow_pass;
|
|
4763
4763
|
uniform vec2 resolution;
|
|
@@ -4784,7 +4784,7 @@ void main() {
|
|
|
4784
4784
|
squared_mean = squared_mean / samples;
|
|
4785
4785
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4786
4786
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4787
|
-
}`,CS=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],IS=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],gp=new Zt,Vr=new D,Eh=new D;function PS(a,t,e){let i=new $d;const n=new Mt,s=new Mt,r=new ie,o=new MM,c=new xM,l={},h=e.maxTextureSize,u={[Ys]:Ue,[Ue]:Ys,[en]:en},d=new ae({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mt},radius:{value:4}},vertexShader:RS,fragmentShader:DS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ue;p.setAttribute("position",new te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Dt(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ro;let g=this.type;this.render=function(b,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===k2&&(Tt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ro);const A=a.getRenderTarget(),I=a.getActiveCubeFace(),C=a.getActiveMipmapLevel(),P=a.state;P.setBlending(jn),P.buffers.depth.getReversed()===!0?P.buffers.color.setClear(0,0,0,0):P.buffers.color.setClear(1,1,1,1),P.buffers.depth.setTest(!0),P.setScissorTest(!1);const X=g!==this.type;X&&T.traverse(function(z){z.material&&(Array.isArray(z.material)?z.material.forEach(N=>N.needsUpdate=!0):z.material.needsUpdate=!0)});for(let z=0,N=b.length;z<N;z++){const V=b[z],k=V.shadow;if(k===void 0){Tt("WebGLShadowMap:",V,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const K=k.getFrameExtents();n.multiply(K),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/K.x),n.x=s.x*K.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/K.y),n.y=s.y*K.y,k.mapSize.y=s.y));const tt=a.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||X===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===Qr){if(V.isPointLight){Tt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new je(n.x,n.y,{format:wa,type:ze,minFilter:se,magFilter:se,generateMipmaps:!1}),k.map.texture.name=V.name+".shadowMap",k.map.depthTexture=new Ks(n.x,n.y,Di),k.map.depthTexture.name=V.name+".shadowMapDepth",k.map.depthTexture.format=Ms,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=we,k.map.depthTexture.magFilter=we}else V.isPointLight?(k.map=new To(n.x),k.map.depthTexture=new dM(n.x,vn)):(k.map=new je(n.x,n.y),k.map.depthTexture=new Ks(n.x,n.y,vn)),k.map.depthTexture.name=V.name+".shadowMap",k.map.depthTexture.format=Ms,this.type===ro?(k.map.depthTexture.compareFunction=tt?Vd:Gd,k.map.depthTexture.minFilter=se,k.map.depthTexture.magFilter=se):(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 it=0;it<J;it++){if(k.map.isWebGLCubeRenderTarget)a.setRenderTarget(k.map,it),a.clear();else{it===0&&(a.setRenderTarget(k.map),a.clear());const ot=k.getViewport(it);r.set(s.x*ot.x,s.y*ot.y,s.x*ot.z,s.y*ot.w),P.viewport(r)}if(V.isPointLight){const ot=k.camera,Vt=k.matrix,Qt=V.distance||ot.far;Qt!==ot.far&&(ot.far=Qt,ot.updateProjectionMatrix()),Vr.setFromMatrixPosition(V.matrixWorld),ot.position.copy(Vr),Eh.copy(ot.position),Eh.add(CS[it]),ot.up.copy(IS[it]),ot.lookAt(Eh),ot.updateMatrixWorld(),Vt.makeTranslation(-Vr.x,-Vr.y,-Vr.z),gp.multiplyMatrices(ot.projectionMatrix,ot.matrixWorldInverse),k._frustum.setFromProjectionMatrix(gp,ot.coordinateSystem,ot.reversedDepth)}else k.updateMatrices(V);i=k.getFrustum(),M(T,x,k.camera,V,this.type)}k.isPointLightShadow!==!0&&this.type===Qr&&_(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,a.setRenderTarget(A,I,C)};function _(b,T){const x=t.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new je(n.x,n.y,{format:wa,type:ze})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,a.setRenderTarget(b.mapPass),a.clear(),a.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,a.setRenderTarget(b.map),a.clear(),a.renderBufferDirect(T,null,x,f,v,null)}function w(b,T,x,A){let I=null;const C=x.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,a.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const P=I.uuid,X=T.uuid;let z=l[P];z===void 0&&(z={},l[P]=z);let N=z[X];N===void 0&&(N=I.clone(),z[X]=N,T.addEventListener("dispose",S)),I=N}if(I.visible=T.visible,I.wireframe=T.wireframe,A===Qr?I.side=T.shadowSide!==null?T.shadowSide:T.side:I.side=T.shadowSide!==null?T.shadowSide:u[T.side],I.alphaMap=T.alphaMap,I.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,I.map=T.map,I.clipShadows=T.clipShadows,I.clippingPlanes=T.clippingPlanes,I.clipIntersection=T.clipIntersection,I.displacementMap=T.displacementMap,I.displacementScale=T.displacementScale,I.displacementBias=T.displacementBias,I.wireframeLinewidth=T.wireframeLinewidth,I.linewidth=T.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const P=a.properties.get(I);P.light=x}return I}function M(b,T,x,A,I){if(b.visible===!1)return;if(b.layers.test(T.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===Qr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);const X=t.update(b),z=b.material;if(Array.isArray(z)){const N=X.groups;for(let V=0,k=N.length;V<k;V++){const K=N[V],tt=z[K.materialIndex];if(tt&&tt.visible){const J=w(b,tt,A,I);b.onBeforeShadow(a,b,T,x,X,J,K),a.renderBufferDirect(x,null,X,J,b,K),b.onAfterShadow(a,b,T,x,X,J,K)}}}else if(z.visible){const N=w(b,z,A,I);b.onBeforeShadow(a,b,T,x,X,N,null),a.renderBufferDirect(x,null,X,N,b,null),b.onAfterShadow(a,b,T,x,X,N,null)}}const P=b.children;for(let X=0,z=P.length;X<z;X++)M(P[X],T,x,A,I)}function S(b){b.target.removeEventListener("dispose",S);for(const x in l){const A=l[x],I=b.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function LS(a,t){function e(){let L=!1;const ct=new ie;let j=null;const dt=new ie(0,0,0,0);return{setMask:function(vt){j!==vt&&!L&&(a.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){L=vt},setClear:function(vt,et,Rt,St,Ve){Ve===!0&&(vt*=St,et*=St,Rt*=St),ct.set(vt,et,Rt,St),dt.equals(ct)===!1&&(a.clearColor(vt,et,Rt,St),dt.copy(ct))},reset:function(){L=!1,j=null,dt.set(-1,0,0,0)}}}function i(){let L=!1,ct=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ct!==et){const Rt=t.get("EXT_clip_control");et?Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.ZERO_TO_ONE_EXT):Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.NEGATIVE_ONE_TO_ONE_EXT),ct=et;const St=vt;vt=null,this.setClear(St)}},getReversed:function(){return ct},setTest:function(et){et?nt(a.DEPTH_TEST):B(a.DEPTH_TEST)},setMask:function(et){j!==et&&!L&&(a.depthMask(et),j=et)},setFunc:function(et){if(ct&&(et=yv[et]),dt!==et){switch(et){case lu:a.depthFunc(a.NEVER);break;case hu:a.depthFunc(a.ALWAYS);break;case uu:a.depthFunc(a.LESS);break;case xr:a.depthFunc(a.LEQUAL);break;case du:a.depthFunc(a.EQUAL);break;case fu:a.depthFunc(a.GEQUAL);break;case pu:a.depthFunc(a.GREATER);break;case mu:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}dt=et}},setLocked:function(et){L=et},setClear:function(et){vt!==et&&(vt=et,ct&&(et=1-et),a.clearDepth(et))},reset:function(){L=!1,j=null,dt=null,vt=null,ct=!1}}}function n(){let L=!1,ct=null,j=null,dt=null,vt=null,et=null,Rt=null,St=null,Ve=null;return{setTest:function(Ae){L||(Ae?nt(a.STENCIL_TEST):B(a.STENCIL_TEST))},setMask:function(Ae){ct!==Ae&&!L&&(a.stencilMask(Ae),ct=Ae)},setFunc:function(Ae,Ln,Nn){(j!==Ae||dt!==Ln||vt!==Nn)&&(a.stencilFunc(Ae,Ln,Nn),j=Ae,dt=Ln,vt=Nn)},setOp:function(Ae,Ln,Nn){(et!==Ae||Rt!==Ln||St!==Nn)&&(a.stencilOp(Ae,Ln,Nn),et=Ae,Rt=Ln,St=Nn)},setLocked:function(Ae){L=Ae},setClear:function(Ae){Ve!==Ae&&(a.clearStencil(Ae),Ve=Ae)},reset:function(){L=!1,ct=null,j=null,dt=null,vt=null,et=null,Rt=null,St=null,Ve=null}}}const s=new e,r=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new st(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null;const V=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const tt=a.getParameter(a.VERSION);tt.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=K>=1):tt.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=K>=2);let J=null,it={};const ot=a.getParameter(a.SCISSOR_BOX),Vt=a.getParameter(a.VIEWPORT),Qt=new ie().fromArray(ot),qt=new ie().fromArray(Vt);function Y(L,ct,j,dt){const vt=new Uint8Array(4),et=a.createTexture();a.bindTexture(L,et),a.texParameteri(L,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(L,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Rt=0;Rt<j;Rt++)L===a.TEXTURE_3D||L===a.TEXTURE_2D_ARRAY?a.texImage3D(ct,0,a.RGBA,1,1,dt,0,a.RGBA,a.UNSIGNED_BYTE,vt):a.texImage2D(ct+Rt,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,vt);return et}const rt={};rt[a.TEXTURE_2D]=Y(a.TEXTURE_2D,a.TEXTURE_2D,1),rt[a.TEXTURE_CUBE_MAP]=Y(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[a.TEXTURE_2D_ARRAY]=Y(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),rt[a.TEXTURE_3D]=Y(a.TEXTURE_3D,a.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),nt(a.DEPTH_TEST),r.setFunc(xr),fe(!1),pe(j0),nt(a.CULL_FACE),kt(jn);function nt(L){h[L]!==!0&&(a.enable(L),h[L]=!0)}function B(L){h[L]!==!1&&(a.disable(L),h[L]=!1)}function At(L,ct){return d[L]!==ct?(a.bindFramebuffer(L,ct),d[L]=ct,L===a.DRAW_FRAMEBUFFER&&(d[a.FRAMEBUFFER]=ct),L===a.FRAMEBUFFER&&(d[a.DRAW_FRAMEBUFFER]=ct),!0):!1}function Nt(L,ct){let j=p,dt=!1;if(L){j=f.get(ct),j===void 0&&(j=[],f.set(ct,j));const vt=L.textures;if(j.length!==vt.length||j[0]!==a.COLOR_ATTACHMENT0){for(let et=0,Rt=vt.length;et<Rt;et++)j[et]=a.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==a.BACK&&(j[0]=a.BACK,dt=!0);dt&&a.drawBuffers(j)}function Ct(L){return v!==L?(a.useProgram(L),v=L,!0):!1}const yt={[ca]:a.FUNC_ADD,[z2]:a.FUNC_SUBTRACT,[B2]:a.FUNC_REVERSE_SUBTRACT};yt[H2]=a.MIN,yt[G2]=a.MAX;const Ft={[V2]:a.ZERO,[yo]:a.ONE,[W2]:a.SRC_COLOR,[cu]:a.SRC_ALPHA,[Z2]:a.SRC_ALPHA_SATURATE,[K2]:a.DST_COLOR,[q2]:a.DST_ALPHA,[X2]:a.ONE_MINUS_SRC_COLOR,[_o]:a.ONE_MINUS_SRC_ALPHA,[$2]:a.ONE_MINUS_DST_COLOR,[Y2]:a.ONE_MINUS_DST_ALPHA,[J2]:a.CONSTANT_COLOR,[j2]:a.ONE_MINUS_CONSTANT_COLOR,[Q2]:a.CONSTANT_ALPHA,[tv]:a.ONE_MINUS_CONSTANT_ALPHA};function kt(L,ct,j,dt,vt,et,Rt,St,Ve,Ae){if(L===jn){m===!0&&(B(a.BLEND),m=!1);return}if(m===!1&&(nt(a.BLEND),m=!0),L!==wl){if(L!==g||Ae!==I){if((_!==ca||S!==ca)&&(a.blendEquation(a.FUNC_ADD),_=ca,S=ca),Ae)switch(L){case Xs:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFunc(a.ONE,a.ONE);break;case Q0:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case tf:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:Ht("WebGLState: Invalid blending: ",L);break}else switch(L){case Xs:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case Q0:Ht("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case tf:Ht("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ht("WebGLState: Invalid blending: ",L);break}w=null,M=null,b=null,T=null,x.set(0,0,0),A=0,g=L,I=Ae}return}vt=vt||ct,et=et||j,Rt=Rt||dt,(ct!==_||vt!==S)&&(a.blendEquationSeparate(yt[ct],yt[vt]),_=ct,S=vt),(j!==w||dt!==M||et!==b||Rt!==T)&&(a.blendFuncSeparate(Ft[j],Ft[dt],Ft[et],Ft[Rt]),w=j,M=dt,b=et,T=Rt),(St.equals(x)===!1||Ve!==A)&&(a.blendColor(St.r,St.g,St.b,Ve),x.copy(St),A=Ve),g=L,I=!1}function zt(L,ct){L.side===en?B(a.CULL_FACE):nt(a.CULL_FACE);let j=L.side===Ue;ct&&(j=!j),fe(j),L.blending===Xs&&L.transparent===!1?kt(jn):kt(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),r.setFunc(L.depthFunc),r.setTest(L.depthTest),r.setMask(L.depthWrite),s.setMask(L.colorWrite);const 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)),Le(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?nt(a.SAMPLE_ALPHA_TO_COVERAGE):B(a.SAMPLE_ALPHA_TO_COVERAGE)}function fe(L){C!==L&&(L?a.frontFace(a.CW):a.frontFace(a.CCW),C=L)}function pe(L){L!==U2?(nt(a.CULL_FACE),L!==P&&(L===j0?a.cullFace(a.BACK):L===F2?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):B(a.CULL_FACE),P=L}function He(L){L!==X&&(k&&a.lineWidth(L),X=L)}function Le(L,ct,j){L?(nt(a.POLYGON_OFFSET_FILL),(z!==ct||N!==j)&&(z=ct,N=j,r.getReversed()&&(ct=-ct),a.polygonOffset(ct,j))):B(a.POLYGON_OFFSET_FILL)}function Ge(L){L?nt(a.SCISSOR_TEST):B(a.SCISSOR_TEST)}function ti(L){L===void 0&&(L=a.TEXTURE0+V-1),J!==L&&(a.activeTexture(L),J=L)}function O(L,ct,j){j===void 0&&(J===null?j=a.TEXTURE0+V-1:j=J);let dt=it[j];dt===void 0&&(dt={type:void 0,texture:void 0},it[j]=dt),(dt.type!==L||dt.texture!==ct)&&(J!==j&&(a.activeTexture(j),J=j),a.bindTexture(L,ct||rt[L]),dt.type=L,dt.texture=ct)}function zi(){const L=it[J];L!==void 0&&L.type!==void 0&&(a.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function me(){try{a.compressedTexImage2D(...arguments)}catch(L){Ht("WebGLState:",L)}}function R(){try{a.compressedTexImage3D(...arguments)}catch(L){Ht("WebGLState:",L)}}function y(){try{a.texSubImage2D(...arguments)}catch(L){Ht("WebGLState:",L)}}function F(){try{a.texSubImage3D(...arguments)}catch(L){Ht("WebGLState:",L)}}function W(){try{a.compressedTexSubImage2D(...arguments)}catch(L){Ht("WebGLState:",L)}}function $(){try{a.compressedTexSubImage3D(...arguments)}catch(L){Ht("WebGLState:",L)}}function at(){try{a.texStorage2D(...arguments)}catch(L){Ht("WebGLState:",L)}}function lt(){try{a.texStorage3D(...arguments)}catch(L){Ht("WebGLState:",L)}}function Z(){try{a.texImage2D(...arguments)}catch(L){Ht("WebGLState:",L)}}function Q(){try{a.texImage3D(...arguments)}catch(L){Ht("WebGLState:",L)}}function ht(L){return u[L]!==void 0?u[L]:a.getParameter(L)}function It(L,ct){u[L]!==ct&&(a.pixelStorei(L,ct),u[L]=ct)}function ft(L){Qt.equals(L)===!1&&(a.scissor(L.x,L.y,L.z,L.w),Qt.copy(L))}function ut(L){qt.equals(L)===!1&&(a.viewport(L.x,L.y,L.z,L.w),qt.copy(L))}function Ut(L,ct){let j=l.get(ct);j===void 0&&(j=new WeakMap,l.set(ct,j));let dt=j.get(L);dt===void 0&&(dt=a.getUniformBlockIndex(ct,L.name),j.set(L,dt))}function Bt(L,ct){const dt=l.get(ct).get(L);c.get(ct)!==dt&&(a.uniformBlockBinding(ct,dt,L.__bindingPointIndex),c.set(ct,dt))}function Kt(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),r.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,it={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new st(0,0,0),A=0,I=!1,C=null,P=null,X=null,z=null,N=null,Qt.set(0,0,a.canvas.width,a.canvas.height),qt.set(0,0,a.canvas.width,a.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:nt,disable:B,bindFramebuffer:At,drawBuffers:Nt,useProgram:Ct,setBlending:kt,setMaterial:zt,setFlipSided:fe,setCullFace:pe,setLineWidth:He,setPolygonOffset:Le,setScissorTest:Ge,activeTexture:ti,bindTexture:O,unbindTexture:zi,compressedTexImage2D:me,compressedTexImage3D:R,texImage2D:Z,texImage3D:Q,pixelStorei:It,getParameter:ht,updateUBOMapping:Ut,uniformBlockBinding:Bt,texStorage2D:at,texStorage3D:lt,texSubImage2D:y,texSubImage3D:F,compressedTexSubImage2D:W,compressedTexSubImage3D:$,scissor:ft,viewport:ut,reset:Kt}}function NS(a,t,e,i,n,s,r){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 Mt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,y){return p?new OffscreenCanvas(R,y):Ao("canvas")}function m(R,y,F){let W=1;const $=me(R);if(($.width>F||$.height>F)&&(W=F/Math.max($.width,$.height)),W<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const at=Math.floor(W*$.width),lt=Math.floor(W*$.height);d===void 0&&(d=v(at,lt));const Z=y?v(at,lt):d;return Z.width=at,Z.height=lt,Z.getContext("2d").drawImage(R,0,0,at,lt),Tt("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+at+"x"+lt+")."),Z}else return"data"in R&&Tt("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function _(R){a.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?a.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function M(R,y,F,W,$,at=!1){if(R!==null){if(a[R]!==void 0)return a[R];Tt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let lt;W&&(lt=t.get("EXT_texture_norm16"),lt||Tt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=y;if(y===a.RED&&(F===a.FLOAT&&(Z=a.R32F),F===a.HALF_FLOAT&&(Z=a.R16F),F===a.UNSIGNED_BYTE&&(Z=a.R8),F===a.UNSIGNED_SHORT&<&&(Z=lt.R16_EXT),F===a.SHORT&<&&(Z=lt.R16_SNORM_EXT)),y===a.RED_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.R8UI),F===a.UNSIGNED_SHORT&&(Z=a.R16UI),F===a.UNSIGNED_INT&&(Z=a.R32UI),F===a.BYTE&&(Z=a.R8I),F===a.SHORT&&(Z=a.R16I),F===a.INT&&(Z=a.R32I)),y===a.RG&&(F===a.FLOAT&&(Z=a.RG32F),F===a.HALF_FLOAT&&(Z=a.RG16F),F===a.UNSIGNED_BYTE&&(Z=a.RG8),F===a.UNSIGNED_SHORT&<&&(Z=lt.RG16_EXT),F===a.SHORT&<&&(Z=lt.RG16_SNORM_EXT)),y===a.RG_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RG8UI),F===a.UNSIGNED_SHORT&&(Z=a.RG16UI),F===a.UNSIGNED_INT&&(Z=a.RG32UI),F===a.BYTE&&(Z=a.RG8I),F===a.SHORT&&(Z=a.RG16I),F===a.INT&&(Z=a.RG32I)),y===a.RGB_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGB8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGB16UI),F===a.UNSIGNED_INT&&(Z=a.RGB32UI),F===a.BYTE&&(Z=a.RGB8I),F===a.SHORT&&(Z=a.RGB16I),F===a.INT&&(Z=a.RGB32I)),y===a.RGBA_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGBA8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGBA16UI),F===a.UNSIGNED_INT&&(Z=a.RGBA32UI),F===a.BYTE&&(Z=a.RGBA8I),F===a.SHORT&&(Z=a.RGBA16I),F===a.INT&&(Z=a.RGBA32I)),y===a.RGB&&(F===a.UNSIGNED_SHORT&<&&(Z=lt.RGB16_EXT),F===a.SHORT&<&&(Z=lt.RGB16_SNORM_EXT),F===a.UNSIGNED_INT_5_9_9_9_REV&&(Z=a.RGB9_E5),F===a.UNSIGNED_INT_10F_11F_11F_REV&&(Z=a.R11F_G11F_B10F)),y===a.RGBA){const Q=at?al:ne.getTransfer($);F===a.FLOAT&&(Z=a.RGBA32F),F===a.HALF_FLOAT&&(Z=a.RGBA16F),F===a.UNSIGNED_BYTE&&(Z=Q===ve?a.SRGB8_ALPHA8:a.RGBA8),F===a.UNSIGNED_SHORT&<&&(Z=lt.RGBA16_EXT),F===a.SHORT&<&&(Z=lt.RGBA16_SNORM_EXT),F===a.UNSIGNED_SHORT_4_4_4_4&&(Z=a.RGBA4),F===a.UNSIGNED_SHORT_5_5_5_1&&(Z=a.RGB5_A1)}return(Z===a.R16F||Z===a.R32F||Z===a.RG16F||Z===a.RG32F||Z===a.RGBA16F||Z===a.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(R,y){let F;return R?y===null||y===vn||y===bo?F=a.DEPTH24_STENCIL8:y===Di?F=a.DEPTH32F_STENCIL8:y===wo&&(F=a.DEPTH24_STENCIL8,Tt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===vn||y===bo?F=a.DEPTH_COMPONENT24:y===Di?F=a.DEPTH_COMPONENT32F:y===wo&&(F=a.DEPTH_COMPONENT16),F}function b(R,y){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==we&&R.minFilter!==se?Math.log2(Math.max(y.width,y.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?y.mipmaps.length:1}function T(R){const y=R.target;y.removeEventListener("dispose",T),A(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&u.delete(y)}function x(R){const y=R.target;y.removeEventListener("dispose",x),C(y)}function A(R){const y=i.get(R);if(y.__webglInit===void 0)return;const F=R.source,W=f.get(F);if(W){const $=W[y.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(W).length===0&&f.delete(F)}i.remove(R)}function I(R){const y=i.get(R);a.deleteTexture(y.__webglTexture);const F=R.source,W=f.get(F);delete W[y.__cacheKey],r.memory.textures--}function C(R){const y=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let W=0;W<6;W++){if(Array.isArray(y.__webglFramebuffer[W]))for(let $=0;$<y.__webglFramebuffer[W].length;$++)a.deleteFramebuffer(y.__webglFramebuffer[W][$]);else a.deleteFramebuffer(y.__webglFramebuffer[W]);y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer[W])}else{if(Array.isArray(y.__webglFramebuffer))for(let W=0;W<y.__webglFramebuffer.length;W++)a.deleteFramebuffer(y.__webglFramebuffer[W]);else a.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&a.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let W=0;W<y.__webglColorRenderbuffer.length;W++)y.__webglColorRenderbuffer[W]&&a.deleteRenderbuffer(y.__webglColorRenderbuffer[W]);y.__webglDepthRenderbuffer&&a.deleteRenderbuffer(y.__webglDepthRenderbuffer)}const F=R.textures;for(let W=0,$=F.length;W<$;W++){const at=i.get(F[W]);at.__webglTexture&&(a.deleteTexture(at.__webglTexture),r.memory.textures--),i.remove(F[W])}i.remove(R)}let P=0;function X(){P=0}function z(){return P}function N(R){P=R}function V(){const R=P;return R>=n.maxTextures&&Tt("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+n.maxTextures),P+=1,R}function k(R){const y=[];return y.push(R.wrapS),y.push(R.wrapT),y.push(R.wrapR||0),y.push(R.magFilter),y.push(R.minFilter),y.push(R.anisotropy),y.push(R.internalFormat),y.push(R.format),y.push(R.type),y.push(R.generateMipmaps),y.push(R.premultiplyAlpha),y.push(R.flipY),y.push(R.unpackAlignment),y.push(R.colorSpace),y.join()}function K(R,y){const F=i.get(R);if(R.isVideoTexture&&O(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&F.__version!==R.version){const W=R.image;if(W===null)Tt("WebGLRenderer: Texture marked for update but no image data found.");else if(W.complete===!1)Tt("WebGLRenderer: Texture marked for update but image is incomplete");else{B(F,R,y);return}}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);e.bindTexture(a.TEXTURE_2D,F.__webglTexture,a.TEXTURE0+y)}function tt(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){B(F,R,y);return}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);e.bindTexture(a.TEXTURE_2D_ARRAY,F.__webglTexture,a.TEXTURE0+y)}function J(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){B(F,R,y);return}e.bindTexture(a.TEXTURE_3D,F.__webglTexture,a.TEXTURE0+y)}function it(R,y){const F=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&F.__version!==R.version){At(F,R,y);return}e.bindTexture(a.TEXTURE_CUBE_MAP,F.__webglTexture,a.TEXTURE0+y)}const ot={[So]:a.REPEAT,[yi]:a.CLAMP_TO_EDGE,[gu]:a.MIRRORED_REPEAT},Vt={[we]:a.NEAREST,[sv]:a.NEAREST_MIPMAP_NEAREST,[Go]:a.NEAREST_MIPMAP_LINEAR,[se]:a.LINEAR,[Vl]:a.LINEAR_MIPMAP_NEAREST,[pa]:a.LINEAR_MIPMAP_LINEAR},Qt={[hv]:a.NEVER,[mv]:a.ALWAYS,[uv]:a.LESS,[Gd]:a.LEQUAL,[dv]:a.EQUAL,[Vd]:a.GEQUAL,[fv]:a.GREATER,[pv]:a.NOTEQUAL};function qt(R,y){if(y.type===Di&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===se||y.magFilter===Vl||y.magFilter===Go||y.magFilter===pa||y.minFilter===se||y.minFilter===Vl||y.minFilter===Go||y.minFilter===pa)&&Tt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(R,a.TEXTURE_WRAP_S,ot[y.wrapS]),a.texParameteri(R,a.TEXTURE_WRAP_T,ot[y.wrapT]),(R===a.TEXTURE_3D||R===a.TEXTURE_2D_ARRAY)&&a.texParameteri(R,a.TEXTURE_WRAP_R,ot[y.wrapR]),a.texParameteri(R,a.TEXTURE_MAG_FILTER,Vt[y.magFilter]),a.texParameteri(R,a.TEXTURE_MIN_FILTER,Vt[y.minFilter]),y.compareFunction&&(a.texParameteri(R,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(R,a.TEXTURE_COMPARE_FUNC,Qt[y.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===we||y.minFilter!==Go&&y.minFilter!==pa||y.type===Di&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");a.texParameterf(R,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,n.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Y(R,y){let F=!1;R.__webglInit===void 0&&(R.__webglInit=!0,y.addEventListener("dispose",T));const W=y.source;let $=f.get(W);$===void 0&&($={},f.set(W,$));const at=k(y);if(at!==R.__cacheKey){$[at]===void 0&&($[at]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,F=!0),$[at].usedTimes++;const lt=$[R.__cacheKey];lt!==void 0&&($[R.__cacheKey].usedTimes--,lt.usedTimes===0&&I(y)),R.__cacheKey=at,R.__webglTexture=$[at].texture}return F}function rt(R,y,F){return Math.floor(Math.floor(R/F)/y)}function nt(R,y,F,W){const at=R.updateRanges;if(at.length===0)e.texSubImage2D(a.TEXTURE_2D,0,0,0,y.width,y.height,F,W,y.data);else{at.sort((It,ft)=>It.start-ft.start);let lt=0;for(let It=1;It<at.length;It++){const ft=at[lt],ut=at[It],Ut=ft.start+ft.count,Bt=rt(ut.start,y.width,4),Kt=rt(ft.start,y.width,4);ut.start<=Ut+1&&Bt===Kt&&rt(ut.start+ut.count-1,y.width,4)===Bt?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,at[lt]=ut)}at.length=lt+1;const Z=e.getParameter(a.UNPACK_ROW_LENGTH),Q=e.getParameter(a.UNPACK_SKIP_PIXELS),ht=e.getParameter(a.UNPACK_SKIP_ROWS);e.pixelStorei(a.UNPACK_ROW_LENGTH,y.width);for(let It=0,ft=at.length;It<ft;It++){const ut=at[It],Ut=Math.floor(ut.start/4),Bt=Math.ceil(ut.count/4),Kt=Ut%y.width,L=Math.floor(Ut/y.width),ct=Bt,j=1;e.pixelStorei(a.UNPACK_SKIP_PIXELS,Kt),e.pixelStorei(a.UNPACK_SKIP_ROWS,L),e.texSubImage2D(a.TEXTURE_2D,0,Kt,L,ct,j,F,W,y.data)}R.clearUpdateRanges(),e.pixelStorei(a.UNPACK_ROW_LENGTH,Z),e.pixelStorei(a.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(a.UNPACK_SKIP_ROWS,ht)}}function B(R,y,F){let W=a.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(W=a.TEXTURE_2D_ARRAY),y.isData3DTexture&&(W=a.TEXTURE_3D);const $=Y(R,y),at=y.source;e.bindTexture(W,R.__webglTexture,a.TEXTURE0+F);const lt=i.get(at);if(at.version!==lt.__version||$===!0){if(e.activeTexture(a.TEXTURE0+F),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){const j=ne.getPrimaries(ne.workingColorSpace),dt=y.colorSpace===Bs?null:ne.getPrimaries(y.colorSpace),vt=y.colorSpace===Bs||j===dt?a.NONE:a.BROWSER_DEFAULT_WEBGL;e.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=m(y.image,!1,n.maxTextureSize);Q=zi(y,Q);const ht=s.convert(y.format,y.colorSpace),It=s.convert(y.type);let ft=M(y.internalFormat,ht,It,y.normalized,y.colorSpace,y.isVideoTexture);qt(W,y);let ut;const Ut=y.mipmaps,Bt=y.isVideoTexture!==!0,Kt=lt.__version===void 0||$===!0,L=at.dataReady,ct=b(y,Q);if(y.isDepthTexture)ft=S(y.format===ma,y.type),Kt&&(Bt?e.texStorage2D(a.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(a.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,It,null));else if(y.isDataTexture)if(Ut.length>0){Bt&&Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Bt?L&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,It,ut.data):e.texImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,It,ut.data);y.generateMipmaps=!1}else Bt?(Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Q.width,Q.height),L&&nt(y,Q,ht,It)):e.texImage2D(a.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,It,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Bt&&Kt&&e.texStorage3D(a.TEXTURE_2D_ARRAY,ct,ft,Ut[0].width,Ut[0].height,Q.depth);for(let j=0,dt=Ut.length;j<dt;j++)if(ut=Ut[j],y.format!==_i)if(ht!==null)if(Bt){if(L)if(y.layerUpdates.size>0){const vt=Kf(ut.width,ut.height,y.format,y.type);for(const et of y.layerUpdates){const Rt=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,Rt)}y.clearLayerUpdates()}else e.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(a.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Bt?L&&e.texSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,It,ut.data):e.texImage3D(a.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,It,ut.data)}else{Bt&&Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],y.format!==_i?ht!==null?Bt?L&&e.compressedTexSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?L&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,It,ut.data):e.texImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,It,ut.data)}else if(y.isDataArrayTexture)if(Bt){if(Kt&&e.texStorage3D(a.TEXTURE_2D_ARRAY,ct,ft,Q.width,Q.height,Q.depth),L)if(y.layerUpdates.size>0){const j=Kf(Q.width,Q.height,y.format,y.type);for(const dt of y.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,It,vt)}y.clearLayerUpdates()}else e.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,It,Q.data)}else e.texImage3D(a.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,It,Q.data);else if(y.isData3DTexture)Bt?(Kt&&e.texStorage3D(a.TEXTURE_3D,ct,ft,Q.width,Q.height,Q.depth),L&&e.texSubImage3D(a.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,It,Q.data)):e.texImage3D(a.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,It,Q.data);else if(y.isFramebufferTexture){if(Kt)if(Bt)e.texStorage2D(a.TEXTURE_2D,ct,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ct;vt++)e.texImage2D(a.TEXTURE_2D,vt,ft,j,dt,0,ht,It,null),j>>=1,dt>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in a){const j=a.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(y),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,Q);else{const vt=a.RGBA,et=a.RGBA,Rt=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,vt,et,Rt,Q)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(Ut.length>0){if(Bt&&Kt){const j=me(Ut[0]);e.texStorage2D(a.TEXTURE_2D,ct,ft,j.width,j.height)}for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Bt?L&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ht,It,ut):e.texImage2D(a.TEXTURE_2D,j,ft,ht,It,ut);y.generateMipmaps=!1}else if(Bt){if(Kt){const j=me(Q);e.texStorage2D(a.TEXTURE_2D,ct,ft,j.width,j.height)}L&&e.texSubImage2D(a.TEXTURE_2D,0,0,0,ht,It,Q)}else e.texImage2D(a.TEXTURE_2D,0,ft,ht,It,Q);g(y)&&_(W),lt.__version=at.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function At(R,y,F){if(y.image.length!==6)return;const W=Y(R,y),$=y.source;e.bindTexture(a.TEXTURE_CUBE_MAP,R.__webglTexture,a.TEXTURE0+F);const at=i.get($);if($.version!==at.__version||W===!0){e.activeTexture(a.TEXTURE0+F);const lt=ne.getPrimaries(ne.workingColorSpace),Z=y.colorSpace===Bs?null:ne.getPrimaries(y.colorSpace),Q=y.colorSpace===Bs||lt===Z?a.NONE:a.BROWSER_DEFAULT_WEBGL;e.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment),e.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=y.isCompressedTexture||y.image[0].isCompressedTexture,It=y.image[0]&&y.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!It?ft[et]=m(y.image[et],!0,n.maxCubemapSize):ft[et]=It?y.image[et].image:y.image[et],ft[et]=zi(y,ft[et]);const ut=ft[0],Ut=s.convert(y.format,y.colorSpace),Bt=s.convert(y.type),Kt=M(y.internalFormat,Ut,Bt,y.normalized,y.colorSpace),L=y.isVideoTexture!==!0,ct=at.__version===void 0||W===!0,j=$.dataReady;let dt=b(y,ut);qt(a.TEXTURE_CUBE_MAP,y);let vt;if(ht){L&&ct&&e.texStorage2D(a.TEXTURE_CUBE_MAP,dt,Kt,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let Rt=0;Rt<vt.length;Rt++){const St=vt[Rt];y.format!==_i?Ut!==null?L?j&&e.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,0,0,St.width,St.height,Ut,St.data):e.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,Kt,St.width,St.height,0,St.data):Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,0,0,St.width,St.height,Ut,Bt,St.data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,Kt,St.width,St.height,0,Ut,Bt,St.data)}}}else{if(vt=y.mipmaps,L&&ct){vt.length>0&&dt++;const et=me(ft[0]);e.texStorage2D(a.TEXTURE_CUBE_MAP,dt,Kt,et.width,et.height)}for(let et=0;et<6;et++)if(It){L?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Ut,Bt,ft[et].data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Kt,ft[et].width,ft[et].height,0,Ut,Bt,ft[et].data);for(let Rt=0;Rt<vt.length;Rt++){const Ve=vt[Rt].image[et].image;L?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,0,0,Ve.width,Ve.height,Ut,Bt,Ve.data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,Kt,Ve.width,Ve.height,0,Ut,Bt,Ve.data)}}else{L?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Ut,Bt,ft[et]):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Kt,Ut,Bt,ft[et]);for(let Rt=0;Rt<vt.length;Rt++){const St=vt[Rt];L?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,0,0,Ut,Bt,St.image[et]):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,Kt,Ut,Bt,St.image[et])}}}g(y)&&_(a.TEXTURE_CUBE_MAP),at.__version=$.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Nt(R,y,F,W,$,at){const lt=s.convert(F.format,F.colorSpace),Z=s.convert(F.type),Q=M(F.internalFormat,lt,Z,F.normalized,F.colorSpace),ht=i.get(y),It=i.get(F);if(It.__renderTarget=y,!ht.__hasExternalTextures){const ft=Math.max(1,y.width>>at),ut=Math.max(1,y.height>>at);$===a.TEXTURE_3D||$===a.TEXTURE_2D_ARRAY?e.texImage3D($,at,Q,ft,ut,y.depth,0,lt,Z,null):e.texImage2D($,at,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(a.FRAMEBUFFER,R),ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,W,$,It.__webglTexture,0,Ge(y)):($===a.TEXTURE_2D||$>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,W,$,It.__webglTexture,at),e.bindFramebuffer(a.FRAMEBUFFER,null)}function Ct(R,y,F){if(a.bindRenderbuffer(a.RENDERBUFFER,R),y.depthBuffer){const W=y.depthTexture,$=W&&W.isDepthTexture?W.type:null,at=S(y.stencilBuffer,$),lt=y.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;ti(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ge(y),at,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ge(y),at,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,at,y.width,y.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,lt,a.RENDERBUFFER,R)}else{const W=y.textures;for(let $=0;$<W.length;$++){const at=W[$],lt=s.convert(at.format,at.colorSpace),Z=s.convert(at.type),Q=M(at.internalFormat,lt,Z,at.normalized,at.colorSpace);ti(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ge(y),Q,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ge(y),Q,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,Q,y.width,y.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function yt(R,y,F){const W=y.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(a.FRAMEBUFFER,R),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(y.depthTexture);if($.__renderTarget=y,(!$.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),W){if($.__webglInit===void 0&&($.__webglInit=!0,y.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=a.createTexture(),e.bindTexture(a.TEXTURE_CUBE_MAP,$.__webglTexture),qt(a.TEXTURE_CUBE_MAP,y.depthTexture);const ht=s.convert(y.depthTexture.format),It=s.convert(y.depthTexture.type);let ft;y.depthTexture.format===Ms?ft=a.DEPTH_COMPONENT24:y.depthTexture.format===ma&&(ft=a.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,y.width,y.height,0,ht,It,null)}}else K(y.depthTexture,0);const at=$.__webglTexture,lt=Ge(y),Z=W?a.TEXTURE_CUBE_MAP_POSITIVE_X+F:a.TEXTURE_2D,Q=y.depthTexture.format===ma?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(y.depthTexture.format===Ms)ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,at,0,lt):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,at,0);else if(y.depthTexture.format===ma)ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,at,0,lt):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,at,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ft(R){const y=i.get(R),F=R.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==R.depthTexture){const W=R.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),W){const $=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,W.removeEventListener("dispose",$)};W.addEventListener("dispose",$),y.__depthDisposeCallback=$}y.__boundDepthTexture=W}if(R.depthTexture&&!y.__autoAllocateDepthBuffer)if(F)for(let W=0;W<6;W++)yt(y.__webglFramebuffer[W],R,W);else{const W=R.texture.mipmaps;W&&W.length>0?yt(y.__webglFramebuffer[0],R,0):yt(y.__webglFramebuffer,R,0)}else if(F){y.__webglDepthbuffer=[];for(let W=0;W<6;W++)if(e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[W]),y.__webglDepthbuffer[W]===void 0)y.__webglDepthbuffer[W]=a.createRenderbuffer(),Ct(y.__webglDepthbuffer[W],R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,at=y.__webglDepthbuffer[W];a.bindRenderbuffer(a.RENDERBUFFER,at),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,at)}}else{const W=R.texture.mipmaps;if(W&&W.length>0?e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[0]):e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=a.createRenderbuffer(),Ct(y.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,at=y.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,at),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,at)}}e.bindFramebuffer(a.FRAMEBUFFER,null)}function kt(R,y,F){const W=i.get(R);y!==void 0&&Nt(W.__webglFramebuffer,R,R.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),F!==void 0&&Ft(R)}function zt(R){const y=R.texture,F=i.get(R),W=i.get(y);R.addEventListener("dispose",x);const $=R.textures,at=R.isWebGLCubeRenderTarget===!0,lt=$.length>1;if(lt||(W.__webglTexture===void 0&&(W.__webglTexture=a.createTexture()),W.__version=y.version,r.memory.textures++),at){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<y.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=a.createFramebuffer()}else F.__webglFramebuffer[Z]=a.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<y.mipmaps.length;Z++)F.__webglFramebuffer[Z]=a.createFramebuffer()}else F.__webglFramebuffer=a.createFramebuffer();if(lt)for(let Z=0,Q=$.length;Z<Q;Z++){const ht=i.get($[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=a.createTexture(),r.memory.textures++)}if(R.samples>0&&ti(R)===!1){F.__webglMultisampledFramebuffer=a.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(a.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const ht=s.convert(Q.format,Q.colorSpace),It=s.convert(Q.type),ft=M(Q.internalFormat,ht,It,Q.normalized,Q.colorSpace,R.isXRRenderTarget===!0),ut=Ge(R);a.renderbufferStorageMultisample(a.RENDERBUFFER,ut,ft,R.width,R.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Z,a.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}a.bindRenderbuffer(a.RENDERBUFFER,null),R.depthBuffer&&(F.__webglDepthRenderbuffer=a.createRenderbuffer(),Ct(F.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(a.FRAMEBUFFER,null)}}if(at){e.bindTexture(a.TEXTURE_CUBE_MAP,W.__webglTexture),qt(a.TEXTURE_CUBE_MAP,y);for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Nt(F.__webglFramebuffer[Z][Q],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Nt(F.__webglFramebuffer[Z],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(y)&&_(a.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=$.length;Z<Q;Z++){const ht=$[Z],It=i.get(ht);let ft=a.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(ft=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),e.bindTexture(ft,It.__webglTexture),qt(ft,ht),Nt(F.__webglFramebuffer,R,ht,a.COLOR_ATTACHMENT0+Z,ft,0),g(ht)&&_(ft)}e.unbindTexture()}else{let Z=a.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Z=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),e.bindTexture(Z,W.__webglTexture),qt(Z,y),y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Nt(F.__webglFramebuffer[Q],R,y,a.COLOR_ATTACHMENT0,Z,Q);else Nt(F.__webglFramebuffer,R,y,a.COLOR_ATTACHMENT0,Z,0);g(y)&&_(Z),e.unbindTexture()}R.depthBuffer&&Ft(R)}function fe(R){const y=R.textures;for(let F=0,W=y.length;F<W;F++){const $=y[F];if(g($)){const at=w(R),lt=i.get($).__webglTexture;e.bindTexture(at,lt),_(at),e.unbindTexture()}}}const pe=[],He=[];function Le(R){if(R.samples>0){if(ti(R)===!1){const y=R.textures,F=R.width,W=R.height;let $=a.COLOR_BUFFER_BIT;const at=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,lt=i.get(R),Z=y.length>1;if(Z)for(let ht=0;ht<y.length;ht++)e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.RENDERBUFFER,null),e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.TEXTURE_2D,null,0);e.bindFramebuffer(a.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=R.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<y.length;ht++){if(R.resolveDepthBuffer&&(R.depthBuffer&&($|=a.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&($|=a.STENCIL_BUFFER_BIT)),Z){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const It=i.get(y[ht]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,It,0)}a.blitFramebuffer(0,0,F,W,0,0,F,W,$,a.NEAREST),c===!0&&(pe.length=0,He.length=0,pe.push(a.COLOR_ATTACHMENT0+ht),R.depthBuffer&&R.resolveDepthBuffer===!1&&(pe.push(at),He.push(at),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,He)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,pe))}if(e.bindFramebuffer(a.READ_FRAMEBUFFER,null),e.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<y.length;ht++){e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const It=i.get(y[ht]).__webglTexture;e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.TEXTURE_2D,It,0)}e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const y=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[y])}}}function Ge(R){return Math.min(n.maxSamples,R.samples)}function ti(R){const y=i.get(R);return R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function O(R){const y=r.render.frame;h.get(R)!==y&&(h.set(R,y),R.update())}function zi(R,y){const F=R.colorSpace,W=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||F!==sl&&F!==Bs&&(ne.getTransfer(F)===ve?(W!==_i||$!==nn)&&Tt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ht("WebGLTextures: Unsupported texture color space:",F)),y}function me(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=V,this.resetTextureUnits=X,this.getTextureUnits=z,this.setTextureUnits=N,this.setTexture2D=K,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=it,this.rebindTextures=kt,this.setupRenderTarget=zt,this.updateRenderTargetMipmap=fe,this.updateMultisampleRenderTarget=Le,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=ti,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function OS(a,t){function e(i,n=Bs){let s;const r=ne.getTransfer(n);if(i===nn)return a.UNSIGNED_BYTE;if(i===Ud)return a.UNSIGNED_SHORT_4_4_4_4;if(i===Fd)return a.UNSIGNED_SHORT_5_5_5_1;if(i===cg)return a.UNSIGNED_INT_5_9_9_9_REV;if(i===lg)return a.UNSIGNED_INT_10F_11F_11F_REV;if(i===rg)return a.BYTE;if(i===og)return a.SHORT;if(i===wo)return a.UNSIGNED_SHORT;if(i===Od)return a.INT;if(i===vn)return a.UNSIGNED_INT;if(i===Di)return a.FLOAT;if(i===ze)return a.HALF_FLOAT;if(i===hg)return a.ALPHA;if(i===ug)return a.RGB;if(i===_i)return a.RGBA;if(i===Ms)return a.DEPTH_COMPONENT;if(i===ma)return a.DEPTH_STENCIL;if(i===El)return a.RED;if(i===kd)return a.RED_INTEGER;if(i===wa)return a.RG;if(i===zd)return a.RG_INTEGER;if(i===Bd)return a.RGBA_INTEGER;if(i===Bc||i===Hc||i===Gc||i===Vc)if(r===ve)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Bc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Vc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Bc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Vc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===vu||i===Mu||i===xu||i===yu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===vu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Mu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===xu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===yu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===_u||i===Su||i===wu||i===bu||i===Eu||i===Qc||i===Au)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===_u||i===Su)return r===ve?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===wu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===bu)return s.COMPRESSED_R11_EAC;if(i===Eu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Qc)return s.COMPRESSED_RG11_EAC;if(i===Au)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Tu||i===Ru||i===Du||i===Cu||i===Iu||i===Pu||i===Lu||i===Nu||i===Ou||i===Uu||i===Fu||i===ku||i===zu||i===Bu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Tu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ru)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Du)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Cu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Iu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Pu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Lu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Nu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ou)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Uu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Fu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ku)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===zu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Bu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Hu||i===Gu||i===Vu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Hu)return r===ve?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Gu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Vu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Wu||i===Xu||i===tl||i===qu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Wu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Xu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===tl)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===qu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===bo?a.UNSIGNED_INT_24_8:a[i]!==void 0?a[i]:null}return{convert:e}}const US=`
|
|
4787
|
+
}`,CS=[new D(1,0,0),new D(-1,0,0),new D(0,1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1)],IS=[new D(0,-1,0),new D(0,-1,0),new D(0,0,1),new D(0,0,-1),new D(0,-1,0),new D(0,-1,0)],gp=new Zt,Vr=new D,Eh=new D;function PS(a,t,e){let i=new $d;const n=new Mt,s=new Mt,r=new ie,o=new MM,c=new xM,l={},h=e.maxTextureSize,u={[Ys]:Ue,[Ue]:Ys,[en]:en},d=new ae({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Mt},radius:{value:4}},vertexShader:RS,fragmentShader:DS}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const p=new ue;p.setAttribute("position",new te(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new Dt(p,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ro;let g=this.type;this.render=function(b,T,x){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===k2&&(Tt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ro);const A=a.getRenderTarget(),I=a.getActiveCubeFace(),C=a.getActiveMipmapLevel(),L=a.state;L.setBlending(jn),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const W=g!==this.type;W&&T.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(P=>P.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,P=b.length;X<P;X++){const B=b[X],k=B.shadow;if(k===void 0){Tt("WebGLShadowMap:",B,"has no shadow.");continue}if(k.autoUpdate===!1&&k.needsUpdate===!1)continue;n.copy(k.mapSize);const K=k.getFrameExtents();n.multiply(K),s.copy(k.mapSize),(n.x>h||n.y>h)&&(n.x>h&&(s.x=Math.floor(h/K.x),n.x=s.x*K.x,k.mapSize.x=s.x),n.y>h&&(s.y=Math.floor(h/K.y),n.y=s.y*K.y,k.mapSize.y=s.y));const tt=a.state.buffers.depth.getReversed();if(k.camera._reversedDepth=tt,k.map===null||W===!0){if(k.map!==null&&(k.map.depthTexture!==null&&(k.map.depthTexture.dispose(),k.map.depthTexture=null),k.map.dispose()),this.type===Qr){if(B.isPointLight){Tt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}k.map=new je(n.x,n.y,{format:wa,type:ze,minFilter:se,magFilter:se,generateMipmaps:!1}),k.map.texture.name=B.name+".shadowMap",k.map.depthTexture=new Ks(n.x,n.y,Di),k.map.depthTexture.name=B.name+".shadowMapDepth",k.map.depthTexture.format=Ms,k.map.depthTexture.compareFunction=null,k.map.depthTexture.minFilter=we,k.map.depthTexture.magFilter=we}else B.isPointLight?(k.map=new To(n.x),k.map.depthTexture=new dM(n.x,vn)):(k.map=new je(n.x,n.y),k.map.depthTexture=new Ks(n.x,n.y,vn)),k.map.depthTexture.name=B.name+".shadowMap",k.map.depthTexture.format=Ms,this.type===ro?(k.map.depthTexture.compareFunction=tt?Vd:Gd,k.map.depthTexture.minFilter=se,k.map.depthTexture.magFilter=se):(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 it=0;it<J;it++){if(k.map.isWebGLCubeRenderTarget)a.setRenderTarget(k.map,it),a.clear();else{it===0&&(a.setRenderTarget(k.map),a.clear());const rt=k.getViewport(it);r.set(s.x*rt.x,s.y*rt.y,s.x*rt.z,s.y*rt.w),L.viewport(r)}if(B.isPointLight){const rt=k.camera,Gt=k.matrix,Jt=B.distance||rt.far;Jt!==rt.far&&(rt.far=Jt,rt.updateProjectionMatrix()),Vr.setFromMatrixPosition(B.matrixWorld),rt.position.copy(Vr),Eh.copy(rt.position),Eh.add(CS[it]),rt.up.copy(IS[it]),rt.lookAt(Eh),rt.updateMatrixWorld(),Gt.makeTranslation(-Vr.x,-Vr.y,-Vr.z),gp.multiplyMatrices(rt.projectionMatrix,rt.matrixWorldInverse),k._frustum.setFromProjectionMatrix(gp,rt.coordinateSystem,rt.reversedDepth)}else k.updateMatrices(B);i=k.getFrustum(),M(T,x,k.camera,B,this.type)}k.isPointLightShadow!==!0&&this.type===Qr&&_(k,x),k.needsUpdate=!1}g=this.type,m.needsUpdate=!1,a.setRenderTarget(A,I,C)};function _(b,T){const x=t.update(v);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new je(n.x,n.y,{format:wa,type:ze})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,a.setRenderTarget(b.mapPass),a.clear(),a.renderBufferDirect(T,null,x,d,v,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,a.setRenderTarget(b.map),a.clear(),a.renderBufferDirect(T,null,x,f,v,null)}function w(b,T,x,A){let I=null;const C=x.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)I=C;else if(I=x.isPointLight===!0?c:o,a.localClippingEnabled&&T.clipShadows===!0&&Array.isArray(T.clippingPlanes)&&T.clippingPlanes.length!==0||T.displacementMap&&T.displacementScale!==0||T.alphaMap&&T.alphaTest>0||T.map&&T.alphaTest>0||T.alphaToCoverage===!0){const L=I.uuid,W=T.uuid;let X=l[L];X===void 0&&(X={},l[L]=X);let P=X[W];P===void 0&&(P=I.clone(),X[W]=P,T.addEventListener("dispose",S)),I=P}if(I.visible=T.visible,I.wireframe=T.wireframe,A===Qr?I.side=T.shadowSide!==null?T.shadowSide:T.side:I.side=T.shadowSide!==null?T.shadowSide:u[T.side],I.alphaMap=T.alphaMap,I.alphaTest=T.alphaToCoverage===!0?.5:T.alphaTest,I.map=T.map,I.clipShadows=T.clipShadows,I.clippingPlanes=T.clippingPlanes,I.clipIntersection=T.clipIntersection,I.displacementMap=T.displacementMap,I.displacementScale=T.displacementScale,I.displacementBias=T.displacementBias,I.wireframeLinewidth=T.wireframeLinewidth,I.linewidth=T.linewidth,x.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const L=a.properties.get(I);L.light=x}return I}function M(b,T,x,A,I){if(b.visible===!1)return;if(b.layers.test(T.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&I===Qr)&&(!b.frustumCulled||i.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(x.matrixWorldInverse,b.matrixWorld);const W=t.update(b),X=b.material;if(Array.isArray(X)){const P=W.groups;for(let B=0,k=P.length;B<k;B++){const K=P[B],tt=X[K.materialIndex];if(tt&&tt.visible){const J=w(b,tt,A,I);b.onBeforeShadow(a,b,T,x,W,J,K),a.renderBufferDirect(x,null,W,J,b,K),b.onAfterShadow(a,b,T,x,W,J,K)}}}else if(X.visible){const P=w(b,X,A,I);b.onBeforeShadow(a,b,T,x,W,P,null),a.renderBufferDirect(x,null,W,P,b,null),b.onAfterShadow(a,b,T,x,W,P,null)}}const L=b.children;for(let W=0,X=L.length;W<X;W++)M(L[W],T,x,A,I)}function S(b){b.target.removeEventListener("dispose",S);for(const x in l){const A=l[x],I=b.target.uuid;I in A&&(A[I].dispose(),delete A[I])}}}function LS(a,t){function e(){let N=!1;const ct=new ie;let j=null;const dt=new ie(0,0,0,0);return{setMask:function(vt){j!==vt&&!N&&(a.colorMask(vt,vt,vt,vt),j=vt)},setLocked:function(vt){N=vt},setClear:function(vt,et,Rt,St,Ve){Ve===!0&&(vt*=St,et*=St,Rt*=St),ct.set(vt,et,Rt,St),dt.equals(ct)===!1&&(a.clearColor(vt,et,Rt,St),dt.copy(ct))},reset:function(){N=!1,j=null,dt.set(-1,0,0,0)}}}function i(){let N=!1,ct=!1,j=null,dt=null,vt=null;return{setReversed:function(et){if(ct!==et){const Rt=t.get("EXT_clip_control");et?Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.ZERO_TO_ONE_EXT):Rt.clipControlEXT(Rt.LOWER_LEFT_EXT,Rt.NEGATIVE_ONE_TO_ONE_EXT),ct=et;const St=vt;vt=null,this.setClear(St)}},getReversed:function(){return ct},setTest:function(et){et?nt(a.DEPTH_TEST):z(a.DEPTH_TEST)},setMask:function(et){j!==et&&!N&&(a.depthMask(et),j=et)},setFunc:function(et){if(ct&&(et=yv[et]),dt!==et){switch(et){case lu:a.depthFunc(a.NEVER);break;case hu:a.depthFunc(a.ALWAYS);break;case uu:a.depthFunc(a.LESS);break;case xr:a.depthFunc(a.LEQUAL);break;case du:a.depthFunc(a.EQUAL);break;case fu:a.depthFunc(a.GEQUAL);break;case pu:a.depthFunc(a.GREATER);break;case mu:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}dt=et}},setLocked:function(et){N=et},setClear:function(et){vt!==et&&(vt=et,ct&&(et=1-et),a.clearDepth(et))},reset:function(){N=!1,j=null,dt=null,vt=null,ct=!1}}}function n(){let N=!1,ct=null,j=null,dt=null,vt=null,et=null,Rt=null,St=null,Ve=null;return{setTest:function(Ae){N||(Ae?nt(a.STENCIL_TEST):z(a.STENCIL_TEST))},setMask:function(Ae){ct!==Ae&&!N&&(a.stencilMask(Ae),ct=Ae)},setFunc:function(Ae,Ln,Nn){(j!==Ae||dt!==Ln||vt!==Nn)&&(a.stencilFunc(Ae,Ln,Nn),j=Ae,dt=Ln,vt=Nn)},setOp:function(Ae,Ln,Nn){(et!==Ae||Rt!==Ln||St!==Nn)&&(a.stencilOp(Ae,Ln,Nn),et=Ae,Rt=Ln,St=Nn)},setLocked:function(Ae){N=Ae},setClear:function(Ae){Ve!==Ae&&(a.clearStencil(Ae),Ve=Ae)},reset:function(){N=!1,ct=null,j=null,dt=null,vt=null,et=null,Rt=null,St=null,Ve=null}}}const s=new e,r=new i,o=new n,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new st(0,0,0),A=0,I=!1,C=null,L=null,W=null,X=null,P=null;const B=a.getParameter(a.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let k=!1,K=0;const tt=a.getParameter(a.VERSION);tt.indexOf("WebGL")!==-1?(K=parseFloat(/^WebGL (\d)/.exec(tt)[1]),k=K>=1):tt.indexOf("OpenGL ES")!==-1&&(K=parseFloat(/^OpenGL ES (\d)/.exec(tt)[1]),k=K>=2);let J=null,it={};const rt=a.getParameter(a.SCISSOR_BOX),Gt=a.getParameter(a.VIEWPORT),Jt=new ie().fromArray(rt),qt=new ie().fromArray(Gt);function Y(N,ct,j,dt){const vt=new Uint8Array(4),et=a.createTexture();a.bindTexture(N,et),a.texParameteri(N,a.TEXTURE_MIN_FILTER,a.NEAREST),a.texParameteri(N,a.TEXTURE_MAG_FILTER,a.NEAREST);for(let Rt=0;Rt<j;Rt++)N===a.TEXTURE_3D||N===a.TEXTURE_2D_ARRAY?a.texImage3D(ct,0,a.RGBA,1,1,dt,0,a.RGBA,a.UNSIGNED_BYTE,vt):a.texImage2D(ct+Rt,0,a.RGBA,1,1,0,a.RGBA,a.UNSIGNED_BYTE,vt);return et}const at={};at[a.TEXTURE_2D]=Y(a.TEXTURE_2D,a.TEXTURE_2D,1),at[a.TEXTURE_CUBE_MAP]=Y(a.TEXTURE_CUBE_MAP,a.TEXTURE_CUBE_MAP_POSITIVE_X,6),at[a.TEXTURE_2D_ARRAY]=Y(a.TEXTURE_2D_ARRAY,a.TEXTURE_2D_ARRAY,1,1),at[a.TEXTURE_3D]=Y(a.TEXTURE_3D,a.TEXTURE_3D,1,1),s.setClear(0,0,0,1),r.setClear(1),o.setClear(0),nt(a.DEPTH_TEST),r.setFunc(xr),fe(!1),pe(j0),nt(a.CULL_FACE),kt(jn);function nt(N){h[N]!==!0&&(a.enable(N),h[N]=!0)}function z(N){h[N]!==!1&&(a.disable(N),h[N]=!1)}function At(N,ct){return d[N]!==ct?(a.bindFramebuffer(N,ct),d[N]=ct,N===a.DRAW_FRAMEBUFFER&&(d[a.FRAMEBUFFER]=ct),N===a.FRAMEBUFFER&&(d[a.DRAW_FRAMEBUFFER]=ct),!0):!1}function Nt(N,ct){let j=p,dt=!1;if(N){j=f.get(ct),j===void 0&&(j=[],f.set(ct,j));const vt=N.textures;if(j.length!==vt.length||j[0]!==a.COLOR_ATTACHMENT0){for(let et=0,Rt=vt.length;et<Rt;et++)j[et]=a.COLOR_ATTACHMENT0+et;j.length=vt.length,dt=!0}}else j[0]!==a.BACK&&(j[0]=a.BACK,dt=!0);dt&&a.drawBuffers(j)}function Ct(N){return v!==N?(a.useProgram(N),v=N,!0):!1}const yt={[ca]:a.FUNC_ADD,[z2]:a.FUNC_SUBTRACT,[B2]:a.FUNC_REVERSE_SUBTRACT};yt[H2]=a.MIN,yt[G2]=a.MAX;const Ft={[V2]:a.ZERO,[yo]:a.ONE,[W2]:a.SRC_COLOR,[cu]:a.SRC_ALPHA,[Z2]:a.SRC_ALPHA_SATURATE,[K2]:a.DST_COLOR,[q2]:a.DST_ALPHA,[X2]:a.ONE_MINUS_SRC_COLOR,[_o]:a.ONE_MINUS_SRC_ALPHA,[$2]:a.ONE_MINUS_DST_COLOR,[Y2]:a.ONE_MINUS_DST_ALPHA,[J2]:a.CONSTANT_COLOR,[j2]:a.ONE_MINUS_CONSTANT_COLOR,[Q2]:a.CONSTANT_ALPHA,[tv]:a.ONE_MINUS_CONSTANT_ALPHA};function kt(N,ct,j,dt,vt,et,Rt,St,Ve,Ae){if(N===jn){m===!0&&(z(a.BLEND),m=!1);return}if(m===!1&&(nt(a.BLEND),m=!0),N!==wl){if(N!==g||Ae!==I){if((_!==ca||S!==ca)&&(a.blendEquation(a.FUNC_ADD),_=ca,S=ca),Ae)switch(N){case Xs:a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFunc(a.ONE,a.ONE);break;case Q0:a.blendFuncSeparate(a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ZERO,a.ONE);break;case tf:a.blendFuncSeparate(a.DST_COLOR,a.ONE_MINUS_SRC_ALPHA,a.ZERO,a.ONE);break;default:Ht("WebGLState: Invalid blending: ",N);break}else switch(N){case Xs:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA);break;case Ci:a.blendFuncSeparate(a.SRC_ALPHA,a.ONE,a.ONE,a.ONE);break;case Q0:Ht("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case tf:Ht("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Ht("WebGLState: Invalid blending: ",N);break}w=null,M=null,b=null,T=null,x.set(0,0,0),A=0,g=N,I=Ae}return}vt=vt||ct,et=et||j,Rt=Rt||dt,(ct!==_||vt!==S)&&(a.blendEquationSeparate(yt[ct],yt[vt]),_=ct,S=vt),(j!==w||dt!==M||et!==b||Rt!==T)&&(a.blendFuncSeparate(Ft[j],Ft[dt],Ft[et],Ft[Rt]),w=j,M=dt,b=et,T=Rt),(St.equals(x)===!1||Ve!==A)&&(a.blendColor(St.r,St.g,St.b,Ve),x.copy(St),A=Ve),g=N,I=!1}function zt(N,ct){N.side===en?z(a.CULL_FACE):nt(a.CULL_FACE);let j=N.side===Ue;ct&&(j=!j),fe(j),N.blending===Xs&&N.transparent===!1?kt(jn):kt(N.blending,N.blendEquation,N.blendSrc,N.blendDst,N.blendEquationAlpha,N.blendSrcAlpha,N.blendDstAlpha,N.blendColor,N.blendAlpha,N.premultipliedAlpha),r.setFunc(N.depthFunc),r.setTest(N.depthTest),r.setMask(N.depthWrite),s.setMask(N.colorWrite);const dt=N.stencilWrite;o.setTest(dt),dt&&(o.setMask(N.stencilWriteMask),o.setFunc(N.stencilFunc,N.stencilRef,N.stencilFuncMask),o.setOp(N.stencilFail,N.stencilZFail,N.stencilZPass)),Le(N.polygonOffset,N.polygonOffsetFactor,N.polygonOffsetUnits),N.alphaToCoverage===!0?nt(a.SAMPLE_ALPHA_TO_COVERAGE):z(a.SAMPLE_ALPHA_TO_COVERAGE)}function fe(N){C!==N&&(N?a.frontFace(a.CW):a.frontFace(a.CCW),C=N)}function pe(N){N!==U2?(nt(a.CULL_FACE),N!==L&&(N===j0?a.cullFace(a.BACK):N===F2?a.cullFace(a.FRONT):a.cullFace(a.FRONT_AND_BACK))):z(a.CULL_FACE),L=N}function He(N){N!==W&&(k&&a.lineWidth(N),W=N)}function Le(N,ct,j){N?(nt(a.POLYGON_OFFSET_FILL),(X!==ct||P!==j)&&(X=ct,P=j,r.getReversed()&&(ct=-ct),a.polygonOffset(ct,j))):z(a.POLYGON_OFFSET_FILL)}function Ge(N){N?nt(a.SCISSOR_TEST):z(a.SCISSOR_TEST)}function ti(N){N===void 0&&(N=a.TEXTURE0+B-1),J!==N&&(a.activeTexture(N),J=N)}function O(N,ct,j){j===void 0&&(J===null?j=a.TEXTURE0+B-1:j=J);let dt=it[j];dt===void 0&&(dt={type:void 0,texture:void 0},it[j]=dt),(dt.type!==N||dt.texture!==ct)&&(J!==j&&(a.activeTexture(j),J=j),a.bindTexture(N,ct||at[N]),dt.type=N,dt.texture=ct)}function zi(){const N=it[J];N!==void 0&&N.type!==void 0&&(a.bindTexture(N.type,null),N.type=void 0,N.texture=void 0)}function me(){try{a.compressedTexImage2D(...arguments)}catch(N){Ht("WebGLState:",N)}}function R(){try{a.compressedTexImage3D(...arguments)}catch(N){Ht("WebGLState:",N)}}function y(){try{a.texSubImage2D(...arguments)}catch(N){Ht("WebGLState:",N)}}function F(){try{a.texSubImage3D(...arguments)}catch(N){Ht("WebGLState:",N)}}function V(){try{a.compressedTexSubImage2D(...arguments)}catch(N){Ht("WebGLState:",N)}}function $(){try{a.compressedTexSubImage3D(...arguments)}catch(N){Ht("WebGLState:",N)}}function ot(){try{a.texStorage2D(...arguments)}catch(N){Ht("WebGLState:",N)}}function lt(){try{a.texStorage3D(...arguments)}catch(N){Ht("WebGLState:",N)}}function Z(){try{a.texImage2D(...arguments)}catch(N){Ht("WebGLState:",N)}}function Q(){try{a.texImage3D(...arguments)}catch(N){Ht("WebGLState:",N)}}function ht(N){return u[N]!==void 0?u[N]:a.getParameter(N)}function It(N,ct){u[N]!==ct&&(a.pixelStorei(N,ct),u[N]=ct)}function ft(N){Jt.equals(N)===!1&&(a.scissor(N.x,N.y,N.z,N.w),Jt.copy(N))}function ut(N){qt.equals(N)===!1&&(a.viewport(N.x,N.y,N.z,N.w),qt.copy(N))}function Ut(N,ct){let j=l.get(ct);j===void 0&&(j=new WeakMap,l.set(ct,j));let dt=j.get(N);dt===void 0&&(dt=a.getUniformBlockIndex(ct,N.name),j.set(N,dt))}function Bt(N,ct){const dt=l.get(ct).get(N);c.get(ct)!==dt&&(a.uniformBlockBinding(ct,dt,N.__bindingPointIndex),c.set(ct,dt))}function Kt(){a.disable(a.BLEND),a.disable(a.CULL_FACE),a.disable(a.DEPTH_TEST),a.disable(a.POLYGON_OFFSET_FILL),a.disable(a.SCISSOR_TEST),a.disable(a.STENCIL_TEST),a.disable(a.SAMPLE_ALPHA_TO_COVERAGE),a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ONE,a.ZERO),a.blendFuncSeparate(a.ONE,a.ZERO,a.ONE,a.ZERO),a.blendColor(0,0,0,0),a.colorMask(!0,!0,!0,!0),a.clearColor(0,0,0,0),a.depthMask(!0),a.depthFunc(a.LESS),r.setReversed(!1),a.clearDepth(1),a.stencilMask(4294967295),a.stencilFunc(a.ALWAYS,0,4294967295),a.stencilOp(a.KEEP,a.KEEP,a.KEEP),a.clearStencil(0),a.cullFace(a.BACK),a.frontFace(a.CCW),a.polygonOffset(0,0),a.activeTexture(a.TEXTURE0),a.bindFramebuffer(a.FRAMEBUFFER,null),a.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),a.bindFramebuffer(a.READ_FRAMEBUFFER,null),a.useProgram(null),a.lineWidth(1),a.scissor(0,0,a.canvas.width,a.canvas.height),a.viewport(0,0,a.canvas.width,a.canvas.height),a.pixelStorei(a.PACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_ALIGNMENT,4),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,!1),a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,a.BROWSER_DEFAULT_WEBGL),a.pixelStorei(a.PACK_ROW_LENGTH,0),a.pixelStorei(a.PACK_SKIP_PIXELS,0),a.pixelStorei(a.PACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_ROW_LENGTH,0),a.pixelStorei(a.UNPACK_IMAGE_HEIGHT,0),a.pixelStorei(a.UNPACK_SKIP_PIXELS,0),a.pixelStorei(a.UNPACK_SKIP_ROWS,0),a.pixelStorei(a.UNPACK_SKIP_IMAGES,0),h={},u={},J=null,it={},d={},f=new WeakMap,p=[],v=null,m=!1,g=null,_=null,w=null,M=null,S=null,b=null,T=null,x=new st(0,0,0),A=0,I=!1,C=null,L=null,W=null,X=null,P=null,Jt.set(0,0,a.canvas.width,a.canvas.height),qt.set(0,0,a.canvas.width,a.canvas.height),s.reset(),r.reset(),o.reset()}return{buffers:{color:s,depth:r,stencil:o},enable:nt,disable:z,bindFramebuffer:At,drawBuffers:Nt,useProgram:Ct,setBlending:kt,setMaterial:zt,setFlipSided:fe,setCullFace:pe,setLineWidth:He,setPolygonOffset:Le,setScissorTest:Ge,activeTexture:ti,bindTexture:O,unbindTexture:zi,compressedTexImage2D:me,compressedTexImage3D:R,texImage2D:Z,texImage3D:Q,pixelStorei:It,getParameter:ht,updateUBOMapping:Ut,uniformBlockBinding:Bt,texStorage2D:ot,texStorage3D:lt,texSubImage2D:y,texSubImage3D:F,compressedTexSubImage2D:V,compressedTexSubImage3D:$,scissor:ft,viewport:ut,reset:Kt}}function NS(a,t,e,i,n,s,r){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 Mt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(R,y){return p?new OffscreenCanvas(R,y):Ao("canvas")}function m(R,y,F){let V=1;const $=me(R);if(($.width>F||$.height>F)&&(V=F/Math.max($.width,$.height)),V<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const ot=Math.floor(V*$.width),lt=Math.floor(V*$.height);d===void 0&&(d=v(ot,lt));const Z=y?v(ot,lt):d;return Z.width=ot,Z.height=lt,Z.getContext("2d").drawImage(R,0,0,ot,lt),Tt("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+ot+"x"+lt+")."),Z}else return"data"in R&&Tt("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function _(R){a.generateMipmap(R)}function w(R){return R.isWebGLCubeRenderTarget?a.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?a.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?a.TEXTURE_2D_ARRAY:a.TEXTURE_2D}function M(R,y,F,V,$,ot=!1){if(R!==null){if(a[R]!==void 0)return a[R];Tt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let lt;V&&(lt=t.get("EXT_texture_norm16"),lt||Tt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=y;if(y===a.RED&&(F===a.FLOAT&&(Z=a.R32F),F===a.HALF_FLOAT&&(Z=a.R16F),F===a.UNSIGNED_BYTE&&(Z=a.R8),F===a.UNSIGNED_SHORT&<&&(Z=lt.R16_EXT),F===a.SHORT&<&&(Z=lt.R16_SNORM_EXT)),y===a.RED_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.R8UI),F===a.UNSIGNED_SHORT&&(Z=a.R16UI),F===a.UNSIGNED_INT&&(Z=a.R32UI),F===a.BYTE&&(Z=a.R8I),F===a.SHORT&&(Z=a.R16I),F===a.INT&&(Z=a.R32I)),y===a.RG&&(F===a.FLOAT&&(Z=a.RG32F),F===a.HALF_FLOAT&&(Z=a.RG16F),F===a.UNSIGNED_BYTE&&(Z=a.RG8),F===a.UNSIGNED_SHORT&<&&(Z=lt.RG16_EXT),F===a.SHORT&<&&(Z=lt.RG16_SNORM_EXT)),y===a.RG_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RG8UI),F===a.UNSIGNED_SHORT&&(Z=a.RG16UI),F===a.UNSIGNED_INT&&(Z=a.RG32UI),F===a.BYTE&&(Z=a.RG8I),F===a.SHORT&&(Z=a.RG16I),F===a.INT&&(Z=a.RG32I)),y===a.RGB_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGB8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGB16UI),F===a.UNSIGNED_INT&&(Z=a.RGB32UI),F===a.BYTE&&(Z=a.RGB8I),F===a.SHORT&&(Z=a.RGB16I),F===a.INT&&(Z=a.RGB32I)),y===a.RGBA_INTEGER&&(F===a.UNSIGNED_BYTE&&(Z=a.RGBA8UI),F===a.UNSIGNED_SHORT&&(Z=a.RGBA16UI),F===a.UNSIGNED_INT&&(Z=a.RGBA32UI),F===a.BYTE&&(Z=a.RGBA8I),F===a.SHORT&&(Z=a.RGBA16I),F===a.INT&&(Z=a.RGBA32I)),y===a.RGB&&(F===a.UNSIGNED_SHORT&<&&(Z=lt.RGB16_EXT),F===a.SHORT&<&&(Z=lt.RGB16_SNORM_EXT),F===a.UNSIGNED_INT_5_9_9_9_REV&&(Z=a.RGB9_E5),F===a.UNSIGNED_INT_10F_11F_11F_REV&&(Z=a.R11F_G11F_B10F)),y===a.RGBA){const Q=ot?al:ne.getTransfer($);F===a.FLOAT&&(Z=a.RGBA32F),F===a.HALF_FLOAT&&(Z=a.RGBA16F),F===a.UNSIGNED_BYTE&&(Z=Q===ve?a.SRGB8_ALPHA8:a.RGBA8),F===a.UNSIGNED_SHORT&<&&(Z=lt.RGBA16_EXT),F===a.SHORT&<&&(Z=lt.RGBA16_SNORM_EXT),F===a.UNSIGNED_SHORT_4_4_4_4&&(Z=a.RGBA4),F===a.UNSIGNED_SHORT_5_5_5_1&&(Z=a.RGB5_A1)}return(Z===a.R16F||Z===a.R32F||Z===a.RG16F||Z===a.RG32F||Z===a.RGBA16F||Z===a.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(R,y){let F;return R?y===null||y===vn||y===bo?F=a.DEPTH24_STENCIL8:y===Di?F=a.DEPTH32F_STENCIL8:y===wo&&(F=a.DEPTH24_STENCIL8,Tt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):y===null||y===vn||y===bo?F=a.DEPTH_COMPONENT24:y===Di?F=a.DEPTH_COMPONENT32F:y===wo&&(F=a.DEPTH_COMPONENT16),F}function b(R,y){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==we&&R.minFilter!==se?Math.log2(Math.max(y.width,y.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?y.mipmaps.length:1}function T(R){const y=R.target;y.removeEventListener("dispose",T),A(y),y.isVideoTexture&&h.delete(y),y.isHTMLTexture&&u.delete(y)}function x(R){const y=R.target;y.removeEventListener("dispose",x),C(y)}function A(R){const y=i.get(R);if(y.__webglInit===void 0)return;const F=R.source,V=f.get(F);if(V){const $=V[y.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(V).length===0&&f.delete(F)}i.remove(R)}function I(R){const y=i.get(R);a.deleteTexture(y.__webglTexture);const F=R.source,V=f.get(F);delete V[y.__cacheKey],r.memory.textures--}function C(R){const y=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let V=0;V<6;V++){if(Array.isArray(y.__webglFramebuffer[V]))for(let $=0;$<y.__webglFramebuffer[V].length;$++)a.deleteFramebuffer(y.__webglFramebuffer[V][$]);else a.deleteFramebuffer(y.__webglFramebuffer[V]);y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer[V])}else{if(Array.isArray(y.__webglFramebuffer))for(let V=0;V<y.__webglFramebuffer.length;V++)a.deleteFramebuffer(y.__webglFramebuffer[V]);else a.deleteFramebuffer(y.__webglFramebuffer);if(y.__webglDepthbuffer&&a.deleteRenderbuffer(y.__webglDepthbuffer),y.__webglMultisampledFramebuffer&&a.deleteFramebuffer(y.__webglMultisampledFramebuffer),y.__webglColorRenderbuffer)for(let V=0;V<y.__webglColorRenderbuffer.length;V++)y.__webglColorRenderbuffer[V]&&a.deleteRenderbuffer(y.__webglColorRenderbuffer[V]);y.__webglDepthRenderbuffer&&a.deleteRenderbuffer(y.__webglDepthRenderbuffer)}const F=R.textures;for(let V=0,$=F.length;V<$;V++){const ot=i.get(F[V]);ot.__webglTexture&&(a.deleteTexture(ot.__webglTexture),r.memory.textures--),i.remove(F[V])}i.remove(R)}let L=0;function W(){L=0}function X(){return L}function P(R){L=R}function B(){const R=L;return R>=n.maxTextures&&Tt("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+n.maxTextures),L+=1,R}function k(R){const y=[];return y.push(R.wrapS),y.push(R.wrapT),y.push(R.wrapR||0),y.push(R.magFilter),y.push(R.minFilter),y.push(R.anisotropy),y.push(R.internalFormat),y.push(R.format),y.push(R.type),y.push(R.generateMipmaps),y.push(R.premultiplyAlpha),y.push(R.flipY),y.push(R.unpackAlignment),y.push(R.colorSpace),y.join()}function K(R,y){const F=i.get(R);if(R.isVideoTexture&&O(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&F.__version!==R.version){const V=R.image;if(V===null)Tt("WebGLRenderer: Texture marked for update but no image data found.");else if(V.complete===!1)Tt("WebGLRenderer: Texture marked for update but image is incomplete");else{z(F,R,y);return}}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);e.bindTexture(a.TEXTURE_2D,F.__webglTexture,a.TEXTURE0+y)}function tt(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){z(F,R,y);return}else R.isExternalTexture&&(F.__webglTexture=R.sourceTexture?R.sourceTexture:null);e.bindTexture(a.TEXTURE_2D_ARRAY,F.__webglTexture,a.TEXTURE0+y)}function J(R,y){const F=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&F.__version!==R.version){z(F,R,y);return}e.bindTexture(a.TEXTURE_3D,F.__webglTexture,a.TEXTURE0+y)}function it(R,y){const F=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&F.__version!==R.version){At(F,R,y);return}e.bindTexture(a.TEXTURE_CUBE_MAP,F.__webglTexture,a.TEXTURE0+y)}const rt={[So]:a.REPEAT,[yi]:a.CLAMP_TO_EDGE,[gu]:a.MIRRORED_REPEAT},Gt={[we]:a.NEAREST,[sv]:a.NEAREST_MIPMAP_NEAREST,[Go]:a.NEAREST_MIPMAP_LINEAR,[se]:a.LINEAR,[Vl]:a.LINEAR_MIPMAP_NEAREST,[pa]:a.LINEAR_MIPMAP_LINEAR},Jt={[hv]:a.NEVER,[mv]:a.ALWAYS,[uv]:a.LESS,[Gd]:a.LEQUAL,[dv]:a.EQUAL,[Vd]:a.GEQUAL,[fv]:a.GREATER,[pv]:a.NOTEQUAL};function qt(R,y){if(y.type===Di&&t.has("OES_texture_float_linear")===!1&&(y.magFilter===se||y.magFilter===Vl||y.magFilter===Go||y.magFilter===pa||y.minFilter===se||y.minFilter===Vl||y.minFilter===Go||y.minFilter===pa)&&Tt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),a.texParameteri(R,a.TEXTURE_WRAP_S,rt[y.wrapS]),a.texParameteri(R,a.TEXTURE_WRAP_T,rt[y.wrapT]),(R===a.TEXTURE_3D||R===a.TEXTURE_2D_ARRAY)&&a.texParameteri(R,a.TEXTURE_WRAP_R,rt[y.wrapR]),a.texParameteri(R,a.TEXTURE_MAG_FILTER,Gt[y.magFilter]),a.texParameteri(R,a.TEXTURE_MIN_FILTER,Gt[y.minFilter]),y.compareFunction&&(a.texParameteri(R,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE),a.texParameteri(R,a.TEXTURE_COMPARE_FUNC,Jt[y.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(y.magFilter===we||y.minFilter!==Go&&y.minFilter!==pa||y.type===Di&&t.has("OES_texture_float_linear")===!1)return;if(y.anisotropy>1||i.get(y).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");a.texParameterf(R,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(y.anisotropy,n.getMaxAnisotropy())),i.get(y).__currentAnisotropy=y.anisotropy}}}function Y(R,y){let F=!1;R.__webglInit===void 0&&(R.__webglInit=!0,y.addEventListener("dispose",T));const V=y.source;let $=f.get(V);$===void 0&&($={},f.set(V,$));const ot=k(y);if(ot!==R.__cacheKey){$[ot]===void 0&&($[ot]={texture:a.createTexture(),usedTimes:0},r.memory.textures++,F=!0),$[ot].usedTimes++;const lt=$[R.__cacheKey];lt!==void 0&&($[R.__cacheKey].usedTimes--,lt.usedTimes===0&&I(y)),R.__cacheKey=ot,R.__webglTexture=$[ot].texture}return F}function at(R,y,F){return Math.floor(Math.floor(R/F)/y)}function nt(R,y,F,V){const ot=R.updateRanges;if(ot.length===0)e.texSubImage2D(a.TEXTURE_2D,0,0,0,y.width,y.height,F,V,y.data);else{ot.sort((It,ft)=>It.start-ft.start);let lt=0;for(let It=1;It<ot.length;It++){const ft=ot[lt],ut=ot[It],Ut=ft.start+ft.count,Bt=at(ut.start,y.width,4),Kt=at(ft.start,y.width,4);ut.start<=Ut+1&&Bt===Kt&&at(ut.start+ut.count-1,y.width,4)===Bt?ft.count=Math.max(ft.count,ut.start+ut.count-ft.start):(++lt,ot[lt]=ut)}ot.length=lt+1;const Z=e.getParameter(a.UNPACK_ROW_LENGTH),Q=e.getParameter(a.UNPACK_SKIP_PIXELS),ht=e.getParameter(a.UNPACK_SKIP_ROWS);e.pixelStorei(a.UNPACK_ROW_LENGTH,y.width);for(let It=0,ft=ot.length;It<ft;It++){const ut=ot[It],Ut=Math.floor(ut.start/4),Bt=Math.ceil(ut.count/4),Kt=Ut%y.width,N=Math.floor(Ut/y.width),ct=Bt,j=1;e.pixelStorei(a.UNPACK_SKIP_PIXELS,Kt),e.pixelStorei(a.UNPACK_SKIP_ROWS,N),e.texSubImage2D(a.TEXTURE_2D,0,Kt,N,ct,j,F,V,y.data)}R.clearUpdateRanges(),e.pixelStorei(a.UNPACK_ROW_LENGTH,Z),e.pixelStorei(a.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(a.UNPACK_SKIP_ROWS,ht)}}function z(R,y,F){let V=a.TEXTURE_2D;(y.isDataArrayTexture||y.isCompressedArrayTexture)&&(V=a.TEXTURE_2D_ARRAY),y.isData3DTexture&&(V=a.TEXTURE_3D);const $=Y(R,y),ot=y.source;e.bindTexture(V,R.__webglTexture,a.TEXTURE0+F);const lt=i.get(ot);if(ot.version!==lt.__version||$===!0){if(e.activeTexture(a.TEXTURE0+F),(typeof ImageBitmap<"u"&&y.image instanceof ImageBitmap)===!1){const j=ne.getPrimaries(ne.workingColorSpace),dt=y.colorSpace===Bs?null:ne.getPrimaries(y.colorSpace),vt=y.colorSpace===Bs||j===dt?a.NONE:a.BROWSER_DEFAULT_WEBGL;e.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,vt)}e.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment);let Q=m(y.image,!1,n.maxTextureSize);Q=zi(y,Q);const ht=s.convert(y.format,y.colorSpace),It=s.convert(y.type);let ft=M(y.internalFormat,ht,It,y.normalized,y.colorSpace,y.isVideoTexture);qt(V,y);let ut;const Ut=y.mipmaps,Bt=y.isVideoTexture!==!0,Kt=lt.__version===void 0||$===!0,N=ot.dataReady,ct=b(y,Q);if(y.isDepthTexture)ft=S(y.format===ma,y.type),Kt&&(Bt?e.texStorage2D(a.TEXTURE_2D,1,ft,Q.width,Q.height):e.texImage2D(a.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,It,null));else if(y.isDataTexture)if(Ut.length>0){Bt&&Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Bt?N&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,It,ut.data):e.texImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,It,ut.data);y.generateMipmaps=!1}else Bt?(Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Q.width,Q.height),N&&nt(y,Q,ht,It)):e.texImage2D(a.TEXTURE_2D,0,ft,Q.width,Q.height,0,ht,It,Q.data);else if(y.isCompressedTexture)if(y.isCompressedArrayTexture){Bt&&Kt&&e.texStorage3D(a.TEXTURE_2D_ARRAY,ct,ft,Ut[0].width,Ut[0].height,Q.depth);for(let j=0,dt=Ut.length;j<dt;j++)if(ut=Ut[j],y.format!==_i)if(ht!==null)if(Bt){if(N)if(y.layerUpdates.size>0){const vt=Kf(ut.width,ut.height,y.format,y.type);for(const et of y.layerUpdates){const Rt=ut.data.subarray(et*vt/ut.data.BYTES_PER_ELEMENT,(et+1)*vt/ut.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,et,ut.width,ut.height,1,ht,Rt)}y.clearLayerUpdates()}else e.compressedTexSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,ut.data)}else e.compressedTexImage3D(a.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ut.data,0,0);else Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Bt?N&&e.texSubImage3D(a.TEXTURE_2D_ARRAY,j,0,0,0,ut.width,ut.height,Q.depth,ht,It,ut.data):e.texImage3D(a.TEXTURE_2D_ARRAY,j,ft,ut.width,ut.height,Q.depth,0,ht,It,ut.data)}else{Bt&&Kt&&e.texStorage2D(a.TEXTURE_2D,ct,ft,Ut[0].width,Ut[0].height);for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],y.format!==_i?ht!==null?Bt?N&&e.compressedTexSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,ut.data):e.compressedTexImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ut.data):Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Bt?N&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ut.width,ut.height,ht,It,ut.data):e.texImage2D(a.TEXTURE_2D,j,ft,ut.width,ut.height,0,ht,It,ut.data)}else if(y.isDataArrayTexture)if(Bt){if(Kt&&e.texStorage3D(a.TEXTURE_2D_ARRAY,ct,ft,Q.width,Q.height,Q.depth),N)if(y.layerUpdates.size>0){const j=Kf(Q.width,Q.height,y.format,y.type);for(const dt of y.layerUpdates){const vt=Q.data.subarray(dt*j/Q.data.BYTES_PER_ELEMENT,(dt+1)*j/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,dt,Q.width,Q.height,1,ht,It,vt)}y.clearLayerUpdates()}else e.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ht,It,Q.data)}else e.texImage3D(a.TEXTURE_2D_ARRAY,0,ft,Q.width,Q.height,Q.depth,0,ht,It,Q.data);else if(y.isData3DTexture)Bt?(Kt&&e.texStorage3D(a.TEXTURE_3D,ct,ft,Q.width,Q.height,Q.depth),N&&e.texSubImage3D(a.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ht,It,Q.data)):e.texImage3D(a.TEXTURE_3D,0,ft,Q.width,Q.height,Q.depth,0,ht,It,Q.data);else if(y.isFramebufferTexture){if(Kt)if(Bt)e.texStorage2D(a.TEXTURE_2D,ct,ft,Q.width,Q.height);else{let j=Q.width,dt=Q.height;for(let vt=0;vt<ct;vt++)e.texImage2D(a.TEXTURE_2D,vt,ft,j,dt,0,ht,It,null),j>>=1,dt>>=1}}else if(y.isHTMLTexture){if("texElementImage2D"in a){const j=a.canvas;if(j.hasAttribute("layoutsubtree")||j.setAttribute("layoutsubtree","true"),Q.parentNode!==j){j.appendChild(Q),u.add(y),j.onpaint=dt=>{const vt=dt.changedElements;for(const et of u)vt.includes(et.image)&&(et.needsUpdate=!0)},j.requestPaint();return}if(a.texElementImage2D.length===3)a.texElementImage2D(a.TEXTURE_2D,a.RGBA8,Q);else{const vt=a.RGBA,et=a.RGBA,Rt=a.UNSIGNED_BYTE;a.texElementImage2D(a.TEXTURE_2D,0,vt,et,Rt,Q)}a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE)}}else if(Ut.length>0){if(Bt&&Kt){const j=me(Ut[0]);e.texStorage2D(a.TEXTURE_2D,ct,ft,j.width,j.height)}for(let j=0,dt=Ut.length;j<dt;j++)ut=Ut[j],Bt?N&&e.texSubImage2D(a.TEXTURE_2D,j,0,0,ht,It,ut):e.texImage2D(a.TEXTURE_2D,j,ft,ht,It,ut);y.generateMipmaps=!1}else if(Bt){if(Kt){const j=me(Q);e.texStorage2D(a.TEXTURE_2D,ct,ft,j.width,j.height)}N&&e.texSubImage2D(a.TEXTURE_2D,0,0,0,ht,It,Q)}else e.texImage2D(a.TEXTURE_2D,0,ft,ht,It,Q);g(y)&&_(V),lt.__version=ot.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function At(R,y,F){if(y.image.length!==6)return;const V=Y(R,y),$=y.source;e.bindTexture(a.TEXTURE_CUBE_MAP,R.__webglTexture,a.TEXTURE0+F);const ot=i.get($);if($.version!==ot.__version||V===!0){e.activeTexture(a.TEXTURE0+F);const lt=ne.getPrimaries(ne.workingColorSpace),Z=y.colorSpace===Bs?null:ne.getPrimaries(y.colorSpace),Q=y.colorSpace===Bs||lt===Z?a.NONE:a.BROWSER_DEFAULT_WEBGL;e.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.flipY),e.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,y.premultiplyAlpha),e.pixelStorei(a.UNPACK_ALIGNMENT,y.unpackAlignment),e.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ht=y.isCompressedTexture||y.image[0].isCompressedTexture,It=y.image[0]&&y.image[0].isDataTexture,ft=[];for(let et=0;et<6;et++)!ht&&!It?ft[et]=m(y.image[et],!0,n.maxCubemapSize):ft[et]=It?y.image[et].image:y.image[et],ft[et]=zi(y,ft[et]);const ut=ft[0],Ut=s.convert(y.format,y.colorSpace),Bt=s.convert(y.type),Kt=M(y.internalFormat,Ut,Bt,y.normalized,y.colorSpace),N=y.isVideoTexture!==!0,ct=ot.__version===void 0||V===!0,j=$.dataReady;let dt=b(y,ut);qt(a.TEXTURE_CUBE_MAP,y);let vt;if(ht){N&&ct&&e.texStorage2D(a.TEXTURE_CUBE_MAP,dt,Kt,ut.width,ut.height);for(let et=0;et<6;et++){vt=ft[et].mipmaps;for(let Rt=0;Rt<vt.length;Rt++){const St=vt[Rt];y.format!==_i?Ut!==null?N?j&&e.compressedTexSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,0,0,St.width,St.height,Ut,St.data):e.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,Kt,St.width,St.height,0,St.data):Tt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):N?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,0,0,St.width,St.height,Ut,Bt,St.data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt,Kt,St.width,St.height,0,Ut,Bt,St.data)}}}else{if(vt=y.mipmaps,N&&ct){vt.length>0&&dt++;const et=me(ft[0]);e.texStorage2D(a.TEXTURE_CUBE_MAP,dt,Kt,et.width,et.height)}for(let et=0;et<6;et++)if(It){N?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,ft[et].width,ft[et].height,Ut,Bt,ft[et].data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Kt,ft[et].width,ft[et].height,0,Ut,Bt,ft[et].data);for(let Rt=0;Rt<vt.length;Rt++){const Ve=vt[Rt].image[et].image;N?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,0,0,Ve.width,Ve.height,Ut,Bt,Ve.data):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,Kt,Ve.width,Ve.height,0,Ut,Bt,Ve.data)}}else{N?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,0,0,Ut,Bt,ft[et]):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,0,Kt,Ut,Bt,ft[et]);for(let Rt=0;Rt<vt.length;Rt++){const St=vt[Rt];N?j&&e.texSubImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,0,0,Ut,Bt,St.image[et]):e.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+et,Rt+1,Kt,Ut,Bt,St.image[et])}}}g(y)&&_(a.TEXTURE_CUBE_MAP),ot.__version=$.version,y.onUpdate&&y.onUpdate(y)}R.__version=y.version}function Nt(R,y,F,V,$,ot){const lt=s.convert(F.format,F.colorSpace),Z=s.convert(F.type),Q=M(F.internalFormat,lt,Z,F.normalized,F.colorSpace),ht=i.get(y),It=i.get(F);if(It.__renderTarget=y,!ht.__hasExternalTextures){const ft=Math.max(1,y.width>>ot),ut=Math.max(1,y.height>>ot);$===a.TEXTURE_3D||$===a.TEXTURE_2D_ARRAY?e.texImage3D($,ot,Q,ft,ut,y.depth,0,lt,Z,null):e.texImage2D($,ot,Q,ft,ut,0,lt,Z,null)}e.bindFramebuffer(a.FRAMEBUFFER,R),ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,V,$,It.__webglTexture,0,Ge(y)):($===a.TEXTURE_2D||$>=a.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&a.framebufferTexture2D(a.FRAMEBUFFER,V,$,It.__webglTexture,ot),e.bindFramebuffer(a.FRAMEBUFFER,null)}function Ct(R,y,F){if(a.bindRenderbuffer(a.RENDERBUFFER,R),y.depthBuffer){const V=y.depthTexture,$=V&&V.isDepthTexture?V.type:null,ot=S(y.stencilBuffer,$),lt=y.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;ti(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ge(y),ot,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ge(y),ot,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,ot,y.width,y.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,lt,a.RENDERBUFFER,R)}else{const V=y.textures;for(let $=0;$<V.length;$++){const ot=V[$],lt=s.convert(ot.format,ot.colorSpace),Z=s.convert(ot.type),Q=M(ot.internalFormat,lt,Z,ot.normalized,ot.colorSpace);ti(y)?o.renderbufferStorageMultisampleEXT(a.RENDERBUFFER,Ge(y),Q,y.width,y.height):F?a.renderbufferStorageMultisample(a.RENDERBUFFER,Ge(y),Q,y.width,y.height):a.renderbufferStorage(a.RENDERBUFFER,Q,y.width,y.height)}}a.bindRenderbuffer(a.RENDERBUFFER,null)}function yt(R,y,F){const V=y.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(a.FRAMEBUFFER,R),!(y.depthTexture&&y.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const $=i.get(y.depthTexture);if($.__renderTarget=y,(!$.__webglTexture||y.depthTexture.image.width!==y.width||y.depthTexture.image.height!==y.height)&&(y.depthTexture.image.width=y.width,y.depthTexture.image.height=y.height,y.depthTexture.needsUpdate=!0),V){if($.__webglInit===void 0&&($.__webglInit=!0,y.depthTexture.addEventListener("dispose",T)),$.__webglTexture===void 0){$.__webglTexture=a.createTexture(),e.bindTexture(a.TEXTURE_CUBE_MAP,$.__webglTexture),qt(a.TEXTURE_CUBE_MAP,y.depthTexture);const ht=s.convert(y.depthTexture.format),It=s.convert(y.depthTexture.type);let ft;y.depthTexture.format===Ms?ft=a.DEPTH_COMPONENT24:y.depthTexture.format===ma&&(ft=a.DEPTH24_STENCIL8);for(let ut=0;ut<6;ut++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+ut,0,ft,y.width,y.height,0,ht,It,null)}}else K(y.depthTexture,0);const ot=$.__webglTexture,lt=Ge(y),Z=V?a.TEXTURE_CUBE_MAP_POSITIVE_X+F:a.TEXTURE_2D,Q=y.depthTexture.format===ma?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;if(y.depthTexture.format===Ms)ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ot,0,lt):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ot,0);else if(y.depthTexture.format===ma)ti(y)?o.framebufferTexture2DMultisampleEXT(a.FRAMEBUFFER,Q,Z,ot,0,lt):a.framebufferTexture2D(a.FRAMEBUFFER,Q,Z,ot,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ft(R){const y=i.get(R),F=R.isWebGLCubeRenderTarget===!0;if(y.__boundDepthTexture!==R.depthTexture){const V=R.depthTexture;if(y.__depthDisposeCallback&&y.__depthDisposeCallback(),V){const $=()=>{delete y.__boundDepthTexture,delete y.__depthDisposeCallback,V.removeEventListener("dispose",$)};V.addEventListener("dispose",$),y.__depthDisposeCallback=$}y.__boundDepthTexture=V}if(R.depthTexture&&!y.__autoAllocateDepthBuffer)if(F)for(let V=0;V<6;V++)yt(y.__webglFramebuffer[V],R,V);else{const V=R.texture.mipmaps;V&&V.length>0?yt(y.__webglFramebuffer[0],R,0):yt(y.__webglFramebuffer,R,0)}else if(F){y.__webglDepthbuffer=[];for(let V=0;V<6;V++)if(e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[V]),y.__webglDepthbuffer[V]===void 0)y.__webglDepthbuffer[V]=a.createRenderbuffer(),Ct(y.__webglDepthbuffer[V],R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ot=y.__webglDepthbuffer[V];a.bindRenderbuffer(a.RENDERBUFFER,ot),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ot)}}else{const V=R.texture.mipmaps;if(V&&V.length>0?e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer[0]):e.bindFramebuffer(a.FRAMEBUFFER,y.__webglFramebuffer),y.__webglDepthbuffer===void 0)y.__webglDepthbuffer=a.createRenderbuffer(),Ct(y.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,ot=y.__webglDepthbuffer;a.bindRenderbuffer(a.RENDERBUFFER,ot),a.framebufferRenderbuffer(a.FRAMEBUFFER,$,a.RENDERBUFFER,ot)}}e.bindFramebuffer(a.FRAMEBUFFER,null)}function kt(R,y,F){const V=i.get(R);y!==void 0&&Nt(V.__webglFramebuffer,R,R.texture,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,0),F!==void 0&&Ft(R)}function zt(R){const y=R.texture,F=i.get(R),V=i.get(y);R.addEventListener("dispose",x);const $=R.textures,ot=R.isWebGLCubeRenderTarget===!0,lt=$.length>1;if(lt||(V.__webglTexture===void 0&&(V.__webglTexture=a.createTexture()),V.__version=y.version,r.memory.textures++),ot){F.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer[Z]=[];for(let Q=0;Q<y.mipmaps.length;Q++)F.__webglFramebuffer[Z][Q]=a.createFramebuffer()}else F.__webglFramebuffer[Z]=a.createFramebuffer()}else{if(y.mipmaps&&y.mipmaps.length>0){F.__webglFramebuffer=[];for(let Z=0;Z<y.mipmaps.length;Z++)F.__webglFramebuffer[Z]=a.createFramebuffer()}else F.__webglFramebuffer=a.createFramebuffer();if(lt)for(let Z=0,Q=$.length;Z<Q;Z++){const ht=i.get($[Z]);ht.__webglTexture===void 0&&(ht.__webglTexture=a.createTexture(),r.memory.textures++)}if(R.samples>0&&ti(R)===!1){F.__webglMultisampledFramebuffer=a.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(a.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let Z=0;Z<$.length;Z++){const Q=$[Z];F.__webglColorRenderbuffer[Z]=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,F.__webglColorRenderbuffer[Z]);const ht=s.convert(Q.format,Q.colorSpace),It=s.convert(Q.type),ft=M(Q.internalFormat,ht,It,Q.normalized,Q.colorSpace,R.isXRRenderTarget===!0),ut=Ge(R);a.renderbufferStorageMultisample(a.RENDERBUFFER,ut,ft,R.width,R.height),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+Z,a.RENDERBUFFER,F.__webglColorRenderbuffer[Z])}a.bindRenderbuffer(a.RENDERBUFFER,null),R.depthBuffer&&(F.__webglDepthRenderbuffer=a.createRenderbuffer(),Ct(F.__webglDepthRenderbuffer,R,!0)),e.bindFramebuffer(a.FRAMEBUFFER,null)}}if(ot){e.bindTexture(a.TEXTURE_CUBE_MAP,V.__webglTexture),qt(a.TEXTURE_CUBE_MAP,y);for(let Z=0;Z<6;Z++)if(y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Nt(F.__webglFramebuffer[Z][Q],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Nt(F.__webglFramebuffer[Z],R,y,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);g(y)&&_(a.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(lt){for(let Z=0,Q=$.length;Z<Q;Z++){const ht=$[Z],It=i.get(ht);let ft=a.TEXTURE_2D;(R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(ft=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),e.bindTexture(ft,It.__webglTexture),qt(ft,ht),Nt(F.__webglFramebuffer,R,ht,a.COLOR_ATTACHMENT0+Z,ft,0),g(ht)&&_(ft)}e.unbindTexture()}else{let Z=a.TEXTURE_2D;if((R.isWebGL3DRenderTarget||R.isWebGLArrayRenderTarget)&&(Z=R.isWebGL3DRenderTarget?a.TEXTURE_3D:a.TEXTURE_2D_ARRAY),e.bindTexture(Z,V.__webglTexture),qt(Z,y),y.mipmaps&&y.mipmaps.length>0)for(let Q=0;Q<y.mipmaps.length;Q++)Nt(F.__webglFramebuffer[Q],R,y,a.COLOR_ATTACHMENT0,Z,Q);else Nt(F.__webglFramebuffer,R,y,a.COLOR_ATTACHMENT0,Z,0);g(y)&&_(Z),e.unbindTexture()}R.depthBuffer&&Ft(R)}function fe(R){const y=R.textures;for(let F=0,V=y.length;F<V;F++){const $=y[F];if(g($)){const ot=w(R),lt=i.get($).__webglTexture;e.bindTexture(ot,lt),_(ot),e.unbindTexture()}}}const pe=[],He=[];function Le(R){if(R.samples>0){if(ti(R)===!1){const y=R.textures,F=R.width,V=R.height;let $=a.COLOR_BUFFER_BIT;const ot=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT,lt=i.get(R),Z=y.length>1;if(Z)for(let ht=0;ht<y.length;ht++)e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.RENDERBUFFER,null),e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.TEXTURE_2D,null,0);e.bindFramebuffer(a.READ_FRAMEBUFFER,lt.__webglMultisampledFramebuffer);const Q=R.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglFramebuffer[0]):e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglFramebuffer);for(let ht=0;ht<y.length;ht++){if(R.resolveDepthBuffer&&(R.depthBuffer&&($|=a.DEPTH_BUFFER_BIT),R.stencilBuffer&&R.resolveStencilBuffer&&($|=a.STENCIL_BUFFER_BIT)),Z){a.framebufferRenderbuffer(a.READ_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const It=i.get(y[ht]).__webglTexture;a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,It,0)}a.blitFramebuffer(0,0,F,V,0,0,F,V,$,a.NEAREST),c===!0&&(pe.length=0,He.length=0,pe.push(a.COLOR_ATTACHMENT0+ht),R.depthBuffer&&R.resolveDepthBuffer===!1&&(pe.push(ot),He.push(ot),a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,He)),a.invalidateFramebuffer(a.READ_FRAMEBUFFER,pe))}if(e.bindFramebuffer(a.READ_FRAMEBUFFER,null),e.bindFramebuffer(a.DRAW_FRAMEBUFFER,null),Z)for(let ht=0;ht<y.length;ht++){e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglMultisampledFramebuffer),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.RENDERBUFFER,lt.__webglColorRenderbuffer[ht]);const It=i.get(y[ht]).__webglTexture;e.bindFramebuffer(a.FRAMEBUFFER,lt.__webglFramebuffer),a.framebufferTexture2D(a.DRAW_FRAMEBUFFER,a.COLOR_ATTACHMENT0+ht,a.TEXTURE_2D,It,0)}e.bindFramebuffer(a.DRAW_FRAMEBUFFER,lt.__webglMultisampledFramebuffer)}else if(R.depthBuffer&&R.resolveDepthBuffer===!1&&c){const y=R.stencilBuffer?a.DEPTH_STENCIL_ATTACHMENT:a.DEPTH_ATTACHMENT;a.invalidateFramebuffer(a.DRAW_FRAMEBUFFER,[y])}}}function Ge(R){return Math.min(n.maxSamples,R.samples)}function ti(R){const y=i.get(R);return R.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&y.__useRenderToTexture!==!1}function O(R){const y=r.render.frame;h.get(R)!==y&&(h.set(R,y),R.update())}function zi(R,y){const F=R.colorSpace,V=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||F!==sl&&F!==Bs&&(ne.getTransfer(F)===ve?(V!==_i||$!==nn)&&Tt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Ht("WebGLTextures: Unsupported texture color space:",F)),y}function me(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(l.width=R.naturalWidth||R.width,l.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(l.width=R.displayWidth,l.height=R.displayHeight):(l.width=R.width,l.height=R.height),l}this.allocateTextureUnit=B,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=P,this.setTexture2D=K,this.setTexture2DArray=tt,this.setTexture3D=J,this.setTextureCube=it,this.rebindTextures=kt,this.setupRenderTarget=zt,this.updateRenderTargetMipmap=fe,this.updateMultisampleRenderTarget=Le,this.setupDepthRenderbuffer=Ft,this.setupFrameBufferTexture=Nt,this.useMultisampledRTT=ti,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function OS(a,t){function e(i,n=Bs){let s;const r=ne.getTransfer(n);if(i===nn)return a.UNSIGNED_BYTE;if(i===Ud)return a.UNSIGNED_SHORT_4_4_4_4;if(i===Fd)return a.UNSIGNED_SHORT_5_5_5_1;if(i===cg)return a.UNSIGNED_INT_5_9_9_9_REV;if(i===lg)return a.UNSIGNED_INT_10F_11F_11F_REV;if(i===rg)return a.BYTE;if(i===og)return a.SHORT;if(i===wo)return a.UNSIGNED_SHORT;if(i===Od)return a.INT;if(i===vn)return a.UNSIGNED_INT;if(i===Di)return a.FLOAT;if(i===ze)return a.HALF_FLOAT;if(i===hg)return a.ALPHA;if(i===ug)return a.RGB;if(i===_i)return a.RGBA;if(i===Ms)return a.DEPTH_COMPONENT;if(i===ma)return a.DEPTH_STENCIL;if(i===El)return a.RED;if(i===kd)return a.RED_INTEGER;if(i===wa)return a.RG;if(i===zd)return a.RG_INTEGER;if(i===Bd)return a.RGBA_INTEGER;if(i===Bc||i===Hc||i===Gc||i===Vc)if(r===ve)if(s=t.get("WEBGL_compressed_texture_s3tc_srgb"),s!==null){if(i===Bc)return s.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Vc)return s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(s=t.get("WEBGL_compressed_texture_s3tc"),s!==null){if(i===Bc)return s.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Hc)return s.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Gc)return s.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Vc)return s.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===vu||i===Mu||i===xu||i===yu)if(s=t.get("WEBGL_compressed_texture_pvrtc"),s!==null){if(i===vu)return s.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Mu)return s.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===xu)return s.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===yu)return s.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===_u||i===Su||i===wu||i===bu||i===Eu||i===Qc||i===Au)if(s=t.get("WEBGL_compressed_texture_etc"),s!==null){if(i===_u||i===Su)return r===ve?s.COMPRESSED_SRGB8_ETC2:s.COMPRESSED_RGB8_ETC2;if(i===wu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:s.COMPRESSED_RGBA8_ETC2_EAC;if(i===bu)return s.COMPRESSED_R11_EAC;if(i===Eu)return s.COMPRESSED_SIGNED_R11_EAC;if(i===Qc)return s.COMPRESSED_RG11_EAC;if(i===Au)return s.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Tu||i===Ru||i===Du||i===Cu||i===Iu||i===Pu||i===Lu||i===Nu||i===Ou||i===Uu||i===Fu||i===ku||i===zu||i===Bu)if(s=t.get("WEBGL_compressed_texture_astc"),s!==null){if(i===Tu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:s.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Ru)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:s.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Du)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:s.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Cu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:s.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Iu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:s.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Pu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:s.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Lu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:s.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Nu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:s.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ou)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:s.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===Uu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:s.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===Fu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:s.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ku)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:s.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===zu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:s.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===Bu)return r===ve?s.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:s.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===Hu||i===Gu||i===Vu)if(s=t.get("EXT_texture_compression_bptc"),s!==null){if(i===Hu)return r===ve?s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:s.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===Gu)return s.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===Vu)return s.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===Wu||i===Xu||i===tl||i===qu)if(s=t.get("EXT_texture_compression_rgtc"),s!==null){if(i===Wu)return s.COMPRESSED_RED_RGTC1_EXT;if(i===Xu)return s.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===tl)return s.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===qu)return s.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===bo?a.UNSIGNED_INT_24_8:a[i]!==void 0?a[i]:null}return{convert:e}}const US=`
|
|
4788
4788
|
void main() {
|
|
4789
4789
|
|
|
4790
4790
|
gl_Position = vec4( position, 1.0 );
|
|
@@ -4808,7 +4808,7 @@ void main() {
|
|
|
4808
4808
|
|
|
4809
4809
|
}
|
|
4810
4810
|
|
|
4811
|
-
}`;class kS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new wg(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new ae({vertexShader:US,fragmentShader:FS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Dt(new ki(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zS extends Zs{constructor(t,e){super();const i=this;let n=null,s=1,r=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new kS,g={},_=e.getContextAttributes();let w=null,M=null;const S=[],b=[],T=new Mt;let x=null;const A=new Vi;A.viewport=new ie;const I=new Vi;I.viewport=new ie;const C=[A,I],P=new UM;let X=null,z=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Zl,S[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Zl,S[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Zl,S[Y]=rt),rt.getHandSpace()};function N(Y){const rt=b.indexOf(Y.inputSource);if(rt===-1)return;const nt=S[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||r),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function V(){n.removeEventListener("select",N),n.removeEventListener("selectstart",N),n.removeEventListener("selectend",N),n.removeEventListener("squeeze",N),n.removeEventListener("squeezestart",N),n.removeEventListener("squeezeend",N),n.removeEventListener("end",V),n.removeEventListener("inputsourceschange",k);for(let Y=0;Y<S.length;Y++){const rt=b[Y];rt!==null&&(b[Y]=null,S[Y].disconnect(rt))}X=null,z=null,m.reset();for(const Y in g)delete g[Y];t.setRenderTarget(w),f=null,d=null,u=null,n=null,M=null,qt.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&Tt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Tt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(Y){if(n=Y,n!==null){if(w=t.getRenderTarget(),n.addEventListener("select",N),n.addEventListener("selectstart",N),n.addEventListener("selectend",N),n.addEventListener("squeeze",N),n.addEventListener("squeezestart",N),n.addEventListener("squeezeend",N),n.addEventListener("end",V),n.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,B=null,At=null;_.depth&&(At=_.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=_.stencil?ma:Ms,B=_.stencil?bo:vn);const Nt={colorFormat:e.RGBA8,depthFormat:At,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Nt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new je(d.textureWidth,d.textureHeight,{format:_i,type:nn,depthTexture:new Ks(d.textureWidth,d.textureHeight,B,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:_.stencil,colorSpace:t.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new je(f.framebufferWidth,f.framebufferHeight,{format:_i,type:nn,colorSpace:t.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(o),qt.setContext(n),qt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],B=b.indexOf(nt);B>=0&&(b[B]=null,S[B].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let B=b.indexOf(nt);if(B===-1){for(let Nt=0;Nt<S.length;Nt++)if(Nt>=b.length){b.push(nt),B=Nt;break}else if(b[Nt]===null){b[Nt]=nt,B=Nt;break}if(B===-1)break}const At=S[B];At&&At.connect(nt)}}const K=new D,tt=new D;function J(Y,rt,nt){K.setFromMatrixPosition(rt.matrixWorld),tt.setFromMatrixPosition(nt.matrixWorld);const B=K.distanceTo(tt),At=rt.projectionMatrix.elements,Nt=nt.projectionMatrix.elements,Ct=At[14]/(At[10]-1),yt=At[14]/(At[10]+1),Ft=(At[9]+1)/At[5],kt=(At[9]-1)/At[5],zt=(At[8]-1)/At[0],fe=(Nt[8]+1)/Nt[0],pe=Ct*zt,He=Ct*fe,Le=B/(-zt+fe),Ge=Le*-zt;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ge),Y.translateZ(Le),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),At[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const ti=Ct+Le,O=yt+Le,zi=pe-Ge,me=He+(B-Ge),R=Ft*yt/O*ti,y=kt*yt/O*ti;Y.projectionMatrix.makePerspective(zi,me,R,y,ti,O),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function it(Y,rt){rt===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(rt.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(n===null)return;let rt=Y.near,nt=Y.far;m.texture!==null&&(m.depthNear>0&&(rt=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),P.near=I.near=A.near=rt,P.far=I.far=A.far=nt,(X!==P.near||z!==P.far)&&(n.updateRenderState({depthNear:P.near,depthFar:P.far}),X=P.near,z=P.far),P.layers.mask=Y.layers.mask|6,A.layers.mask=P.layers.mask&-5,I.layers.mask=P.layers.mask&-3;const B=Y.parent,At=P.cameras;it(P,B);for(let Nt=0;Nt<At.length;Nt++)it(At[Nt],B);At.length===2?J(P,A,I):P.projectionMatrix.copy(A.projectionMatrix),ot(Y,P,B)};function ot(Y,rt,nt){nt===null?Y.matrix.copy(rt.matrixWorld):(Y.matrix.copy(nt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(rt.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=_r*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return P},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(P)},this.getCameraTexture=function(Y){return g[Y]};let Vt=null;function Qt(Y,rt){if(h=rt.getViewerPose(l||r),p=rt,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let B=!1;nt.length!==P.cameras.length&&(P.cameras.length=0,B=!0);for(let yt=0;yt<nt.length;yt++){const Ft=nt[yt];let kt=null;if(f!==null)kt=f.getViewport(Ft);else{const fe=u.getViewSubImage(d,Ft);kt=fe.viewport,yt===0&&(t.setRenderTargetTextures(M,fe.colorTexture,fe.depthStencilTexture),t.setRenderTarget(M))}let zt=C[yt];zt===void 0&&(zt=new Vi,zt.layers.enable(yt),zt.viewport=new ie,C[yt]=zt),zt.matrix.fromArray(Ft.transform.matrix),zt.matrix.decompose(zt.position,zt.quaternion,zt.scale),zt.projectionMatrix.fromArray(Ft.projectionMatrix),zt.projectionMatrixInverse.copy(zt.projectionMatrix).invert(),zt.viewport.set(kt.x,kt.y,kt.width,kt.height),yt===0&&(P.matrix.copy(zt.matrix),P.matrix.decompose(P.position,P.quaternion,P.scale)),B===!0&&P.cameras.push(zt)}const At=n.enabledFeatures;if(At&&At.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const yt=u.getDepthInformation(nt[0]);yt&&yt.isValid&&yt.texture&&m.init(yt,n.renderState)}if(At&&At.includes("camera-access")&&v){t.state.unbindTexture(),u=i.getBinding();for(let yt=0;yt<nt.length;yt++){const Ft=nt[yt].camera;if(Ft){let kt=g[Ft];kt||(kt=new wg,g[Ft]=kt);const zt=u.getCameraImage(Ft);kt.sourceTexture=zt}}}}for(let nt=0;nt<S.length;nt++){const B=b[nt],At=S[nt];B!==null&&At!==void 0&&At.update(B,rt,l||r)}Vt&&Vt(Y,rt),rt.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:rt}),p=null}const qt=new Pg;qt.setAnimationLoop(Qt),this.setAnimationLoop=function(Y){Vt=Y},this.dispose=function(){}}}const BS=new Zt,kg=new Xt;kg.set(-1,0,0,0,1,0,0,0,1);function HS(a,t){function e(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,bg(a)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,_,w,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(r(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,_,w):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,e(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ue&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,e(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ue&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,e(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,e(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,e(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const _=t.get(g),w=_.envMap,M=_.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(BS.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(kg),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,e(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,e(g.aoMap,m.aoMapTransform))}function r(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,_,w){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*_,m.scale.value=w*.5,g.map&&(m.map.value=g.map,e(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,e(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,e(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,_){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,e(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,e(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,e(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,e(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,e(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ue&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,e(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,e(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=_.texture,m.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,e(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,e(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,e(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,e(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,e(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const _=t.get(g).light;m.referencePosition.value.setFromMatrixPosition(_.matrixWorld),m.nearDistance.value=_.shadow.camera.near,m.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function GS(a,t,e,i){let n={},s={},r=[];const o=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const b=S.program;i.uniformBlockBinding(M,b)}function l(M,S){let b=n[M.id];b===void 0&&(m(M),b=h(M),n[M.id]=b,M.addEventListener("dispose",_));const T=S.program;i.updateUBOMapping(M,T);const x=t.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const S=u();M.__bindingPointIndex=S;const b=a.createBuffer(),T=M.__size,x=M.usage;return a.bindBuffer(a.UNIFORM_BUFFER,b),a.bufferData(a.UNIFORM_BUFFER,T,x),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(r.indexOf(M)===-1)return r.push(M),M;return Ht("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=n[M.id],b=M.uniforms,T=M.__cache;a.bindBuffer(a.UNIFORM_BUFFER,S);for(let x=0,A=b.length;x<A;x++){const I=b[x];if(Array.isArray(I))for(let C=0,P=I.length;C<P;C++)f(I[C],x,C,T);else f(I,x,0,T)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function f(M,S,b,T){if(v(M,S,b,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let I=0;for(let C=0;C<A.length;C++){const P=A[C],X=g(P);p(P,M.__data,I),typeof P!="number"&&typeof P!="boolean"&&!P.isMatrix3&&!ArrayBuffer.isView(P)&&(I+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,x,M.__data)}}function p(M,S,b){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,b)}function v(M,S,b,T){const x=M.value,A=S+"_"+b;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const I=T[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const T=16;for(let A=0,I=S.length;A<I;A++){const C=Array.isArray(S[A])?S[A]:[S[A]];for(let P=0,X=C.length;P<X;P++){const z=C[P],N=Array.isArray(z.value)?z.value:[z.value];for(let V=0,k=N.length;V<k;V++){const K=N[V],tt=g(K),J=b%T,it=J%tt.boundary,ot=J+it;b+=it,ot!==0&&T-ot<tt.storage&&(b+=T-ot),z.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),z.__offset=b,b+=tt.storage}}}const x=b%T;return x>0&&(b+=T-x),M.__size=b,M.__cache={},this}function g(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Tt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Tt("WebGLRenderer: Unsupported uniform value type.",M),S}function _(M){const S=M.target;S.removeEventListener("dispose",_);const b=r.indexOf(S.__bindingPointIndex);r.splice(b,1),a.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function w(){for(const M in n)a.deleteBuffer(n[M]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const VS=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let kn=null;function WS(){return kn===null&&(kn=new Js(VS,16,16,wa,ze),kn.name="DFG_LUT",kn.minFilter=se,kn.magFilter=se,kn.wrapS=yi,kn.wrapT=yi,kn.generateMipmaps=!1,kn.needsUpdate=!0),kn}class XS{constructor(t={}){const{canvas:e=Mv(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=nn}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const v=f,m=new Set([Bd,zd,kd]),g=new Set([nn,vn,wo,bo,Ud,Fd]),_=new Uint32Array(4),w=new Int32Array(4),M=new D;let S=null,b=null;const T=[],x=[];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=Qn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,P=null,X=null,z=null,N=null;this._outputColorSpace=Fi;let V=0,k=0,K=null,tt=-1,J=null;const it=new ie,ot=new ie;let Vt=null;const Qt=new st(0);let qt=0,Y=e.width,rt=e.height,nt=1,B=null,At=null;const Nt=new ie(0,0,Y,rt),Ct=new ie(0,0,Y,rt);let yt=!1;const Ft=new $d;let kt=!1,zt=!1;const fe=new Zt,pe=new D,He=new ie,Le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function ti(){return K===null?nt:1}let O=i;function zi(E,U){return e.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ld}`),e.addEventListener("webglcontextlost",Ve,!1),e.addEventListener("webglcontextrestored",Ae,!1),e.addEventListener("webglcontextcreationerror",Ln,!1),O===null){const U="webgl2";if(O=zi(U,E),O===null)throw zi(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Ht("WebGLRenderer: "+E.message),E}let me,R,y,F,W,$,at,lt,Z,Q,ht,It,ft,ut,Ut,Bt,Kt,L,ct,j,dt,vt,et;function Rt(){me=new W3(O),me.init(),dt=new OS(O,me),R=new U3(O,me,t,dt),y=new LS(O,me),R.reversedDepthBuffer&&d&&y.buffers.depth.setReversed(!0),X=O.createFramebuffer(),z=O.createFramebuffer(),N=O.createFramebuffer(),F=new Y3(O),W=new xS,$=new NS(O,me,y,W,R,dt,F),at=new V3(I),lt=new JM(O),vt=new N3(O,lt),Z=new X3(O,lt,F,vt),Q=new $3(O,Z,lt,vt,F),L=new K3(O,R,$),Ut=new F3(W),ht=new MS(I,at,me,R,vt,Ut),It=new HS(I,W),ft=new _S,ut=new TS(me),Kt=new L3(I,at,y,Q,p,c),Bt=new PS(I,Q,R),et=new GS(O,F,R,y),ct=new O3(O,me,F),j=new q3(O,me,F),F.programs=ht.programs,I.capabilities=R,I.extensions=me,I.properties=W,I.renderLists=ft,I.shadowMap=Bt,I.state=y,I.info=F}Rt(),v!==nn&&(A=new J3(v,e.width,e.height,o,n,s));const St=new zS(I,O);this.xr=St,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=me.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=me.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(Y,rt,!1))},this.getSize=function(E){return E.set(Y,rt)},this.setSize=function(E,U,q=!0){if(St.isPresenting){Tt("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=E,rt=U,e.width=Math.floor(E*nt),e.height=Math.floor(U*nt),q===!0&&(e.style.width=E+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(E,U,q){Y=E,rt=U,nt=q,e.width=Math.floor(E*q),e.height=Math.floor(U*q),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===nn){Ht("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){Tt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(it)},this.getViewport=function(E){return E.copy(Nt)},this.setViewport=function(E,U,q,H){E.isVector4?Nt.set(E.x,E.y,E.z,E.w):Nt.set(E,U,q,H),y.viewport(it.copy(Nt).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(Ct)},this.setScissor=function(E,U,q,H){E.isVector4?Ct.set(E.x,E.y,E.z,E.w):Ct.set(E,U,q,H),y.scissor(ot.copy(Ct).multiplyScalar(nt).round())},this.getScissorTest=function(){return yt},this.setScissorTest=function(E){y.setScissorTest(yt=E)},this.setOpaqueSort=function(E){B=E},this.setTransparentSort=function(E){At=E},this.getClearColor=function(E){return E.copy(Kt.getClearColor())},this.setClearColor=function(){Kt.setClearColor(...arguments)},this.getClearAlpha=function(){return Kt.getClearAlpha()},this.setClearAlpha=function(){Kt.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,q=!0){let H=0;if(E){let G=!1;if(K!==null){const gt=K.texture.format;G=m.has(gt)}if(G){const gt=K.texture.type,_t=g.has(gt),mt=Kt.getClearColor(),bt=Kt.getClearAlpha(),Pt=mt.r,$t=mt.g,Jt=mt.b;_t?(_[0]=Pt,_[1]=$t,_[2]=Jt,_[3]=bt,O.clearBufferuiv(O.COLOR,0,_)):(w[0]=Pt,w[1]=$t,w[2]=Jt,w[3]=bt,O.clearBufferiv(O.COLOR,0,w))}else H|=O.COLOR_BUFFER_BIT}U&&(H|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(H|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&O.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(E){E.setRenderer(this),P=E},this.dispose=function(){e.removeEventListener("webglcontextlost",Ve,!1),e.removeEventListener("webglcontextrestored",Ae,!1),e.removeEventListener("webglcontextcreationerror",Ln,!1),Kt.dispose(),ft.dispose(),ut.dispose(),W.dispose(),at.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),St.dispose(),St.removeEventListener("sessionstart",_0),St.removeEventListener("sessionend",S0),js.stop()};function Ve(E){E.preventDefault(),ol("WebGLRenderer: Context Lost."),C=!0}function Ae(){ol("WebGLRenderer: Context Restored."),C=!1;const E=F.autoReset,U=Bt.enabled,q=Bt.autoUpdate,H=Bt.needsUpdate,G=Bt.type;Rt(),F.autoReset=E,Bt.enabled=U,Bt.autoUpdate=q,Bt.needsUpdate=H,Bt.type=G}function Ln(E){Ht("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Nn(E){const U=E.target;U.removeEventListener("dispose",Nn),w1(U)}function w1(E){b1(E),W.remove(E)}function b1(E){const U=W.get(E).programs;U!==void 0&&(U.forEach(function(q){ht.releaseProgram(q)}),E.isShaderMaterial&&ht.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,q,H,G,gt){U===null&&(U=Le);const _t=G.isMesh&&G.matrixWorld.determinantAffine()<0,mt=T1(E,U,q,H,G);y.setMaterial(H,_t);let bt=q.index,Pt=1;if(H.wireframe===!0){if(bt=Z.getWireframeAttribute(q),bt===void 0)return;Pt=2}const $t=q.drawRange,Jt=q.attributes.position;let Lt=$t.start*Pt,Se=($t.start+$t.count)*Pt;gt!==null&&(Lt=Math.max(Lt,gt.start*Pt),Se=Math.min(Se,(gt.start+gt.count)*Pt)),bt!==null?(Lt=Math.max(Lt,0),Se=Math.min(Se,bt.count)):Jt!=null&&(Lt=Math.max(Lt,0),Se=Math.min(Se,Jt.count));const Ke=Se-Lt;if(Ke<0||Ke===1/0)return;vt.setup(G,H,mt,q,bt);let We,be=ct;if(bt!==null&&(We=lt.get(bt),be=j,be.setIndex(We)),G.isMesh)H.wireframe===!0?(y.setLineWidth(H.wireframeLinewidth*ti()),be.setMode(O.LINES)):be.setMode(O.TRIANGLES);else if(G.isLine){let wi=H.linewidth;wi===void 0&&(wi=1),y.setLineWidth(wi*ti()),G.isLineSegments?be.setMode(O.LINES):G.isLineLoop?be.setMode(O.LINE_LOOP):be.setMode(O.LINE_STRIP)}else G.isPoints?be.setMode(O.POINTS):G.isSprite&&be.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(me.get("WEBGL_multi_draw"))be.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const wi=G._multiDrawStarts,xt=G._multiDrawCounts,Xi=G._multiDrawCount,re=bt?lt.get(bt).bytesPerElement:1,rn=W.get(H).currentProgram.getUniforms();for(let On=0;On<Xi;On++)rn.setValue(O,"_gl_DrawID",On),be.render(wi[On]/re,xt[On])}else if(G.isInstancedMesh)be.renderInstances(Lt,Ke,G.count);else if(q.isInstancedBufferGeometry){const wi=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,xt=Math.min(q.instanceCount,wi);be.renderInstances(Lt,Ke,xt)}else be.render(Lt,Ke)};function y0(E,U,q){E.transparent===!0&&E.side===en&&E.forceSinglePass===!1?(E.side=Ue,E.needsUpdate=!0,Oo(E,U,q),E.side=Ys,E.needsUpdate=!0,Oo(E,U,q),E.side=en):Oo(E,U,q)}this.compile=function(E,U,q=null){q===null&&(q=E),b=ut.get(q),b.init(U),x.push(b),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),E!==q&&E.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),b.setupLights();const H=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const gt=G.material;if(gt)if(Array.isArray(gt))for(let _t=0;_t<gt.length;_t++){const mt=gt[_t];y0(mt,q,G),H.add(mt)}else y0(gt,q,G),H.add(gt)}),b=x.pop(),H},this.compileAsync=function(E,U,q=null){const H=this.compile(E,U,q);return new Promise(G=>{function gt(){if(H.forEach(function(_t){W.get(_t).currentProgram.isReady()&&H.delete(_t)}),H.size===0){G(E);return}setTimeout(gt,10)}me.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Fl=null;function E1(E){Fl&&Fl(E)}function _0(){js.stop()}function S0(){js.start()}const js=new Pg;js.setAnimationLoop(E1),typeof self<"u"&&js.setContext(self),this.setAnimationLoop=function(E){Fl=E,St.setAnimationLoop(E),E===null?js.stop():js.start()},St.addEventListener("sessionstart",_0),St.addEventListener("sessionend",S0),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Ht("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;P!==null&&P.renderStart(E,U);const q=St.enabled===!0&&St.isPresenting===!0,H=A!==null&&(K===null||q)&&A.begin(I,K);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),St.enabled===!0&&St.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(St.cameraAutoUpdate===!0&&St.updateCamera(U),U=St.getCamera()),E.isScene===!0&&E.onBeforeRender(I,E,U,K),b=ut.get(E,x.length),b.init(U),b.state.textureUnits=$.getTextureUnits(),x.push(b),fe.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ft.setFromProjectionMatrix(fe,Zn,U.reversedDepth),zt=this.localClippingEnabled,kt=Ut.init(this.clippingPlanes,zt),S=ft.get(E,T.length),S.init(),T.push(S),St.enabled===!0&&St.isPresenting===!0){const _t=I.xr.getDepthSensingMesh();_t!==null&&kl(_t,U,-1/0,I.sortObjects)}kl(E,U,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(B,At,U.reversedDepth),Ge=St.enabled===!1||St.isPresenting===!1||St.hasDepthSensing()===!1,Ge&&Kt.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),kt===!0&&Ut.beginShadows();const G=b.state.shadowsArray;if(Bt.render(G,E,U),kt===!0&&Ut.endShadows(),(H&&A.hasRenderPass())===!1){const _t=S.opaque,mt=S.transmissive;if(b.setupLights(),U.isArrayCamera){const bt=U.cameras;if(mt.length>0)for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const Jt=bt[Pt];b0(_t,mt,E,Jt)}Ge&&Kt.render(E);for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const Jt=bt[Pt];w0(S,E,Jt,Jt.viewport)}}else mt.length>0&&b0(_t,mt,E,U),Ge&&Kt.render(E),w0(S,E,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),H&&A.end(I),E.isScene===!0&&E.onAfterRender(I,E,U),vt.resetDefaultState(),tt=-1,J=null,x.pop(),x.length>0?(b=x[x.length-1],$.setTextureUnits(b.state.textureUnits),kt===!0&&Ut.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,T.pop(),T.length>0?S=T[T.length-1]:S=null,P!==null&&P.renderEnd()};function kl(E,U,q,H){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Ft.intersectsSprite(E)){H&&He.setFromMatrixPosition(E.matrixWorld).applyMatrix4(fe);const _t=Q.update(E),mt=E.material;mt.visible&&S.push(E,_t,mt,q,He.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Ft.intersectsObject(E))){const _t=Q.update(E),mt=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),He.copy(E.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),He.copy(_t.boundingSphere.center)),He.applyMatrix4(E.matrixWorld).applyMatrix4(fe)),Array.isArray(mt)){const bt=_t.groups;for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const Jt=bt[Pt],Lt=mt[Jt.materialIndex];Lt&&Lt.visible&&S.push(E,_t,Lt,q,He.z,Jt)}}else mt.visible&&S.push(E,_t,mt,q,He.z,null)}}const gt=E.children;for(let _t=0,mt=gt.length;_t<mt;_t++)kl(gt[_t],U,q,H)}function w0(E,U,q,H){const{opaque:G,transmissive:gt,transparent:_t}=E;b.setupLightsView(q),kt===!0&&Ut.setGlobalState(I.clippingPlanes,q),H&&y.viewport(it.copy(H)),G.length>0&&No(G,U,q),gt.length>0&&No(gt,U,q),_t.length>0&&No(_t,U,q),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function b0(E,U,q,H){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[H.id]===void 0){const Lt=me.has("EXT_color_buffer_half_float")||me.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[H.id]=new je(1,1,{generateMipmaps:!0,type:Lt?ze:nn,minFilter:pa,samples:Math.max(4,R.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ne.workingColorSpace})}const gt=b.state.transmissionRenderTarget[H.id],_t=H.viewport||it;gt.setSize(_t.z*I.transmissionResolutionScale,_t.w*I.transmissionResolutionScale);const mt=I.getRenderTarget(),bt=I.getActiveCubeFace(),Pt=I.getActiveMipmapLevel();I.setRenderTarget(gt),I.getClearColor(Qt),qt=I.getClearAlpha(),qt<1&&I.setClearColor(16777215,.5),I.clear(),Ge&&Kt.render(q);const $t=I.toneMapping;I.toneMapping=Qn;const Jt=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),b.setupLightsView(H),kt===!0&&Ut.setGlobalState(I.clippingPlanes,H),No(E,q,H),$.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt),me.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let Se=0,Ke=U.length;Se<Ke;Se++){const We=U[Se],{object:be,geometry:wi,material:xt,group:Xi}=We;if(xt.side===en&&be.layers.test(H.layers)){const re=xt.side;xt.side=Ue,xt.needsUpdate=!0,E0(be,q,H,wi,xt,Xi),xt.side=re,xt.needsUpdate=!0,Lt=!0}}Lt===!0&&($.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt))}I.setRenderTarget(mt,bt,Pt),I.setClearColor(Qt,qt),Jt!==void 0&&(H.viewport=Jt),I.toneMapping=$t}function No(E,U,q){const H=U.isScene===!0?U.overrideMaterial:null;for(let G=0,gt=E.length;G<gt;G++){const _t=E[G],{object:mt,geometry:bt,group:Pt}=_t;let $t=_t.material;$t.allowOverride===!0&&H!==null&&($t=H),mt.layers.test(q.layers)&&E0(mt,U,q,bt,$t,Pt)}}function E0(E,U,q,H,G,gt){E.onBeforeRender(I,U,q,H,G,gt),E.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(I,U,q,H,E,gt),G.transparent===!0&&G.side===en&&G.forceSinglePass===!1?(G.side=Ue,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,E,gt),G.side=Ys,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,E,gt),G.side=en):I.renderBufferDirect(q,U,H,G,E,gt),E.onAfterRender(I,U,q,H,G,gt)}function Oo(E,U,q){U.isScene!==!0&&(U=Le);const H=W.get(E),G=b.state.lights,gt=b.state.shadowsArray,_t=G.state.version,mt=ht.getParameters(E,G.state,gt,U,q,b.state.lightProbeGridArray),bt=ht.getProgramCacheKey(mt);let Pt=H.programs;H.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,H.fog=U.fog;const $t=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;H.envMap=at.get(E.envMap||H.environment,$t),H.envMapRotation=H.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Pt===void 0&&(E.addEventListener("dispose",Nn),Pt=new Map,H.programs=Pt);let Jt=Pt.get(bt);if(Jt!==void 0){if(H.currentProgram===Jt&&H.lightsStateVersion===_t)return T0(E,mt),Jt}else mt.uniforms=ht.getUniforms(E),P!==null&&E.isNodeMaterial&&P.build(E,q,mt),E.onBeforeCompile(mt,I),Jt=ht.acquireProgram(mt,bt),Pt.set(bt,Jt),H.uniforms=mt.uniforms;const Lt=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Lt.clippingPlanes=Ut.uniform),T0(E,mt),H.needsLights=D1(E),H.lightsStateVersion=_t,H.needsLights&&(Lt.ambientLightColor.value=G.state.ambient,Lt.lightProbe.value=G.state.probe,Lt.directionalLights.value=G.state.directional,Lt.directionalLightShadows.value=G.state.directionalShadow,Lt.spotLights.value=G.state.spot,Lt.spotLightShadows.value=G.state.spotShadow,Lt.rectAreaLights.value=G.state.rectArea,Lt.ltc_1.value=G.state.rectAreaLTC1,Lt.ltc_2.value=G.state.rectAreaLTC2,Lt.pointLights.value=G.state.point,Lt.pointLightShadows.value=G.state.pointShadow,Lt.hemisphereLights.value=G.state.hemi,Lt.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Lt.spotLightMatrix.value=G.state.spotLightMatrix,Lt.spotLightMap.value=G.state.spotLightMap,Lt.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=b.state.lightProbeGridArray.length>0,H.currentProgram=Jt,H.uniformsList=null,Jt}function A0(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Xc.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function T0(E,U){const q=W.get(E);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function A1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let q=0,H=E.length;q<H;q++){const G=E[q];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function T1(E,U,q,H,G){U.isScene!==!0&&(U=Le),$.resetTextureUnits();const gt=U.fog,_t=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?U.environment:null,mt=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:ne.workingColorSpace,bt=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Pt=at.get(H.envMap||_t,bt),$t=H.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,Jt=!!q.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Lt=!!q.morphAttributes.position,Se=!!q.morphAttributes.normal,Ke=!!q.morphAttributes.color;let We=Qn;H.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(We=I.toneMapping);const be=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,wi=be!==void 0?be.length:0,xt=W.get(H),Xi=b.state.lights;if(kt===!0&&(zt===!0||E!==J)){const Te=E===J&&H.id===tt;Ut.setState(H,E,Te)}let re=!1;H.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==Xi.state.version||xt.outputColorSpace!==mt||G.isBatchedMesh&&xt.batching===!1||!G.isBatchedMesh&&xt.batching===!0||G.isBatchedMesh&&xt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&xt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&xt.instancing===!1||!G.isInstancedMesh&&xt.instancing===!0||G.isSkinnedMesh&&xt.skinning===!1||!G.isSkinnedMesh&&xt.skinning===!0||G.isInstancedMesh&&xt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&xt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&xt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&xt.instancingMorph===!1&&G.morphTexture!==null||xt.envMap!==Pt||H.fog===!0&&xt.fog!==gt||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Ut.numPlanes||xt.numIntersection!==Ut.numIntersection)||xt.vertexAlphas!==$t||xt.vertexTangents!==Jt||xt.morphTargets!==Lt||xt.morphNormals!==Se||xt.morphColors!==Ke||xt.toneMapping!==We||xt.morphTargetsCount!==wi||!!xt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(re=!0):(re=!0,xt.__version=H.version);let rn=xt.currentProgram;re===!0&&(rn=Oo(H,U,G),P&&H.isNodeMaterial&&P.onUpdateProgram(H,rn,xt));let On=!1,bs=!1,Aa=!1;const Ee=rn.getUniforms(),$e=xt.uniforms;if(y.useProgram(rn.program)&&(On=!0,bs=!0,Aa=!0),H.id!==tt&&(tt=H.id,bs=!0),xt.needsLights){const Te=A1(b.state.lightProbeGridArray,G);xt.lightProbeGrid!==Te&&(xt.lightProbeGrid=Te,bs=!0)}if(On||J!==E){y.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Ee.setValue(O,"projectionMatrix",E.projectionMatrix),Ee.setValue(O,"viewMatrix",E.matrixWorldInverse);const As=Ee.map.cameraPosition;As!==void 0&&As.setValue(O,pe.setFromMatrixPosition(E.matrixWorld)),R.logarithmicDepthBuffer&&Ee.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ee.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,bs=!0,Aa=!0)}if(xt.needsLights&&(Xi.state.directionalShadowMap.length>0&&Ee.setValue(O,"directionalShadowMap",Xi.state.directionalShadowMap,$),Xi.state.spotShadowMap.length>0&&Ee.setValue(O,"spotShadowMap",Xi.state.spotShadowMap,$),Xi.state.pointShadowMap.length>0&&Ee.setValue(O,"pointShadowMap",Xi.state.pointShadowMap,$)),G.isSkinnedMesh){Ee.setOptional(O,G,"bindMatrix"),Ee.setOptional(O,G,"bindMatrixInverse");const Te=G.skeleton;Te&&(Te.boneTexture===null&&Te.computeBoneTexture(),Ee.setValue(O,"boneTexture",Te.boneTexture,$))}G.isBatchedMesh&&(Ee.setOptional(O,G,"batchingTexture"),Ee.setValue(O,"batchingTexture",G._matricesTexture,$),Ee.setOptional(O,G,"batchingIdTexture"),Ee.setValue(O,"batchingIdTexture",G._indirectTexture,$),Ee.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&Ee.setValue(O,"batchingColorTexture",G._colorsTexture,$));const Es=q.morphAttributes;if((Es.position!==void 0||Es.normal!==void 0||Es.color!==void 0)&&L.update(G,q,rn),(bs||xt.receiveShadow!==G.receiveShadow)&&(xt.receiveShadow=G.receiveShadow,Ee.setValue(O,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&U.environment!==null&&($e.envMapIntensity.value=U.environmentIntensity),$e.dfgLUT!==void 0&&($e.dfgLUT.value=WS()),bs){if(Ee.setValue(O,"toneMappingExposure",I.toneMappingExposure),xt.needsLights&&R1($e,Aa),gt&&H.fog===!0&&It.refreshFogUniforms($e,gt),It.refreshMaterialUniforms($e,H,nt,rt,b.state.transmissionRenderTarget[E.id]),xt.needsLights&&xt.lightProbeGrid){const Te=xt.lightProbeGrid;$e.probesSH.value=Te.texture,$e.probesMin.value.copy(Te.boundingBox.min),$e.probesMax.value.copy(Te.boundingBox.max),$e.probesResolution.value.copy(Te.resolution)}Xc.upload(O,A0(xt),$e,$)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(Xc.upload(O,A0(xt),$e,$),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ee.setValue(O,"center",G.center),Ee.setValue(O,"modelViewMatrix",G.modelViewMatrix),Ee.setValue(O,"normalMatrix",G.normalMatrix),Ee.setValue(O,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const Te=H.uniformsGroups;for(let As=0,Ta=Te.length;As<Ta;As++){const R0=Te[As];et.update(R0,rn),et.bind(R0,rn)}}return rn}function R1(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function D1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return V},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(E,U,q){const H=W.get(E);H.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),W.get(E.texture).__webglTexture=U,W.get(E.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:q,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const q=W.get(E);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,q=0){K=E,V=U,k=q;let H=null,G=!1,gt=!1;if(E){const mt=W.get(E);if(mt.__useDefaultFramebuffer!==void 0){y.bindFramebuffer(O.FRAMEBUFFER,mt.__webglFramebuffer),it.copy(E.viewport),ot.copy(E.scissor),Vt=E.scissorTest,y.viewport(it),y.scissor(ot),y.setScissorTest(Vt),tt=-1;return}else if(mt.__webglFramebuffer===void 0)$.setupRenderTarget(E);else if(mt.__hasExternalTextures)$.rebindTextures(E,W.get(E.texture).__webglTexture,W.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $t=E.depthTexture;if(mt.__boundDepthTexture!==$t){if($t!==null&&W.has($t)&&(E.width!==$t.image.width||E.height!==$t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(E)}}const bt=E.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(gt=!0);const Pt=W.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pt[U])?H=Pt[U][q]:H=Pt[U],G=!0):E.samples>0&&$.useMultisampledRTT(E)===!1?H=W.get(E).__webglMultisampledFramebuffer:Array.isArray(Pt)?H=Pt[q]:H=Pt,it.copy(E.viewport),ot.copy(E.scissor),Vt=E.scissorTest}else it.copy(Nt).multiplyScalar(nt).floor(),ot.copy(Ct).multiplyScalar(nt).floor(),Vt=yt;if(q!==0&&(H=X),y.bindFramebuffer(O.FRAMEBUFFER,H)&&y.drawBuffers(E,H),y.viewport(it),y.scissor(ot),y.setScissorTest(Vt),G){const mt=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,mt.__webglTexture,q)}else if(gt){const mt=U;for(let bt=0;bt<E.textures.length;bt++){const Pt=W.get(E.textures[bt]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+bt,Pt.__webglTexture,q,mt)}}else if(E!==null&&q!==0){const mt=W.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,mt.__webglTexture,q)}tt=-1},this.readRenderTargetPixels=function(E,U,q,H,G,gt,_t,mt=0){if(!(E&&E.isWebGLRenderTarget)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt){y.bindFramebuffer(O.FRAMEBUFFER,bt);try{const Pt=E.textures[mt],$t=Pt.format,Jt=Pt.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+mt),!R.textureFormatReadable($t)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Jt)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-H&&q>=0&&q<=E.height-G&&O.readPixels(U,q,H,G,dt.convert($t),dt.convert(Jt),gt)}finally{const Pt=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(E,U,q,H,G,gt,_t,mt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=W.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt)if(U>=0&&U<=E.width-H&&q>=0&&q<=E.height-G){y.bindFramebuffer(O.FRAMEBUFFER,bt);const Pt=E.textures[mt],$t=Pt.format,Jt=Pt.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+mt),!R.textureFormatReadable($t))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Lt=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Lt),O.bufferData(O.PIXEL_PACK_BUFFER,gt.byteLength,O.STREAM_READ),O.readPixels(U,q,H,G,dt.convert($t),dt.convert(Jt),0);const Se=K!==null?W.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Se);const Ke=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await xv(O,Ke,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Lt),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,gt),O.deleteBuffer(Lt),O.deleteSync(Ke),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,q=0){const H=Math.pow(2,-q),G=Math.floor(E.image.width*H),gt=Math.floor(E.image.height*H),_t=U!==null?U.x:0,mt=U!==null?U.y:0;$.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_t,mt,G,gt),y.unbindTexture()},this.copyTextureToTexture=function(E,U,q=null,H=null,G=0,gt=0){let _t,mt,bt,Pt,$t,Jt,Lt,Se,Ke;const We=E.isCompressedTexture?E.mipmaps[gt]:E.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,Pt=q.min.x,$t=q.min.y,Jt=q.isBox3?q.min.z:0;else{const $e=Math.pow(2,-G);_t=Math.floor(We.width*$e),mt=Math.floor(We.height*$e),E.isDataArrayTexture?bt=We.depth:E.isData3DTexture?bt=Math.floor(We.depth*$e):bt=1,Pt=0,$t=0,Jt=0}H!==null?(Lt=H.x,Se=H.y,Ke=H.z):(Lt=0,Se=0,Ke=0);const be=dt.convert(U.format),wi=dt.convert(U.type);let xt;U.isData3DTexture?($.setTexture3D(U,0),xt=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),xt=O.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),xt=O.TEXTURE_2D),y.activeTexture(O.TEXTURE0),y.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),y.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),y.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Xi=y.getParameter(O.UNPACK_ROW_LENGTH),re=y.getParameter(O.UNPACK_IMAGE_HEIGHT),rn=y.getParameter(O.UNPACK_SKIP_PIXELS),On=y.getParameter(O.UNPACK_SKIP_ROWS),bs=y.getParameter(O.UNPACK_SKIP_IMAGES);y.pixelStorei(O.UNPACK_ROW_LENGTH,We.width),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,We.height),y.pixelStorei(O.UNPACK_SKIP_PIXELS,Pt),y.pixelStorei(O.UNPACK_SKIP_ROWS,$t),y.pixelStorei(O.UNPACK_SKIP_IMAGES,Jt);const Aa=E.isDataArrayTexture||E.isData3DTexture,Ee=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const $e=W.get(E),Es=W.get(U),Te=W.get($e.__renderTarget),As=W.get(Es.__renderTarget);y.bindFramebuffer(O.READ_FRAMEBUFFER,Te.__webglFramebuffer),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,As.__webglFramebuffer);for(let Ta=0;Ta<bt;Ta++)Aa&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(E).__webglTexture,G,Jt+Ta),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,W.get(U).__webglTexture,gt,Ke+Ta)),O.blitFramebuffer(Pt,$t,_t,mt,Lt,Se,_t,mt,O.DEPTH_BUFFER_BIT,O.NEAREST);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||W.has(E)){const $e=W.get(E),Es=W.get(U);y.bindFramebuffer(O.READ_FRAMEBUFFER,z),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,N);for(let Te=0;Te<bt;Te++)Aa?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,$e.__webglTexture,G,Jt+Te):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,$e.__webglTexture,G),Ee?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Es.__webglTexture,gt,Ke+Te):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Es.__webglTexture,gt),G!==0?O.blitFramebuffer(Pt,$t,_t,mt,Lt,Se,_t,mt,O.COLOR_BUFFER_BIT,O.NEAREST):Ee?O.copyTexSubImage3D(xt,gt,Lt,Se,Ke+Te,Pt,$t,_t,mt):O.copyTexSubImage2D(xt,gt,Lt,Se,Pt,$t,_t,mt);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Ee?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,wi,We.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,We.data):O.texSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,wi,We):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,gt,Lt,Se,_t,mt,be,wi,We.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,gt,Lt,Se,We.width,We.height,be,We.data):O.texSubImage2D(O.TEXTURE_2D,gt,Lt,Se,_t,mt,be,wi,We);y.pixelStorei(O.UNPACK_ROW_LENGTH,Xi),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,re),y.pixelStorei(O.UNPACK_SKIP_PIXELS,rn),y.pixelStorei(O.UNPACK_SKIP_ROWS,On),y.pixelStorei(O.UNPACK_SKIP_IMAGES,bs),gt===0&&U.generateMipmaps&&O.generateMipmap(xt),y.unbindTexture()},this.initRenderTarget=function(E){W.get(E).__webglFramebuffer===void 0&&$.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?$.setTextureCube(E,0):E.isData3DTexture?$.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?$.setTexture2DArray(E,0):$.setTexture2D(E,0),y.unbindTexture()},this.resetState=function(){V=0,k=0,K=null,y.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Zn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=ne._getDrawingBufferColorSpace(t),e.unpackColorSpace=ne._getUnpackColorSpace()}}const qS=`
|
|
4811
|
+
}`;class kS{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const i=new wg(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=i}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,i=new ae({vertexShader:US,fragmentShader:FS,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new Dt(new ki(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class zS extends Zs{constructor(t,e){super();const i=this;let n=null,s=1,r=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,p=null;const v=typeof XRWebGLBinding<"u",m=new kS,g={},_=e.getContextAttributes();let w=null,M=null;const S=[],b=[],T=new Mt;let x=null;const A=new Vi;A.viewport=new ie;const I=new Vi;I.viewport=new ie;const C=[A,I],L=new UM;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let at=S[Y];return at===void 0&&(at=new Zl,S[Y]=at),at.getTargetRaySpace()},this.getControllerGrip=function(Y){let at=S[Y];return at===void 0&&(at=new Zl,S[Y]=at),at.getGripSpace()},this.getHand=function(Y){let at=S[Y];return at===void 0&&(at=new Zl,S[Y]=at),at.getHandSpace()};function P(Y){const at=b.indexOf(Y.inputSource);if(at===-1)return;const nt=S[at];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||r),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function B(){n.removeEventListener("select",P),n.removeEventListener("selectstart",P),n.removeEventListener("selectend",P),n.removeEventListener("squeeze",P),n.removeEventListener("squeezestart",P),n.removeEventListener("squeezeend",P),n.removeEventListener("end",B),n.removeEventListener("inputsourceschange",k);for(let Y=0;Y<S.length;Y++){const at=b[Y];at!==null&&(b[Y]=null,S[Y].disconnect(at))}W=null,X=null,m.reset();for(const Y in g)delete g[Y];t.setRenderTarget(w),f=null,d=null,u=null,n=null,M=null,qt.stop(),i.isPresenting=!1,t.setPixelRatio(x),t.setSize(T.width,T.height,!1),i.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){s=Y,i.isPresenting===!0&&Tt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,i.isPresenting===!0&&Tt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||r},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(n,e)),u},this.getFrame=function(){return p},this.getSession=function(){return n},this.setSession=async function(Y){if(n=Y,n!==null){if(w=t.getRenderTarget(),n.addEventListener("select",P),n.addEventListener("selectstart",P),n.addEventListener("selectend",P),n.addEventListener("squeeze",P),n.addEventListener("squeezestart",P),n.addEventListener("squeezeend",P),n.addEventListener("end",B),n.addEventListener("inputsourceschange",k),_.xrCompatible!==!0&&await e.makeXRCompatible(),x=t.getPixelRatio(),t.getSize(T),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,At=null;_.depth&&(At=_.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=_.stencil?ma:Ms,z=_.stencil?bo:vn);const Nt={colorFormat:e.RGBA8,depthFormat:At,scaleFactor:s};u=this.getBinding(),d=u.createProjectionLayer(Nt),n.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new je(d.textureWidth,d.textureHeight,{format:_i,type:nn,depthTexture:new Ks(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:_.stencil,colorSpace:t.outputColorSpace,samples:_.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:_.antialias,alpha:!0,depth:_.depth,stencil:_.stencil,framebufferScaleFactor:s};f=new XRWebGLLayer(n,e,nt),n.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new je(f.framebufferWidth,f.framebufferHeight,{format:_i,type:nn,colorSpace:t.outputColorSpace,stencilBuffer:_.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,r=await n.requestReferenceSpace(o),qt.setContext(n),qt.start(),i.isPresenting=!0,i.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(n!==null)return n.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function k(Y){for(let at=0;at<Y.removed.length;at++){const nt=Y.removed[at],z=b.indexOf(nt);z>=0&&(b[z]=null,S[z].disconnect(nt))}for(let at=0;at<Y.added.length;at++){const nt=Y.added[at];let z=b.indexOf(nt);if(z===-1){for(let Nt=0;Nt<S.length;Nt++)if(Nt>=b.length){b.push(nt),z=Nt;break}else if(b[Nt]===null){b[Nt]=nt,z=Nt;break}if(z===-1)break}const At=S[z];At&&At.connect(nt)}}const K=new D,tt=new D;function J(Y,at,nt){K.setFromMatrixPosition(at.matrixWorld),tt.setFromMatrixPosition(nt.matrixWorld);const z=K.distanceTo(tt),At=at.projectionMatrix.elements,Nt=nt.projectionMatrix.elements,Ct=At[14]/(At[10]-1),yt=At[14]/(At[10]+1),Ft=(At[9]+1)/At[5],kt=(At[9]-1)/At[5],zt=(At[8]-1)/At[0],fe=(Nt[8]+1)/Nt[0],pe=Ct*zt,He=Ct*fe,Le=z/(-zt+fe),Ge=Le*-zt;if(at.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(Ge),Y.translateZ(Le),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),At[10]===-1)Y.projectionMatrix.copy(at.projectionMatrix),Y.projectionMatrixInverse.copy(at.projectionMatrixInverse);else{const ti=Ct+Le,O=yt+Le,zi=pe-Ge,me=He+(z-Ge),R=Ft*yt/O*ti,y=kt*yt/O*ti;Y.projectionMatrix.makePerspective(zi,me,R,y,ti,O),Y.projectionMatrixInverse.copy(Y.projectionMatrix).invert()}}function it(Y,at){at===null?Y.matrixWorld.copy(Y.matrix):Y.matrixWorld.multiplyMatrices(at.matrixWorld,Y.matrix),Y.matrixWorldInverse.copy(Y.matrixWorld).invert()}this.updateCamera=function(Y){if(n===null)return;let at=Y.near,nt=Y.far;m.texture!==null&&(m.depthNear>0&&(at=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),L.near=I.near=A.near=at,L.far=I.far=A.far=nt,(W!==L.near||X!==L.far)&&(n.updateRenderState({depthNear:L.near,depthFar:L.far}),W=L.near,X=L.far),L.layers.mask=Y.layers.mask|6,A.layers.mask=L.layers.mask&-5,I.layers.mask=L.layers.mask&-3;const z=Y.parent,At=L.cameras;it(L,z);for(let Nt=0;Nt<At.length;Nt++)it(At[Nt],z);At.length===2?J(L,A,I):L.projectionMatrix.copy(A.projectionMatrix),rt(Y,L,z)};function rt(Y,at,nt){nt===null?Y.matrix.copy(at.matrixWorld):(Y.matrix.copy(nt.matrixWorld),Y.matrix.invert(),Y.matrix.multiply(at.matrixWorld)),Y.matrix.decompose(Y.position,Y.quaternion,Y.scale),Y.updateMatrixWorld(!0),Y.projectionMatrix.copy(at.projectionMatrix),Y.projectionMatrixInverse.copy(at.projectionMatrixInverse),Y.isPerspectiveCamera&&(Y.fov=_r*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(d===null&&f===null))return c},this.setFoveation=function(Y){c=Y,d!==null&&(d.fixedFoveation=Y),f!==null&&f.fixedFoveation!==void 0&&(f.fixedFoveation=Y)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(L)},this.getCameraTexture=function(Y){return g[Y]};let Gt=null;function Jt(Y,at){if(h=at.getViewerPose(l||r),p=at,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==L.cameras.length&&(L.cameras.length=0,z=!0);for(let yt=0;yt<nt.length;yt++){const Ft=nt[yt];let kt=null;if(f!==null)kt=f.getViewport(Ft);else{const fe=u.getViewSubImage(d,Ft);kt=fe.viewport,yt===0&&(t.setRenderTargetTextures(M,fe.colorTexture,fe.depthStencilTexture),t.setRenderTarget(M))}let zt=C[yt];zt===void 0&&(zt=new Vi,zt.layers.enable(yt),zt.viewport=new ie,C[yt]=zt),zt.matrix.fromArray(Ft.transform.matrix),zt.matrix.decompose(zt.position,zt.quaternion,zt.scale),zt.projectionMatrix.fromArray(Ft.projectionMatrix),zt.projectionMatrixInverse.copy(zt.projectionMatrix).invert(),zt.viewport.set(kt.x,kt.y,kt.width,kt.height),yt===0&&(L.matrix.copy(zt.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),z===!0&&L.cameras.push(zt)}const At=n.enabledFeatures;if(At&&At.includes("depth-sensing")&&n.depthUsage=="gpu-optimized"&&v){u=i.getBinding();const yt=u.getDepthInformation(nt[0]);yt&&yt.isValid&&yt.texture&&m.init(yt,n.renderState)}if(At&&At.includes("camera-access")&&v){t.state.unbindTexture(),u=i.getBinding();for(let yt=0;yt<nt.length;yt++){const Ft=nt[yt].camera;if(Ft){let kt=g[Ft];kt||(kt=new wg,g[Ft]=kt);const zt=u.getCameraImage(Ft);kt.sourceTexture=zt}}}}for(let nt=0;nt<S.length;nt++){const z=b[nt],At=S[nt];z!==null&&At!==void 0&&At.update(z,at,l||r)}Gt&&Gt(Y,at),at.detectedPlanes&&i.dispatchEvent({type:"planesdetected",data:at}),p=null}const qt=new Pg;qt.setAnimationLoop(Jt),this.setAnimationLoop=function(Y){Gt=Y},this.dispose=function(){}}}const BS=new Zt,kg=new Xt;kg.set(-1,0,0,0,1,0,0,0,1);function HS(a,t){function e(m,g){m.matrixAutoUpdate===!0&&m.updateMatrix(),g.value.copy(m.matrix)}function i(m,g){g.color.getRGB(m.fogColor.value,bg(a)),g.isFog?(m.fogNear.value=g.near,m.fogFar.value=g.far):g.isFogExp2&&(m.fogDensity.value=g.density)}function n(m,g,_,w,M){g.isNodeMaterial?g.uniformsNeedUpdate=!1:g.isMeshBasicMaterial?s(m,g):g.isMeshLambertMaterial?(s(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshToonMaterial?(s(m,g),u(m,g)):g.isMeshPhongMaterial?(s(m,g),h(m,g),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)):g.isMeshStandardMaterial?(s(m,g),d(m,g),g.isMeshPhysicalMaterial&&f(m,g,M)):g.isMeshMatcapMaterial?(s(m,g),p(m,g)):g.isMeshDepthMaterial?s(m,g):g.isMeshDistanceMaterial?(s(m,g),v(m,g)):g.isMeshNormalMaterial?s(m,g):g.isLineBasicMaterial?(r(m,g),g.isLineDashedMaterial&&o(m,g)):g.isPointsMaterial?c(m,g,_,w):g.isSpriteMaterial?l(m,g):g.isShadowMaterial?(m.color.value.copy(g.color),m.opacity.value=g.opacity):g.isShaderMaterial&&(g.uniformsNeedUpdate=!1)}function s(m,g){m.opacity.value=g.opacity,g.color&&m.diffuse.value.copy(g.color),g.emissive&&m.emissive.value.copy(g.emissive).multiplyScalar(g.emissiveIntensity),g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.bumpMap&&(m.bumpMap.value=g.bumpMap,e(g.bumpMap,m.bumpMapTransform),m.bumpScale.value=g.bumpScale,g.side===Ue&&(m.bumpScale.value*=-1)),g.normalMap&&(m.normalMap.value=g.normalMap,e(g.normalMap,m.normalMapTransform),m.normalScale.value.copy(g.normalScale),g.side===Ue&&m.normalScale.value.negate()),g.displacementMap&&(m.displacementMap.value=g.displacementMap,e(g.displacementMap,m.displacementMapTransform),m.displacementScale.value=g.displacementScale,m.displacementBias.value=g.displacementBias),g.emissiveMap&&(m.emissiveMap.value=g.emissiveMap,e(g.emissiveMap,m.emissiveMapTransform)),g.specularMap&&(m.specularMap.value=g.specularMap,e(g.specularMap,m.specularMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest);const _=t.get(g),w=_.envMap,M=_.envMapRotation;w&&(m.envMap.value=w,m.envMapRotation.value.setFromMatrix4(BS.makeRotationFromEuler(M)).transpose(),w.isCubeTexture&&w.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(kg),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,e(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,e(g.aoMap,m.aoMapTransform))}function r(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function c(m,g,_,w){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*_,m.scale.value=w*.5,g.map&&(m.map.value=g.map,e(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function l(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,e(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,e(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function h(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function u(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function d(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,e(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,e(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,_){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,e(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,e(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,e(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,e(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,e(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===Ue&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,e(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,e(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=_.texture,m.transmissionSamplerSize.value.set(_.width,_.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,e(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,e(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,e(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,e(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,e(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function v(m,g){const _=t.get(g).light;m.referencePosition.value.setFromMatrixPosition(_.matrixWorld),m.nearDistance.value=_.shadow.camera.near,m.farDistance.value=_.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:n}}function GS(a,t,e,i){let n={},s={},r=[];const o=a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const b=S.program;i.uniformBlockBinding(M,b)}function l(M,S){let b=n[M.id];b===void 0&&(m(M),b=h(M),n[M.id]=b,M.addEventListener("dispose",_));const T=S.program;i.updateUBOMapping(M,T);const x=t.render.frame;s[M.id]!==x&&(d(M),s[M.id]=x)}function h(M){const S=u();M.__bindingPointIndex=S;const b=a.createBuffer(),T=M.__size,x=M.usage;return a.bindBuffer(a.UNIFORM_BUFFER,b),a.bufferData(a.UNIFORM_BUFFER,T,x),a.bindBuffer(a.UNIFORM_BUFFER,null),a.bindBufferBase(a.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(r.indexOf(M)===-1)return r.push(M),M;return Ht("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=n[M.id],b=M.uniforms,T=M.__cache;a.bindBuffer(a.UNIFORM_BUFFER,S);for(let x=0,A=b.length;x<A;x++){const I=b[x];if(Array.isArray(I))for(let C=0,L=I.length;C<L;C++)f(I[C],x,C,T);else f(I,x,0,T)}a.bindBuffer(a.UNIFORM_BUFFER,null)}function f(M,S,b,T){if(v(M,S,b,T)===!0){const x=M.__offset,A=M.value;if(Array.isArray(A)){let I=0;for(let C=0;C<A.length;C++){const L=A[C],W=g(L);p(L,M.__data,I),typeof L!="number"&&typeof L!="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L)&&(I+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else p(A,M.__data,0);a.bufferSubData(a.UNIFORM_BUFFER,x,M.__data)}}function p(M,S,b){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,b)}function v(M,S,b,T){const x=M.value,A=S+"_"+b;if(T[A]===void 0)return typeof x=="number"||typeof x=="boolean"?T[A]=x:ArrayBuffer.isView(x)?T[A]=x.slice():T[A]=x.clone(),!0;{const I=T[A];if(typeof x=="number"||typeof x=="boolean"){if(I!==x)return T[A]=x,!0}else{if(ArrayBuffer.isView(x))return!0;if(I.equals(x)===!1)return I.copy(x),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const T=16;for(let A=0,I=S.length;A<I;A++){const C=Array.isArray(S[A])?S[A]:[S[A]];for(let L=0,W=C.length;L<W;L++){const X=C[L],P=Array.isArray(X.value)?X.value:[X.value];for(let B=0,k=P.length;B<k;B++){const K=P[B],tt=g(K),J=b%T,it=J%tt.boundary,rt=J+it;b+=it,rt!==0&&T-rt<tt.storage&&(b+=T-rt),X.__data=new Float32Array(tt.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=b,b+=tt.storage}}}const x=b%T;return x>0&&(b+=T-x),M.__size=b,M.__cache={},this}function g(M){const S={boundary:0,storage:0};return typeof M=="number"||typeof M=="boolean"?(S.boundary=4,S.storage=4):M.isVector2?(S.boundary=8,S.storage=8):M.isVector3||M.isColor?(S.boundary=16,S.storage=12):M.isVector4?(S.boundary=16,S.storage=16):M.isMatrix3?(S.boundary=48,S.storage=48):M.isMatrix4?(S.boundary=64,S.storage=64):M.isTexture?Tt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Tt("WebGLRenderer: Unsupported uniform value type.",M),S}function _(M){const S=M.target;S.removeEventListener("dispose",_);const b=r.indexOf(S.__bindingPointIndex);r.splice(b,1),a.deleteBuffer(n[S.id]),delete n[S.id],delete s[S.id]}function w(){for(const M in n)a.deleteBuffer(n[M]);r=[],n={},s={}}return{bind:c,update:l,dispose:w}}const VS=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let kn=null;function WS(){return kn===null&&(kn=new Js(VS,16,16,wa,ze),kn.name="DFG_LUT",kn.minFilter=se,kn.magFilter=se,kn.wrapS=yi,kn.wrapT=yi,kn.generateMipmaps=!1,kn.needsUpdate=!0),kn}class XS{constructor(t={}){const{canvas:e=Mv(),context:i=null,depth:n=!0,stencil:s=!1,alpha:r=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=nn}=t;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=r;const v=f,m=new Set([Bd,zd,kd]),g=new Set([nn,vn,wo,bo,Ud,Fd]),_=new Uint32Array(4),w=new Int32Array(4),M=new D;let S=null,b=null;const T=[],x=[];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=Qn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let C=!1,L=null,W=null,X=null,P=null;this._outputColorSpace=Fi;let B=0,k=0,K=null,tt=-1,J=null;const it=new ie,rt=new ie;let Gt=null;const Jt=new st(0);let qt=0,Y=e.width,at=e.height,nt=1,z=null,At=null;const Nt=new ie(0,0,Y,at),Ct=new ie(0,0,Y,at);let yt=!1;const Ft=new $d;let kt=!1,zt=!1;const fe=new Zt,pe=new D,He=new ie,Le={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let Ge=!1;function ti(){return K===null?nt:1}let O=i;function zi(E,U){return e.getContext(E,U)}try{const E={alpha:!0,depth:n,stencil:s,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Ld}`),e.addEventListener("webglcontextlost",Ve,!1),e.addEventListener("webglcontextrestored",Ae,!1),e.addEventListener("webglcontextcreationerror",Ln,!1),O===null){const U="webgl2";if(O=zi(U,E),O===null)throw zi(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(E){throw Ht("WebGLRenderer: "+E.message),E}let me,R,y,F,V,$,ot,lt,Z,Q,ht,It,ft,ut,Ut,Bt,Kt,N,ct,j,dt,vt,et;function Rt(){me=new W3(O),me.init(),dt=new OS(O,me),R=new U3(O,me,t,dt),y=new LS(O,me),R.reversedDepthBuffer&&d&&y.buffers.depth.setReversed(!0),W=O.createFramebuffer(),X=O.createFramebuffer(),P=O.createFramebuffer(),F=new Y3(O),V=new xS,$=new NS(O,me,y,V,R,dt,F),ot=new V3(I),lt=new JM(O),vt=new N3(O,lt),Z=new X3(O,lt,F,vt),Q=new $3(O,Z,lt,vt,F),N=new K3(O,R,$),Ut=new F3(V),ht=new MS(I,ot,me,R,vt,Ut),It=new HS(I,V),ft=new _S,ut=new TS(me),Kt=new L3(I,ot,y,Q,p,c),Bt=new PS(I,Q,R),et=new GS(O,F,R,y),ct=new O3(O,me,F),j=new q3(O,me,F),F.programs=ht.programs,I.capabilities=R,I.extensions=me,I.properties=V,I.renderLists=ft,I.shadowMap=Bt,I.state=y,I.info=F}Rt(),v!==nn&&(A=new J3(v,e.width,e.height,o,n,s));const St=new zS(I,O);this.xr=St,this.getContext=function(){return O},this.getContextAttributes=function(){return O.getContextAttributes()},this.forceContextLoss=function(){const E=me.get("WEBGL_lose_context");E&&E.loseContext()},this.forceContextRestore=function(){const E=me.get("WEBGL_lose_context");E&&E.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(E){E!==void 0&&(nt=E,this.setSize(Y,at,!1))},this.getSize=function(E){return E.set(Y,at)},this.setSize=function(E,U,q=!0){if(St.isPresenting){Tt("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=E,at=U,e.width=Math.floor(E*nt),e.height=Math.floor(U*nt),q===!0&&(e.style.width=E+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,E,U)},this.getDrawingBufferSize=function(E){return E.set(Y*nt,at*nt).floor()},this.setDrawingBufferSize=function(E,U,q){Y=E,at=U,nt=q,e.width=Math.floor(E*q),e.height=Math.floor(U*q),this.setViewport(0,0,E,U)},this.setEffects=function(E){if(v===nn){Ht("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(E){for(let U=0;U<E.length;U++)if(E[U].isOutputPass===!0){Tt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(E||[])},this.getCurrentViewport=function(E){return E.copy(it)},this.getViewport=function(E){return E.copy(Nt)},this.setViewport=function(E,U,q,H){E.isVector4?Nt.set(E.x,E.y,E.z,E.w):Nt.set(E,U,q,H),y.viewport(it.copy(Nt).multiplyScalar(nt).round())},this.getScissor=function(E){return E.copy(Ct)},this.setScissor=function(E,U,q,H){E.isVector4?Ct.set(E.x,E.y,E.z,E.w):Ct.set(E,U,q,H),y.scissor(rt.copy(Ct).multiplyScalar(nt).round())},this.getScissorTest=function(){return yt},this.setScissorTest=function(E){y.setScissorTest(yt=E)},this.setOpaqueSort=function(E){z=E},this.setTransparentSort=function(E){At=E},this.getClearColor=function(E){return E.copy(Kt.getClearColor())},this.setClearColor=function(){Kt.setClearColor(...arguments)},this.getClearAlpha=function(){return Kt.getClearAlpha()},this.setClearAlpha=function(){Kt.setClearAlpha(...arguments)},this.clear=function(E=!0,U=!0,q=!0){let H=0;if(E){let G=!1;if(K!==null){const gt=K.texture.format;G=m.has(gt)}if(G){const gt=K.texture.type,_t=g.has(gt),mt=Kt.getClearColor(),bt=Kt.getClearAlpha(),Pt=mt.r,$t=mt.g,jt=mt.b;_t?(_[0]=Pt,_[1]=$t,_[2]=jt,_[3]=bt,O.clearBufferuiv(O.COLOR,0,_)):(w[0]=Pt,w[1]=$t,w[2]=jt,w[3]=bt,O.clearBufferiv(O.COLOR,0,w))}else H|=O.COLOR_BUFFER_BIT}U&&(H|=O.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),q&&(H|=O.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),H!==0&&O.clear(H)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(E){E.setRenderer(this),L=E},this.dispose=function(){e.removeEventListener("webglcontextlost",Ve,!1),e.removeEventListener("webglcontextrestored",Ae,!1),e.removeEventListener("webglcontextcreationerror",Ln,!1),Kt.dispose(),ft.dispose(),ut.dispose(),V.dispose(),ot.dispose(),Q.dispose(),vt.dispose(),et.dispose(),ht.dispose(),St.dispose(),St.removeEventListener("sessionstart",_0),St.removeEventListener("sessionend",S0),js.stop()};function Ve(E){E.preventDefault(),ol("WebGLRenderer: Context Lost."),C=!0}function Ae(){ol("WebGLRenderer: Context Restored."),C=!1;const E=F.autoReset,U=Bt.enabled,q=Bt.autoUpdate,H=Bt.needsUpdate,G=Bt.type;Rt(),F.autoReset=E,Bt.enabled=U,Bt.autoUpdate=q,Bt.needsUpdate=H,Bt.type=G}function Ln(E){Ht("WebGLRenderer: A WebGL context could not be created. Reason: ",E.statusMessage)}function Nn(E){const U=E.target;U.removeEventListener("dispose",Nn),w1(U)}function w1(E){b1(E),V.remove(E)}function b1(E){const U=V.get(E).programs;U!==void 0&&(U.forEach(function(q){ht.releaseProgram(q)}),E.isShaderMaterial&&ht.releaseShaderCache(E))}this.renderBufferDirect=function(E,U,q,H,G,gt){U===null&&(U=Le);const _t=G.isMesh&&G.matrixWorld.determinantAffine()<0,mt=T1(E,U,q,H,G);y.setMaterial(H,_t);let bt=q.index,Pt=1;if(H.wireframe===!0){if(bt=Z.getWireframeAttribute(q),bt===void 0)return;Pt=2}const $t=q.drawRange,jt=q.attributes.position;let Lt=$t.start*Pt,Se=($t.start+$t.count)*Pt;gt!==null&&(Lt=Math.max(Lt,gt.start*Pt),Se=Math.min(Se,(gt.start+gt.count)*Pt)),bt!==null?(Lt=Math.max(Lt,0),Se=Math.min(Se,bt.count)):jt!=null&&(Lt=Math.max(Lt,0),Se=Math.min(Se,jt.count));const Ke=Se-Lt;if(Ke<0||Ke===1/0)return;vt.setup(G,H,mt,q,bt);let We,be=ct;if(bt!==null&&(We=lt.get(bt),be=j,be.setIndex(We)),G.isMesh)H.wireframe===!0?(y.setLineWidth(H.wireframeLinewidth*ti()),be.setMode(O.LINES)):be.setMode(O.TRIANGLES);else if(G.isLine){let wi=H.linewidth;wi===void 0&&(wi=1),y.setLineWidth(wi*ti()),G.isLineSegments?be.setMode(O.LINES):G.isLineLoop?be.setMode(O.LINE_LOOP):be.setMode(O.LINE_STRIP)}else G.isPoints?be.setMode(O.POINTS):G.isSprite&&be.setMode(O.TRIANGLES);if(G.isBatchedMesh)if(me.get("WEBGL_multi_draw"))be.renderMultiDraw(G._multiDrawStarts,G._multiDrawCounts,G._multiDrawCount);else{const wi=G._multiDrawStarts,xt=G._multiDrawCounts,Xi=G._multiDrawCount,re=bt?lt.get(bt).bytesPerElement:1,rn=V.get(H).currentProgram.getUniforms();for(let On=0;On<Xi;On++)rn.setValue(O,"_gl_DrawID",On),be.render(wi[On]/re,xt[On])}else if(G.isInstancedMesh)be.renderInstances(Lt,Ke,G.count);else if(q.isInstancedBufferGeometry){const wi=q._maxInstanceCount!==void 0?q._maxInstanceCount:1/0,xt=Math.min(q.instanceCount,wi);be.renderInstances(Lt,Ke,xt)}else be.render(Lt,Ke)};function y0(E,U,q){E.transparent===!0&&E.side===en&&E.forceSinglePass===!1?(E.side=Ue,E.needsUpdate=!0,Oo(E,U,q),E.side=Ys,E.needsUpdate=!0,Oo(E,U,q),E.side=en):Oo(E,U,q)}this.compile=function(E,U,q=null){q===null&&(q=E),b=ut.get(q),b.init(U),x.push(b),q.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),E!==q&&E.traverseVisible(function(G){G.isLight&&G.layers.test(U.layers)&&(b.pushLight(G),G.castShadow&&b.pushShadow(G))}),b.setupLights();const H=new Set;return E.traverse(function(G){if(!(G.isMesh||G.isPoints||G.isLine||G.isSprite))return;const gt=G.material;if(gt)if(Array.isArray(gt))for(let _t=0;_t<gt.length;_t++){const mt=gt[_t];y0(mt,q,G),H.add(mt)}else y0(gt,q,G),H.add(gt)}),b=x.pop(),H},this.compileAsync=function(E,U,q=null){const H=this.compile(E,U,q);return new Promise(G=>{function gt(){if(H.forEach(function(_t){V.get(_t).currentProgram.isReady()&&H.delete(_t)}),H.size===0){G(E);return}setTimeout(gt,10)}me.get("KHR_parallel_shader_compile")!==null?gt():setTimeout(gt,10)})};let Fl=null;function E1(E){Fl&&Fl(E)}function _0(){js.stop()}function S0(){js.start()}const js=new Pg;js.setAnimationLoop(E1),typeof self<"u"&&js.setContext(self),this.setAnimationLoop=function(E){Fl=E,St.setAnimationLoop(E),E===null?js.stop():js.start()},St.addEventListener("sessionstart",_0),St.addEventListener("sessionend",S0),this.render=function(E,U){if(U!==void 0&&U.isCamera!==!0){Ht("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;L!==null&&L.renderStart(E,U);const q=St.enabled===!0&&St.isPresenting===!0,H=A!==null&&(K===null||q)&&A.begin(I,K);if(E.matrixWorldAutoUpdate===!0&&E.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),St.enabled===!0&&St.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(St.cameraAutoUpdate===!0&&St.updateCamera(U),U=St.getCamera()),E.isScene===!0&&E.onBeforeRender(I,E,U,K),b=ut.get(E,x.length),b.init(U),b.state.textureUnits=$.getTextureUnits(),x.push(b),fe.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Ft.setFromProjectionMatrix(fe,Zn,U.reversedDepth),zt=this.localClippingEnabled,kt=Ut.init(this.clippingPlanes,zt),S=ft.get(E,T.length),S.init(),T.push(S),St.enabled===!0&&St.isPresenting===!0){const _t=I.xr.getDepthSensingMesh();_t!==null&&kl(_t,U,-1/0,I.sortObjects)}kl(E,U,0,I.sortObjects),S.finish(),I.sortObjects===!0&&S.sort(z,At,U.reversedDepth),Ge=St.enabled===!1||St.isPresenting===!1||St.hasDepthSensing()===!1,Ge&&Kt.addToRenderList(S,E),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),kt===!0&&Ut.beginShadows();const G=b.state.shadowsArray;if(Bt.render(G,E,U),kt===!0&&Ut.endShadows(),(H&&A.hasRenderPass())===!1){const _t=S.opaque,mt=S.transmissive;if(b.setupLights(),U.isArrayCamera){const bt=U.cameras;if(mt.length>0)for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const jt=bt[Pt];b0(_t,mt,E,jt)}Ge&&Kt.render(E);for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const jt=bt[Pt];w0(S,E,jt,jt.viewport)}}else mt.length>0&&b0(_t,mt,E,U),Ge&&Kt.render(E),w0(S,E,U)}K!==null&&k===0&&($.updateMultisampleRenderTarget(K),$.updateRenderTargetMipmap(K)),H&&A.end(I),E.isScene===!0&&E.onAfterRender(I,E,U),vt.resetDefaultState(),tt=-1,J=null,x.pop(),x.length>0?(b=x[x.length-1],$.setTextureUnits(b.state.textureUnits),kt===!0&&Ut.setGlobalState(I.clippingPlanes,b.state.camera)):b=null,T.pop(),T.length>0?S=T[T.length-1]:S=null,L!==null&&L.renderEnd()};function kl(E,U,q,H){if(E.visible===!1)return;if(E.layers.test(U.layers)){if(E.isGroup)q=E.renderOrder;else if(E.isLOD)E.autoUpdate===!0&&E.update(U);else if(E.isLightProbeGrid)b.pushLightProbeGrid(E);else if(E.isLight)b.pushLight(E),E.castShadow&&b.pushShadow(E);else if(E.isSprite){if(!E.frustumCulled||Ft.intersectsSprite(E)){H&&He.setFromMatrixPosition(E.matrixWorld).applyMatrix4(fe);const _t=Q.update(E),mt=E.material;mt.visible&&S.push(E,_t,mt,q,He.z,null)}}else if((E.isMesh||E.isLine||E.isPoints)&&(!E.frustumCulled||Ft.intersectsObject(E))){const _t=Q.update(E),mt=E.material;if(H&&(E.boundingSphere!==void 0?(E.boundingSphere===null&&E.computeBoundingSphere(),He.copy(E.boundingSphere.center)):(_t.boundingSphere===null&&_t.computeBoundingSphere(),He.copy(_t.boundingSphere.center)),He.applyMatrix4(E.matrixWorld).applyMatrix4(fe)),Array.isArray(mt)){const bt=_t.groups;for(let Pt=0,$t=bt.length;Pt<$t;Pt++){const jt=bt[Pt],Lt=mt[jt.materialIndex];Lt&&Lt.visible&&S.push(E,_t,Lt,q,He.z,jt)}}else mt.visible&&S.push(E,_t,mt,q,He.z,null)}}const gt=E.children;for(let _t=0,mt=gt.length;_t<mt;_t++)kl(gt[_t],U,q,H)}function w0(E,U,q,H){const{opaque:G,transmissive:gt,transparent:_t}=E;b.setupLightsView(q),kt===!0&&Ut.setGlobalState(I.clippingPlanes,q),H&&y.viewport(it.copy(H)),G.length>0&&No(G,U,q),gt.length>0&&No(gt,U,q),_t.length>0&&No(_t,U,q),y.buffers.depth.setTest(!0),y.buffers.depth.setMask(!0),y.buffers.color.setMask(!0),y.setPolygonOffset(!1)}function b0(E,U,q,H){if((q.isScene===!0?q.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[H.id]===void 0){const Lt=me.has("EXT_color_buffer_half_float")||me.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[H.id]=new je(1,1,{generateMipmaps:!0,type:Lt?ze:nn,minFilter:pa,samples:Math.max(4,R.samples),stencilBuffer:s,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:ne.workingColorSpace})}const gt=b.state.transmissionRenderTarget[H.id],_t=H.viewport||it;gt.setSize(_t.z*I.transmissionResolutionScale,_t.w*I.transmissionResolutionScale);const mt=I.getRenderTarget(),bt=I.getActiveCubeFace(),Pt=I.getActiveMipmapLevel();I.setRenderTarget(gt),I.getClearColor(Jt),qt=I.getClearAlpha(),qt<1&&I.setClearColor(16777215,.5),I.clear(),Ge&&Kt.render(q);const $t=I.toneMapping;I.toneMapping=Qn;const jt=H.viewport;if(H.viewport!==void 0&&(H.viewport=void 0),b.setupLightsView(H),kt===!0&&Ut.setGlobalState(I.clippingPlanes,H),No(E,q,H),$.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt),me.has("WEBGL_multisampled_render_to_texture")===!1){let Lt=!1;for(let Se=0,Ke=U.length;Se<Ke;Se++){const We=U[Se],{object:be,geometry:wi,material:xt,group:Xi}=We;if(xt.side===en&&be.layers.test(H.layers)){const re=xt.side;xt.side=Ue,xt.needsUpdate=!0,E0(be,q,H,wi,xt,Xi),xt.side=re,xt.needsUpdate=!0,Lt=!0}}Lt===!0&&($.updateMultisampleRenderTarget(gt),$.updateRenderTargetMipmap(gt))}I.setRenderTarget(mt,bt,Pt),I.setClearColor(Jt,qt),jt!==void 0&&(H.viewport=jt),I.toneMapping=$t}function No(E,U,q){const H=U.isScene===!0?U.overrideMaterial:null;for(let G=0,gt=E.length;G<gt;G++){const _t=E[G],{object:mt,geometry:bt,group:Pt}=_t;let $t=_t.material;$t.allowOverride===!0&&H!==null&&($t=H),mt.layers.test(q.layers)&&E0(mt,U,q,bt,$t,Pt)}}function E0(E,U,q,H,G,gt){E.onBeforeRender(I,U,q,H,G,gt),E.modelViewMatrix.multiplyMatrices(q.matrixWorldInverse,E.matrixWorld),E.normalMatrix.getNormalMatrix(E.modelViewMatrix),G.onBeforeRender(I,U,q,H,E,gt),G.transparent===!0&&G.side===en&&G.forceSinglePass===!1?(G.side=Ue,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,E,gt),G.side=Ys,G.needsUpdate=!0,I.renderBufferDirect(q,U,H,G,E,gt),G.side=en):I.renderBufferDirect(q,U,H,G,E,gt),E.onAfterRender(I,U,q,H,G,gt)}function Oo(E,U,q){U.isScene!==!0&&(U=Le);const H=V.get(E),G=b.state.lights,gt=b.state.shadowsArray,_t=G.state.version,mt=ht.getParameters(E,G.state,gt,U,q,b.state.lightProbeGridArray),bt=ht.getProgramCacheKey(mt);let Pt=H.programs;H.environment=E.isMeshStandardMaterial||E.isMeshLambertMaterial||E.isMeshPhongMaterial?U.environment:null,H.fog=U.fog;const $t=E.isMeshStandardMaterial||E.isMeshLambertMaterial&&!E.envMap||E.isMeshPhongMaterial&&!E.envMap;H.envMap=ot.get(E.envMap||H.environment,$t),H.envMapRotation=H.environment!==null&&E.envMap===null?U.environmentRotation:E.envMapRotation,Pt===void 0&&(E.addEventListener("dispose",Nn),Pt=new Map,H.programs=Pt);let jt=Pt.get(bt);if(jt!==void 0){if(H.currentProgram===jt&&H.lightsStateVersion===_t)return T0(E,mt),jt}else mt.uniforms=ht.getUniforms(E),L!==null&&E.isNodeMaterial&&L.build(E,q,mt),E.onBeforeCompile(mt,I),jt=ht.acquireProgram(mt,bt),Pt.set(bt,jt),H.uniforms=mt.uniforms;const Lt=H.uniforms;return(!E.isShaderMaterial&&!E.isRawShaderMaterial||E.clipping===!0)&&(Lt.clippingPlanes=Ut.uniform),T0(E,mt),H.needsLights=D1(E),H.lightsStateVersion=_t,H.needsLights&&(Lt.ambientLightColor.value=G.state.ambient,Lt.lightProbe.value=G.state.probe,Lt.directionalLights.value=G.state.directional,Lt.directionalLightShadows.value=G.state.directionalShadow,Lt.spotLights.value=G.state.spot,Lt.spotLightShadows.value=G.state.spotShadow,Lt.rectAreaLights.value=G.state.rectArea,Lt.ltc_1.value=G.state.rectAreaLTC1,Lt.ltc_2.value=G.state.rectAreaLTC2,Lt.pointLights.value=G.state.point,Lt.pointLightShadows.value=G.state.pointShadow,Lt.hemisphereLights.value=G.state.hemi,Lt.directionalShadowMatrix.value=G.state.directionalShadowMatrix,Lt.spotLightMatrix.value=G.state.spotLightMatrix,Lt.spotLightMap.value=G.state.spotLightMap,Lt.pointShadowMatrix.value=G.state.pointShadowMatrix),H.lightProbeGrid=b.state.lightProbeGridArray.length>0,H.currentProgram=jt,H.uniformsList=null,jt}function A0(E){if(E.uniformsList===null){const U=E.currentProgram.getUniforms();E.uniformsList=Xc.seqWithValue(U.seq,E.uniforms)}return E.uniformsList}function T0(E,U){const q=V.get(E);q.outputColorSpace=U.outputColorSpace,q.batching=U.batching,q.batchingColor=U.batchingColor,q.instancing=U.instancing,q.instancingColor=U.instancingColor,q.instancingMorph=U.instancingMorph,q.skinning=U.skinning,q.morphTargets=U.morphTargets,q.morphNormals=U.morphNormals,q.morphColors=U.morphColors,q.morphTargetsCount=U.morphTargetsCount,q.numClippingPlanes=U.numClippingPlanes,q.numIntersection=U.numClipIntersection,q.vertexAlphas=U.vertexAlphas,q.vertexTangents=U.vertexTangents,q.toneMapping=U.toneMapping}function A1(E,U){if(E.length===0)return null;if(E.length===1)return E[0].texture!==null?E[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let q=0,H=E.length;q<H;q++){const G=E[q];if(G.texture!==null&&G.boundingBox.containsPoint(M))return G}return null}function T1(E,U,q,H,G){U.isScene!==!0&&(U=Le),$.resetTextureUnits();const gt=U.fog,_t=H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial?U.environment:null,mt=K===null?I.outputColorSpace:K.isXRRenderTarget===!0?K.texture.colorSpace:ne.workingColorSpace,bt=H.isMeshStandardMaterial||H.isMeshLambertMaterial&&!H.envMap||H.isMeshPhongMaterial&&!H.envMap,Pt=ot.get(H.envMap||_t,bt),$t=H.vertexColors===!0&&!!q.attributes.color&&q.attributes.color.itemSize===4,jt=!!q.attributes.tangent&&(!!H.normalMap||H.anisotropy>0),Lt=!!q.morphAttributes.position,Se=!!q.morphAttributes.normal,Ke=!!q.morphAttributes.color;let We=Qn;H.toneMapped&&(K===null||K.isXRRenderTarget===!0)&&(We=I.toneMapping);const be=q.morphAttributes.position||q.morphAttributes.normal||q.morphAttributes.color,wi=be!==void 0?be.length:0,xt=V.get(H),Xi=b.state.lights;if(kt===!0&&(zt===!0||E!==J)){const Te=E===J&&H.id===tt;Ut.setState(H,E,Te)}let re=!1;H.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==Xi.state.version||xt.outputColorSpace!==mt||G.isBatchedMesh&&xt.batching===!1||!G.isBatchedMesh&&xt.batching===!0||G.isBatchedMesh&&xt.batchingColor===!0&&G.colorTexture===null||G.isBatchedMesh&&xt.batchingColor===!1&&G.colorTexture!==null||G.isInstancedMesh&&xt.instancing===!1||!G.isInstancedMesh&&xt.instancing===!0||G.isSkinnedMesh&&xt.skinning===!1||!G.isSkinnedMesh&&xt.skinning===!0||G.isInstancedMesh&&xt.instancingColor===!0&&G.instanceColor===null||G.isInstancedMesh&&xt.instancingColor===!1&&G.instanceColor!==null||G.isInstancedMesh&&xt.instancingMorph===!0&&G.morphTexture===null||G.isInstancedMesh&&xt.instancingMorph===!1&&G.morphTexture!==null||xt.envMap!==Pt||H.fog===!0&&xt.fog!==gt||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Ut.numPlanes||xt.numIntersection!==Ut.numIntersection)||xt.vertexAlphas!==$t||xt.vertexTangents!==jt||xt.morphTargets!==Lt||xt.morphNormals!==Se||xt.morphColors!==Ke||xt.toneMapping!==We||xt.morphTargetsCount!==wi||!!xt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(re=!0):(re=!0,xt.__version=H.version);let rn=xt.currentProgram;re===!0&&(rn=Oo(H,U,G),L&&H.isNodeMaterial&&L.onUpdateProgram(H,rn,xt));let On=!1,bs=!1,Aa=!1;const Ee=rn.getUniforms(),$e=xt.uniforms;if(y.useProgram(rn.program)&&(On=!0,bs=!0,Aa=!0),H.id!==tt&&(tt=H.id,bs=!0),xt.needsLights){const Te=A1(b.state.lightProbeGridArray,G);xt.lightProbeGrid!==Te&&(xt.lightProbeGrid=Te,bs=!0)}if(On||J!==E){y.buffers.depth.getReversed()&&E.reversedDepth!==!0&&(E._reversedDepth=!0,E.updateProjectionMatrix()),Ee.setValue(O,"projectionMatrix",E.projectionMatrix),Ee.setValue(O,"viewMatrix",E.matrixWorldInverse);const As=Ee.map.cameraPosition;As!==void 0&&As.setValue(O,pe.setFromMatrixPosition(E.matrixWorld)),R.logarithmicDepthBuffer&&Ee.setValue(O,"logDepthBufFC",2/(Math.log(E.far+1)/Math.LN2)),(H.isMeshPhongMaterial||H.isMeshToonMaterial||H.isMeshLambertMaterial||H.isMeshBasicMaterial||H.isMeshStandardMaterial||H.isShaderMaterial)&&Ee.setValue(O,"isOrthographic",E.isOrthographicCamera===!0),J!==E&&(J=E,bs=!0,Aa=!0)}if(xt.needsLights&&(Xi.state.directionalShadowMap.length>0&&Ee.setValue(O,"directionalShadowMap",Xi.state.directionalShadowMap,$),Xi.state.spotShadowMap.length>0&&Ee.setValue(O,"spotShadowMap",Xi.state.spotShadowMap,$),Xi.state.pointShadowMap.length>0&&Ee.setValue(O,"pointShadowMap",Xi.state.pointShadowMap,$)),G.isSkinnedMesh){Ee.setOptional(O,G,"bindMatrix"),Ee.setOptional(O,G,"bindMatrixInverse");const Te=G.skeleton;Te&&(Te.boneTexture===null&&Te.computeBoneTexture(),Ee.setValue(O,"boneTexture",Te.boneTexture,$))}G.isBatchedMesh&&(Ee.setOptional(O,G,"batchingTexture"),Ee.setValue(O,"batchingTexture",G._matricesTexture,$),Ee.setOptional(O,G,"batchingIdTexture"),Ee.setValue(O,"batchingIdTexture",G._indirectTexture,$),Ee.setOptional(O,G,"batchingColorTexture"),G._colorsTexture!==null&&Ee.setValue(O,"batchingColorTexture",G._colorsTexture,$));const Es=q.morphAttributes;if((Es.position!==void 0||Es.normal!==void 0||Es.color!==void 0)&&N.update(G,q,rn),(bs||xt.receiveShadow!==G.receiveShadow)&&(xt.receiveShadow=G.receiveShadow,Ee.setValue(O,"receiveShadow",G.receiveShadow)),(H.isMeshStandardMaterial||H.isMeshLambertMaterial||H.isMeshPhongMaterial)&&H.envMap===null&&U.environment!==null&&($e.envMapIntensity.value=U.environmentIntensity),$e.dfgLUT!==void 0&&($e.dfgLUT.value=WS()),bs){if(Ee.setValue(O,"toneMappingExposure",I.toneMappingExposure),xt.needsLights&&R1($e,Aa),gt&&H.fog===!0&&It.refreshFogUniforms($e,gt),It.refreshMaterialUniforms($e,H,nt,at,b.state.transmissionRenderTarget[E.id]),xt.needsLights&&xt.lightProbeGrid){const Te=xt.lightProbeGrid;$e.probesSH.value=Te.texture,$e.probesMin.value.copy(Te.boundingBox.min),$e.probesMax.value.copy(Te.boundingBox.max),$e.probesResolution.value.copy(Te.resolution)}Xc.upload(O,A0(xt),$e,$)}if(H.isShaderMaterial&&H.uniformsNeedUpdate===!0&&(Xc.upload(O,A0(xt),$e,$),H.uniformsNeedUpdate=!1),H.isSpriteMaterial&&Ee.setValue(O,"center",G.center),Ee.setValue(O,"modelViewMatrix",G.modelViewMatrix),Ee.setValue(O,"normalMatrix",G.normalMatrix),Ee.setValue(O,"modelMatrix",G.matrixWorld),H.uniformsGroups!==void 0){const Te=H.uniformsGroups;for(let As=0,Ta=Te.length;As<Ta;As++){const R0=Te[As];et.update(R0,rn),et.bind(R0,rn)}}return rn}function R1(E,U){E.ambientLightColor.needsUpdate=U,E.lightProbe.needsUpdate=U,E.directionalLights.needsUpdate=U,E.directionalLightShadows.needsUpdate=U,E.pointLights.needsUpdate=U,E.pointLightShadows.needsUpdate=U,E.spotLights.needsUpdate=U,E.spotLightShadows.needsUpdate=U,E.rectAreaLights.needsUpdate=U,E.hemisphereLights.needsUpdate=U}function D1(E){return E.isMeshLambertMaterial||E.isMeshToonMaterial||E.isMeshPhongMaterial||E.isMeshStandardMaterial||E.isShadowMaterial||E.isShaderMaterial&&E.lights===!0}this.getActiveCubeFace=function(){return B},this.getActiveMipmapLevel=function(){return k},this.getRenderTarget=function(){return K},this.setRenderTargetTextures=function(E,U,q){const H=V.get(E);H.__autoAllocateDepthBuffer=E.resolveDepthBuffer===!1,H.__autoAllocateDepthBuffer===!1&&(H.__useRenderToTexture=!1),V.get(E.texture).__webglTexture=U,V.get(E.depthTexture).__webglTexture=H.__autoAllocateDepthBuffer?void 0:q,H.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(E,U){const q=V.get(E);q.__webglFramebuffer=U,q.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(E,U=0,q=0){K=E,B=U,k=q;let H=null,G=!1,gt=!1;if(E){const mt=V.get(E);if(mt.__useDefaultFramebuffer!==void 0){y.bindFramebuffer(O.FRAMEBUFFER,mt.__webglFramebuffer),it.copy(E.viewport),rt.copy(E.scissor),Gt=E.scissorTest,y.viewport(it),y.scissor(rt),y.setScissorTest(Gt),tt=-1;return}else if(mt.__webglFramebuffer===void 0)$.setupRenderTarget(E);else if(mt.__hasExternalTextures)$.rebindTextures(E,V.get(E.texture).__webglTexture,V.get(E.depthTexture).__webglTexture);else if(E.depthBuffer){const $t=E.depthTexture;if(mt.__boundDepthTexture!==$t){if($t!==null&&V.has($t)&&(E.width!==$t.image.width||E.height!==$t.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");$.setupDepthRenderbuffer(E)}}const bt=E.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(gt=!0);const Pt=V.get(E).__webglFramebuffer;E.isWebGLCubeRenderTarget?(Array.isArray(Pt[U])?H=Pt[U][q]:H=Pt[U],G=!0):E.samples>0&&$.useMultisampledRTT(E)===!1?H=V.get(E).__webglMultisampledFramebuffer:Array.isArray(Pt)?H=Pt[q]:H=Pt,it.copy(E.viewport),rt.copy(E.scissor),Gt=E.scissorTest}else it.copy(Nt).multiplyScalar(nt).floor(),rt.copy(Ct).multiplyScalar(nt).floor(),Gt=yt;if(q!==0&&(H=W),y.bindFramebuffer(O.FRAMEBUFFER,H)&&y.drawBuffers(E,H),y.viewport(it),y.scissor(rt),y.setScissorTest(Gt),G){const mt=V.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_CUBE_MAP_POSITIVE_X+U,mt.__webglTexture,q)}else if(gt){const mt=U;for(let bt=0;bt<E.textures.length;bt++){const Pt=V.get(E.textures[bt]);O.framebufferTextureLayer(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0+bt,Pt.__webglTexture,q,mt)}}else if(E!==null&&q!==0){const mt=V.get(E.texture);O.framebufferTexture2D(O.FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,mt.__webglTexture,q)}tt=-1},this.readRenderTargetPixels=function(E,U,q,H,G,gt,_t,mt=0){if(!(E&&E.isWebGLRenderTarget)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=V.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt){y.bindFramebuffer(O.FRAMEBUFFER,bt);try{const Pt=E.textures[mt],$t=Pt.format,jt=Pt.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+mt),!R.textureFormatReadable($t)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(jt)){Ht("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=E.width-H&&q>=0&&q<=E.height-G&&O.readPixels(U,q,H,G,dt.convert($t),dt.convert(jt),gt)}finally{const Pt=K!==null?V.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Pt)}}},this.readRenderTargetPixelsAsync=async function(E,U,q,H,G,gt,_t,mt=0){if(!(E&&E.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=V.get(E).__webglFramebuffer;if(E.isWebGLCubeRenderTarget&&_t!==void 0&&(bt=bt[_t]),bt)if(U>=0&&U<=E.width-H&&q>=0&&q<=E.height-G){y.bindFramebuffer(O.FRAMEBUFFER,bt);const Pt=E.textures[mt],$t=Pt.format,jt=Pt.type;if(E.textures.length>1&&O.readBuffer(O.COLOR_ATTACHMENT0+mt),!R.textureFormatReadable($t))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(jt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Lt=O.createBuffer();O.bindBuffer(O.PIXEL_PACK_BUFFER,Lt),O.bufferData(O.PIXEL_PACK_BUFFER,gt.byteLength,O.STREAM_READ),O.readPixels(U,q,H,G,dt.convert($t),dt.convert(jt),0);const Se=K!==null?V.get(K).__webglFramebuffer:null;y.bindFramebuffer(O.FRAMEBUFFER,Se);const Ke=O.fenceSync(O.SYNC_GPU_COMMANDS_COMPLETE,0);return O.flush(),await xv(O,Ke,4),O.bindBuffer(O.PIXEL_PACK_BUFFER,Lt),O.getBufferSubData(O.PIXEL_PACK_BUFFER,0,gt),O.deleteBuffer(Lt),O.deleteSync(Ke),gt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(E,U=null,q=0){const H=Math.pow(2,-q),G=Math.floor(E.image.width*H),gt=Math.floor(E.image.height*H),_t=U!==null?U.x:0,mt=U!==null?U.y:0;$.setTexture2D(E,0),O.copyTexSubImage2D(O.TEXTURE_2D,q,0,0,_t,mt,G,gt),y.unbindTexture()},this.copyTextureToTexture=function(E,U,q=null,H=null,G=0,gt=0){let _t,mt,bt,Pt,$t,jt,Lt,Se,Ke;const We=E.isCompressedTexture?E.mipmaps[gt]:E.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,Pt=q.min.x,$t=q.min.y,jt=q.isBox3?q.min.z:0;else{const $e=Math.pow(2,-G);_t=Math.floor(We.width*$e),mt=Math.floor(We.height*$e),E.isDataArrayTexture?bt=We.depth:E.isData3DTexture?bt=Math.floor(We.depth*$e):bt=1,Pt=0,$t=0,jt=0}H!==null?(Lt=H.x,Se=H.y,Ke=H.z):(Lt=0,Se=0,Ke=0);const be=dt.convert(U.format),wi=dt.convert(U.type);let xt;U.isData3DTexture?($.setTexture3D(U,0),xt=O.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?($.setTexture2DArray(U,0),xt=O.TEXTURE_2D_ARRAY):($.setTexture2D(U,0),xt=O.TEXTURE_2D),y.activeTexture(O.TEXTURE0),y.pixelStorei(O.UNPACK_FLIP_Y_WEBGL,U.flipY),y.pixelStorei(O.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),y.pixelStorei(O.UNPACK_ALIGNMENT,U.unpackAlignment);const Xi=y.getParameter(O.UNPACK_ROW_LENGTH),re=y.getParameter(O.UNPACK_IMAGE_HEIGHT),rn=y.getParameter(O.UNPACK_SKIP_PIXELS),On=y.getParameter(O.UNPACK_SKIP_ROWS),bs=y.getParameter(O.UNPACK_SKIP_IMAGES);y.pixelStorei(O.UNPACK_ROW_LENGTH,We.width),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,We.height),y.pixelStorei(O.UNPACK_SKIP_PIXELS,Pt),y.pixelStorei(O.UNPACK_SKIP_ROWS,$t),y.pixelStorei(O.UNPACK_SKIP_IMAGES,jt);const Aa=E.isDataArrayTexture||E.isData3DTexture,Ee=U.isDataArrayTexture||U.isData3DTexture;if(E.isDepthTexture){const $e=V.get(E),Es=V.get(U),Te=V.get($e.__renderTarget),As=V.get(Es.__renderTarget);y.bindFramebuffer(O.READ_FRAMEBUFFER,Te.__webglFramebuffer),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,As.__webglFramebuffer);for(let Ta=0;Ta<bt;Ta++)Aa&&(O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,V.get(E).__webglTexture,G,jt+Ta),O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,V.get(U).__webglTexture,gt,Ke+Ta)),O.blitFramebuffer(Pt,$t,_t,mt,Lt,Se,_t,mt,O.DEPTH_BUFFER_BIT,O.NEAREST);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else if(G!==0||E.isRenderTargetTexture||V.has(E)){const $e=V.get(E),Es=V.get(U);y.bindFramebuffer(O.READ_FRAMEBUFFER,X),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,P);for(let Te=0;Te<bt;Te++)Aa?O.framebufferTextureLayer(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,$e.__webglTexture,G,jt+Te):O.framebufferTexture2D(O.READ_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,$e.__webglTexture,G),Ee?O.framebufferTextureLayer(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,Es.__webglTexture,gt,Ke+Te):O.framebufferTexture2D(O.DRAW_FRAMEBUFFER,O.COLOR_ATTACHMENT0,O.TEXTURE_2D,Es.__webglTexture,gt),G!==0?O.blitFramebuffer(Pt,$t,_t,mt,Lt,Se,_t,mt,O.COLOR_BUFFER_BIT,O.NEAREST):Ee?O.copyTexSubImage3D(xt,gt,Lt,Se,Ke+Te,Pt,$t,_t,mt):O.copyTexSubImage2D(xt,gt,Lt,Se,Pt,$t,_t,mt);y.bindFramebuffer(O.READ_FRAMEBUFFER,null),y.bindFramebuffer(O.DRAW_FRAMEBUFFER,null)}else Ee?E.isDataTexture||E.isData3DTexture?O.texSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,wi,We.data):U.isCompressedArrayTexture?O.compressedTexSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,We.data):O.texSubImage3D(xt,gt,Lt,Se,Ke,_t,mt,bt,be,wi,We):E.isDataTexture?O.texSubImage2D(O.TEXTURE_2D,gt,Lt,Se,_t,mt,be,wi,We.data):E.isCompressedTexture?O.compressedTexSubImage2D(O.TEXTURE_2D,gt,Lt,Se,We.width,We.height,be,We.data):O.texSubImage2D(O.TEXTURE_2D,gt,Lt,Se,_t,mt,be,wi,We);y.pixelStorei(O.UNPACK_ROW_LENGTH,Xi),y.pixelStorei(O.UNPACK_IMAGE_HEIGHT,re),y.pixelStorei(O.UNPACK_SKIP_PIXELS,rn),y.pixelStorei(O.UNPACK_SKIP_ROWS,On),y.pixelStorei(O.UNPACK_SKIP_IMAGES,bs),gt===0&&U.generateMipmaps&&O.generateMipmap(xt),y.unbindTexture()},this.initRenderTarget=function(E){V.get(E).__webglFramebuffer===void 0&&$.setupRenderTarget(E)},this.initTexture=function(E){E.isCubeTexture?$.setTextureCube(E,0):E.isData3DTexture?$.setTexture3D(E,0):E.isDataArrayTexture||E.isCompressedArrayTexture?$.setTexture2DArray(E,0):$.setTexture2D(E,0),y.unbindTexture()},this.resetState=function(){B=0,k=0,K=null,y.reset(),vt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Zn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=ne._getDrawingBufferColorSpace(t),e.unpackColorSpace=ne._getUnpackColorSpace()}}const qS=`
|
|
4812
4812
|
varying vec3 vDir;
|
|
4813
4813
|
varying vec3 vWorldDir;
|
|
4814
4814
|
|
|
@@ -5238,7 +5238,11 @@ float densityAt(vec3 p) {
|
|
|
5238
5238
|
if (mask < 0.001) return 0.0;
|
|
5239
5239
|
float top = mix(0.45 + 0.55 * billow, 0.96, flatness);
|
|
5240
5240
|
float profile = smoothstep(0.0, 0.09, h) * (1.0 - smoothstep(top - 0.22, top, h));
|
|
5241
|
-
|
|
5241
|
+
// The billows' and the detail's bite goes with them into the distance: taken off a mask already
|
|
5242
|
+
// averaged to the cover, it took more than the cover left (0.095 − 0.19 at Valensole), and a deck
|
|
5243
|
+
// stopped dead thirty kilometres out — a line of cloud with clear sky under it to the horizon.
|
|
5244
|
+
float bite = 1.0 - distant;
|
|
5245
|
+
float erosion = mix(max(0.0, mask - ((1.0 - billow) * 0.38 + (1.0 - detail) * 0.10) * bite), mask * 0.8, flatness);
|
|
5242
5246
|
return profile * erosion * density * carve;
|
|
5243
5247
|
}
|
|
5244
5248
|
void main() {
|
|
@@ -5324,7 +5328,7 @@ float transmissionAt(vec3 dir, float distanceM) {
|
|
|
5324
5328
|
if (transmission < 0.015) break;
|
|
5325
5329
|
}
|
|
5326
5330
|
return transmission;
|
|
5327
|
-
}`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(t+e).replace(i,n=>a+n)}class dl{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new D(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.4,.45,.5)},hazeColor:{value:new st(.5,.6,.7)},offsetM:{value:new D},seedOffset:{value:new D},localCenter:{value:new D},localSize:{value:new D},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Wr},()=>new D)},holeSize:{value:Array.from({length:Wr},()=>new D)},holeRotation:{value:new Array(Wr).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new ae({uniforms:this.uniforms,vertexShader:ZS,fragmentShader:sd,transparent:!0,depthWrite:!1,depthTest:!0,side:Ue});this.mesh=new Dt(new Qe(e,32,16),i),this.mesh.frustumCulled=!1}update(t,e,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(Wr,n.length),n.slice(0,Wr).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,t.baseM),s.thicknessM.value=Math.max(10,t.thicknessM),s.coverage.value=Math.max(0,Math.min(1,t.coverage)),s.sizeM.value=Math.max(50,t.sizeM),s.density.value=Math.max(0,Math.min(2,t.density)),s.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),s.eyeM.value=Math.max(.1,e),s.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const r=nd(t);s.seedOffset.value.set(r%97/97,r%61/61,r%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,i=(z,N,V)=>{const k=Math.max(0,Math.min(1,(V-z)/(N-z)));return k*k*(3-2*k)},n=(z,N,V)=>z+(N-z)*V,s=e.eyeM.value+t.y,r=2*Gs*s+t.x**2+s**2+t.z**2,o=r/(Math.sqrt(Gs**2+r)+Gs),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=(z,N,V)=>{const k=t.x+e.offsetM.value.x-z.x,K=t.z+e.offsetM.value.z-z.z,tt=Math.cos(V),J=Math.sin(V);return Math.hypot((tt*k-J*K)/(N.x*.5),(o-z.y)/(N.y*.5),(J*k+tt*K)/(N.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((z,N)=>(z+e.offsetM.value.getComponent(N))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(N)),f=e.noiseMap.value.image.data,p=(z,N,V)=>{const k=[z,N,V].map(it=>(it%1+1)%1*Je-.5),K=k.map(Math.floor),tt=k.map((it,ot)=>it-K[ot]);let J=0;for(let it=0;it<2;it++)for(let ot=0;ot<2;ot++)for(let Vt=0;Vt<2;Vt++){const Qt=(K[0]+Vt+Je)%Je,qt=(K[1]+ot+Je)%Je,Y=(K[2]+it+Je)%Je;J+=f[Qt+Je*(qt+Je*Y)]/255*(Vt?tt[0]:1-tt[0])*(ot?tt[1]:1-tt[1])*(it?tt[2]:1-tt[2])}return J},v=[d[0]*.173,Ah,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let _=i(.2,.8,p(d[0],Ah,d[2])*.65+p(m,Ah+.37,g)*.35);const w=i(8e3,4e4,Math.hypot(t.x,t.y,t.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,w),S=n(p(d[0]*7,d[1]*7,d[2]*7),.5,w);let b=dl.thresholdFor(e.coverage.value),T=1,x=0;if(l){const z=u+(M-.5)*.18;x=1-i(.35,1,z),T=1-i(.85,1.15,z),_=n(_,1,x),b=Math.min(b,dl.thresholdFor(.5))}for(let z=0;z<e.holeCount.value;z++)T*=i(.85,1.15,h(e.holeCenter.value[z],e.holeSize.value[z],e.holeRotation.value[z])+(M-.5)*.18);if(T<.001)return 0;const A=(1-e.flatness.value)*.3*c*c;let I=i(b-.1+A,b+.1+A,_+(M-.5)*.12*c);if(I=n(I,1,i(.92,1,e.coverage.value)),I=n(I,Math.max(e.coverage.value,x),w),I<.001)return 0;const C=n(.45+.55*M,.96,e.flatness.value),P=i(0,.09,c)*(1-i(C-.22,C,c)),X=n(Math.max(0,I-(1-M)*.38-(1-S)*.1),I*.8,e.flatness.value);return P*X*e.density.value*T}transmissionAt(t,e=1/0){const i=this.uniforms,n=$S(t.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,r]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Gs);const u=i.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;s=Math.max(s,d-Math.sqrt(f)),r=Math.min(r,d+Math.sqrt(f))}const o=Math.min(r,e,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x: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 ci{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=ci.build(24);static build(t){const e=[];let i=0,n=0,s=0;for(let r=0;r<t;r++){const o=ci.VIOLET_NM+(r+.5)/t*(ci.DEEP_RED_NM-ci.VIOLET_NM),[c,l,h]=ci.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,e.push(u)}for(const r of e)r.r/=i,r.g/=n,r.b/=s;return e}static tristimulus(t,e,i){let n=0,s=0,r=0;for(let c=0;c<t.length;c++){const[l,h,u]=ci.colourMatching(t[c]);n+=l*e[c],s+=h*e[c],r+=u*e[c]}const o=683*i;return[n*o,s*o,r*o]}static scotopic(t){const e=t/1e3;return .992*Math.exp(-321.9*(e-.5)**2)}static linearSrgbOf([t,e,i]){return[3.2406*t-1.5372*e-.4986*i,-.9689*t+1.8758*e+.0415*i,.0557*t-.204*e+1.057*i]}static colourMatching(t){const e=(i,n,s)=>{const r=(t-i)/(t<i?n:s);return Math.exp(-.5*r*r)};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 fl{static reflectance(t,e,i){const s=e/i*Math.sqrt(Math.max(0,1-t*t));if(s>=1)return 1;const r=Math.sqrt(Math.max(0,1-s*s)),o=(i*t-e*r)/(i*t+e*r),c=(e*t-i*r)/(e*t+i*r);return(o*o+c*c)/2}}class gi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(gi.ANCHOR_BLUE-gi.ANCHOR_RED)/(1/(gi.BLUE_NM*gi.BLUE_NM)-1/(gi.RED_NM*gi.RED_NM));static A=gi.ANCHOR_RED-gi.B/(gi.RED_NM*gi.RED_NM);static indexAt(t){return gi.A+gi.B/(t*t)}}class dr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const i=Math.min(1,Math.max(0,t)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,r=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=fl.reflectance(n,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=dr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=fl.reflectance(r,this.index,1);let d=1-l;for(let f=1;f<=dr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=dr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let i=t%e;return i<0&&(i+=e),i>Math.PI?e-i:i}}class Ze{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new dr;previous=Ze.emergences();current=Ze.emergences();tally=new Float32Array(Ze.BINS*3);radiance=new Float32Array(Ze.BINS*3);scratch=new Float32Array(Ze.BINS*3);static emergences(){return Array.from({length:dr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of ci.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ze.BINS,data:this.radiance,binDeg:180/Ze.BINS}}sweep(t){this.drop.refractiveIndex=gi.indexAt(t.wavelengthNm);const e=Ze.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/e;for(let s=1;s<=e;s++){const r=this.drop.trace(Math.sqrt(s/e),this.current);for(let o=0;o<Math.min(r,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,t)}i=r,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let i=0;i<t.length;i++)e[i].chords=t[i].chords,e[i].scatteringAngle=t[i].scatteringAngle,e[i].weight=t[i].weight}deposit(t,e,i,n){if(i<=0)return;const s=Ze.BINS,r=Math.PI/s,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/r))),u=Math.min(s-1,Math.max(0,Math.floor(c/r)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*r)-Math.max(o,d*r);f>0&&this.add(d,i*f/l,n)}}add(t,e,i){const n=t*3,s=e*ci.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const t=Ze.BINS,e=Math.PI/t;for(let i=0;i<t;i++){const n=2*Math.PI*(Math.cos(i*e)-Math.cos((i+1)*e)),s=n>0?this.backwardShare((i+.5)*(180/t))/n:0,r=i*3;this.radiance[r]=this.tally[r]*s,this.radiance[r+1]=this.tally[r+1]*s,this.radiance[r+2]=this.tally[r+2]*s}}backwardShare(t){const e=180-t;if(e<=Ze.FULL_UNTIL_DEG)return 1;if(e>=Ze.FADED_BY_DEG)return 0;const i=(e-Ze.FULL_UNTIL_DEG)/(Ze.FADED_BY_DEG-Ze.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const t=Ze.BINS,e=Ze.SOURCE_RADIUS_DEG*t/180,i=Math.max(1,Math.ceil(e)),n=[];let s=0;for(let r=-i;r<=i;r++){const o=Math.max(0,e*e-r*r),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let r=0;r<t;r++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(t-1,Math.max(0,r+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=r*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class ga{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ze;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ze.BINS*4),this.texture=new Js(this.texels,Ze.BINS,1,_i,ze),this.texture.minFilter=se,this.texture.magFilter=se,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new ae({uniforms:{uSource:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:ga.GAIN}},vertexShader:`
|
|
5331
|
+
}`,i=/\b(noiseMap|sunDir|sunColor|ambientColor|hazeColor|offsetM|seedOffset|localCenter|localSize|localRotation|baseM|thicknessM|eyeM|coverage|sizeM|density|darkness|flatness|SLICE|MAX_HOLES|holeCount|holeCenter|holeSize|holeRotation|R|roots|altitude|coverageThreshold|ellipsoidRadius|clipLocal|densityAt|transmissionAt)\b/g;return(t+e).replace(i,n=>a+n)}class dl{mesh;uniforms;constructor(t,e){this.uniforms={noiseMap:{value:t},sunDir:{value:new D(0,1,0)},sunColor:{value:new st(1,1,1)},ambientColor:{value:new st(.4,.45,.5)},hazeColor:{value:new st(.5,.6,.7)},offsetM:{value:new D},seedOffset:{value:new D},localCenter:{value:new D},localSize:{value:new D},localRotation:{value:0},holeCount:{value:0},holeCenter:{value:Array.from({length:Wr},()=>new D)},holeSize:{value:Array.from({length:Wr},()=>new D)},holeRotation:{value:new Array(Wr).fill(0)},baseM:{value:1e3},thicknessM:{value:650},eyeM:{value:1.6},coverage:{value:.5},sizeM:{value:1400},density:{value:1},darkness:{value:0},flatness:{value:0}};const i=new ae({uniforms:this.uniforms,vertexShader:ZS,fragmentShader:sd,transparent:!0,depthWrite:!1,depthTest:!0,side:Ue});this.mesh=new Dt(new Qe(e,32,16),i),this.mesh.frustumCulled=!1}update(t,e,i,n=[]){const s=this.uniforms;s.localSize.value.set(i?.widthM??0,i?.thicknessM??0,i?.depthM??0),s.localCenter.value.set(i?.eastM??0,i?i.baseM+i.thicknessM/2:0,-(i?.northM??0)),s.localRotation.value=(i?.rotationDeg??0)*Math.PI/180,s.holeCount.value=Math.min(Wr,n.length),n.slice(0,Wr).forEach((o,c)=>{s.holeCenter.value[c].set(o.eastM,o.baseM+o.thicknessM/2,-o.northM),s.holeSize.value[c].set(o.widthM,o.thicknessM,o.depthM),s.holeRotation.value[c]=o.rotationDeg*Math.PI/180}),s.baseM.value=Math.max(0,t.baseM),s.thicknessM.value=Math.max(10,t.thicknessM),s.coverage.value=Math.max(0,Math.min(1,t.coverage)),s.sizeM.value=Math.max(50,t.sizeM),s.density.value=Math.max(0,Math.min(2,t.density)),s.darkness.value=Math.max(0,Math.min(1,t.darkness??0)),s.eyeM.value=Math.max(.1,e),s.flatness.value=t.type==="stratus"?1:t.type==="stratocumulus"?.45:0;const r=nd(t);s.seedOffset.value.set(r%97/97,r%61/61,r%37/37),this.mesh.visible=s.density.value>0&&(i!==void 0||s.coverage.value>0)}static thresholdFor(t){const e=Math.min(.999,Math.max(.001,t));return .564-.2516*(Math.sqrt(3)/Math.PI)*Math.log(e/(1-e))}densityAt(t){const e=this.uniforms,i=(P,B,k)=>{const K=Math.max(0,Math.min(1,(k-P)/(B-P)));return K*K*(3-2*K)},n=(P,B,k)=>P+(B-P)*k,s=e.eyeM.value+t.y,r=2*Gs*s+t.x**2+s**2+t.z**2,o=r/(Math.sqrt(Gs**2+r)+Gs),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=(P,B,k)=>{const K=t.x+e.offsetM.value.x-P.x,tt=t.z+e.offsetM.value.z-P.z,J=Math.cos(k),it=Math.sin(k);return Math.hypot((J*K-it*tt)/(B.x*.5),(o-P.y)/(B.y*.5),(it*K+J*tt)/(B.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((P,B)=>(P+e.offsetM.value.getComponent(B))/(e.sizeM.value*4)+e.seedOffset.value.getComponent(B)),f=e.noiseMap.value.image.data,p=(P,B,k)=>{const K=[P,B,k].map(rt=>(rt%1+1)%1*Je-.5),tt=K.map(Math.floor),J=K.map((rt,Gt)=>rt-tt[Gt]);let it=0;for(let rt=0;rt<2;rt++)for(let Gt=0;Gt<2;Gt++)for(let Jt=0;Jt<2;Jt++){const qt=(tt[0]+Jt+Je)%Je,Y=(tt[1]+Gt+Je)%Je,at=(tt[2]+rt+Je)%Je;it+=f[qt+Je*(Y+Je*at)]/255*(Jt?J[0]:1-J[0])*(Gt?J[1]:1-J[1])*(rt?J[2]:1-J[2])}return it},v=[d[0]*.173,Ah,d[2]*.173];d[0]+=(p(v[0]+.13,v[1]+.27,v[2]+.41)-.5)*1.3,d[2]+=(p(v[0]+.67,v[1]+.53,v[2]+.19)-.5)*1.3;const m=(d[0]*.731+d[2]*.682)*1.371,g=(-d[0]*.682+d[2]*.731)*1.371;let _=i(.2,.8,p(d[0],Ah,d[2])*.65+p(m,Ah+.37,g)*.35);const w=i(8e3,4e4,Math.hypot(t.x,t.y,t.z)),M=n(p(d[0]*2,d[1]*3,d[2]*2),.5,w),S=n(p(d[0]*7,d[1]*7,d[2]*7),.5,w);let b=dl.thresholdFor(e.coverage.value),T=1,x=0;if(l){const P=u+(M-.5)*.18;x=1-i(.35,1,P),T=1-i(.85,1.15,P),_=n(_,1,x),b=Math.min(b,dl.thresholdFor(.5))}for(let P=0;P<e.holeCount.value;P++)T*=i(.85,1.15,h(e.holeCenter.value[P],e.holeSize.value[P],e.holeRotation.value[P])+(M-.5)*.18);if(T<.001)return 0;const A=(1-e.flatness.value)*.3*c*c;let I=i(b-.1+A,b+.1+A,_+(M-.5)*.12*c);if(I=n(I,1,i(.92,1,e.coverage.value)),I=n(I,Math.max(e.coverage.value,x),w),I<.001)return 0;const C=n(.45+.55*M,.96,e.flatness.value),L=i(0,.09,c)*(1-i(C-.22,C,c)),W=1-w,X=n(Math.max(0,I-((1-M)*.38+(1-S)*.1)*W),I*.8,e.flatness.value);return L*X*e.density.value*T}transmissionAt(t,e=1/0){const i=this.uniforms,n=$S(t.y,i.eyeM.value,i.baseM.value,i.thicknessM.value);if(!n)return 1;let[s,r]=n;if(i.localSize.value.x>0){const h=i.localCenter.value.clone().sub(i.offsetM.value);h.y-=i.eyeM.value+(h.x**2+h.z**2)/(2*Gs);const u=i.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;s=Math.max(s,d-Math.sqrt(f)),r=Math.min(r,d+Math.sqrt(f))}const o=Math.min(r,e,s+18e3);if(o<=s)return 1;const c=(o-s)/48;let l=1;for(let h=0;h<48;h++){const u=s+(h+.5)*c;if(l*=Math.exp(-this.densityAt({x: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 ci{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=ci.build(24);static build(t){const e=[];let i=0,n=0,s=0;for(let r=0;r<t;r++){const o=ci.VIOLET_NM+(r+.5)/t*(ci.DEEP_RED_NM-ci.VIOLET_NM),[c,l,h]=ci.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};i+=u.r,n+=u.g,s+=u.b,e.push(u)}for(const r of e)r.r/=i,r.g/=n,r.b/=s;return e}static tristimulus(t,e,i){let n=0,s=0,r=0;for(let c=0;c<t.length;c++){const[l,h,u]=ci.colourMatching(t[c]);n+=l*e[c],s+=h*e[c],r+=u*e[c]}const o=683*i;return[n*o,s*o,r*o]}static scotopic(t){const e=t/1e3;return .992*Math.exp(-321.9*(e-.5)**2)}static linearSrgbOf([t,e,i]){return[3.2406*t-1.5372*e-.4986*i,-.9689*t+1.8758*e+.0415*i,.0557*t-.204*e+1.057*i]}static colourMatching(t){const e=(i,n,s)=>{const r=(t-i)/(t<i?n:s);return Math.exp(-.5*r*r)};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 fl{static reflectance(t,e,i){const s=e/i*Math.sqrt(Math.max(0,1-t*t));if(s>=1)return 1;const r=Math.sqrt(Math.max(0,1-s*s)),o=(i*t-e*r)/(i*t+e*r),c=(e*t-i*r)/(e*t+i*r);return(o*o+c*c)/2}}class gi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(gi.ANCHOR_BLUE-gi.ANCHOR_RED)/(1/(gi.BLUE_NM*gi.BLUE_NM)-1/(gi.RED_NM*gi.RED_NM));static A=gi.ANCHOR_RED-gi.B/(gi.RED_NM*gi.RED_NM);static indexAt(t){return gi.A+gi.B/(t*t)}}class dr{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const i=Math.min(1,Math.max(0,t)),n=Math.sqrt(Math.max(0,1-i*i)),s=i/this.index,r=Math.sqrt(Math.max(0,1-s*s)),o=Math.asin(i),c=Math.asin(s),l=fl.reflectance(n,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=dr.folded(Math.PI-2*o),e[h].weight=l,h++;const u=fl.reflectance(r,this.index,1);let d=1-l;for(let f=1;f<=dr.MAX_CHORDS&&h<e.length;f++){const p=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=dr.folded(p),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let i=t%e;return i<0&&(i+=e),i>Math.PI?e-i:i}}class Ze{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new dr;previous=Ze.emergences();current=Ze.emergences();tally=new Float32Array(Ze.BINS*3);radiance=new Float32Array(Ze.BINS*3);scratch=new Float32Array(Ze.BINS*3);static emergences(){return Array.from({length:dr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of ci.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Ze.BINS,data:this.radiance,binDeg:180/Ze.BINS}}sweep(t){this.drop.refractiveIndex=gi.indexAt(t.wavelengthNm);const e=Ze.IMPACT_STEPS;let i=this.drop.trace(0,this.previous);const n=1/e;for(let s=1;s<=e;s++){const r=this.drop.trace(Math.sqrt(s/e),this.current);for(let o=0;o<Math.min(r,i);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*n,t)}i=r,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let i=0;i<t.length;i++)e[i].chords=t[i].chords,e[i].scatteringAngle=t[i].scatteringAngle,e[i].weight=t[i].weight}deposit(t,e,i,n){if(i<=0)return;const s=Ze.BINS,r=Math.PI/s,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(s-1,Math.max(0,Math.floor(o/r))),u=Math.min(s-1,Math.max(0,Math.floor(c/r)));if(l<=0||h===u){this.add(h,i,n);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*r)-Math.max(o,d*r);f>0&&this.add(d,i*f/l,n)}}add(t,e,i){const n=t*3,s=e*ci.SAMPLES.length;this.tally[n]+=s*i.r,this.tally[n+1]+=s*i.g,this.tally[n+2]+=s*i.b}toRadiance(){const t=Ze.BINS,e=Math.PI/t;for(let i=0;i<t;i++){const n=2*Math.PI*(Math.cos(i*e)-Math.cos((i+1)*e)),s=n>0?this.backwardShare((i+.5)*(180/t))/n:0,r=i*3;this.radiance[r]=this.tally[r]*s,this.radiance[r+1]=this.tally[r+1]*s,this.radiance[r+2]=this.tally[r+2]*s}}backwardShare(t){const e=180-t;if(e<=Ze.FULL_UNTIL_DEG)return 1;if(e>=Ze.FADED_BY_DEG)return 0;const i=(e-Ze.FULL_UNTIL_DEG)/(Ze.FADED_BY_DEG-Ze.FULL_UNTIL_DEG);return Math.cos(i*Math.PI/2)**2}blurBySourceDisc(){const t=Ze.BINS,e=Ze.SOURCE_RADIUS_DEG*t/180,i=Math.max(1,Math.ceil(e)),n=[];let s=0;for(let r=-i;r<=i;r++){const o=Math.max(0,e*e-r*r),c=Math.sqrt(o);n.push(c),s+=c}if(!(s<=0)){this.scratch.set(this.radiance);for(let r=0;r<t;r++){let o=0,c=0,l=0;for(let u=-i;u<=i;u++){const d=Math.min(t-1,Math.max(0,r+u))*3,f=n[u+i];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=r*3;this.radiance[h]=o/s,this.radiance[h+1]=c/s,this.radiance[h+2]=l/s}}}}class ga{static RADIUS=880;static RENDER_ORDER=5.5;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Ze;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Ze.BINS*4),this.texture=new Js(this.texels,Ze.BINS,1,_i,ze),this.texture.minFilter=se,this.texture.magFilter=se,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new ae({uniforms:{uSource:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:ga.GAIN}},vertexShader:`
|
|
5328
5332
|
varying vec3 vDirection;
|
|
5329
5333
|
void main() {
|
|
5330
5334
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5490,7 +5494,7 @@ vec3 finish(vec3 relative, vec4 overlay) {
|
|
|
5490
5494
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
5491
5495
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
5492
5496
|
* @license MIT
|
|
5493
|
-
*/const r0=173.1446326846693,ua=14959787069098932e-8,ye=.017453292519943295,wp=.26179938779914946,ts=57.29577951308232,Xg=3.819718634205488,g5=365.24217,bp=new Date("2000-01-01T12:00:00Z"),cs=2*Math.PI,Ns=3600*(180/Math.PI),sr=484813681109536e-20,qg=10800*60,v5=2*qg,Ep=7292115e-11,M5=qg/Math.PI,x5=-.17-5*Math.log10(M5),od=.996647180302104,y5=od*od,cd=6378.1366,_5=cd/ua,Yg=81.30056,o0=.0002959122082855911,ld=2825345909524226e-22,hd=8459715185680659e-23,ud=1292024916781969e-23,dd=1524358900784276e-23;function ml(a){if(a!==!0&&a!==!1)throw console.trace(),`Value is not boolean: ${a}`;return a}function Mi(a){if(!Number.isFinite(a))throw console.trace(),`Value is not a finite number: ${a}`;return a}function Za(a){return a-Math.floor(a)}function S5(a,t){const e=a.x*a.x+a.y*a.y+a.z*a.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(a.x*t.x+a.y*t.y+a.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:ts*Math.acos(n)}var wt;(function(a){a.Sun="Sun",a.Moon="Moon",a.Mercury="Mercury",a.Venus="Venus",a.Earth="Earth",a.Mars="Mars",a.Jupiter="Jupiter",a.Saturn="Saturn",a.Uranus="Uranus",a.Neptune="Neptune",a.Pluto="Pluto",a.SSB="SSB",a.EMB="EMB",a.Star1="Star1",a.Star2="Star2",a.Star3="Star3",a.Star4="Star4",a.Star5="Star5",a.Star6="Star6",a.Star7="Star7",a.Star8="Star8"})(wt||(wt={}));const w5=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],b5=[{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 E5(a){const t=w5.indexOf(a);return t>=0?b5[t]:null}function c0(a){const t=E5(a);return t&&t.dist>0?t:null}var Si;(function(a){a[a.From2000=0]="From2000",a[a.Into2000=1]="Into2000"})(Si||(Si={}));const Jn={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 A5(a){var t,e,i,n,s,r,o;const c=2e3+(a-14)/g5;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*r):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*r):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*r+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):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 T5=A5;function Ap(a){return a+T5(a)/86400}class mr{constructor(t){if(t instanceof mr){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()-bp.getTime())/e,this.tt=Ap(this.ut);return}if(Number.isFinite(t)){this.date=new Date(bp.getTime()+t*e),this.ut=t,this.tt=Ap(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 mr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new mr(this.ut+t)}}function Be(a){return a instanceof mr?a:new mr(a)}function R5(a){function t(d){return d%v5*sr}const e=a.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),r=t(450160.398036-e*69628905431e-4);let o=Math.sin(r),c=Math.cos(r),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+r);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*(n+r),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*r,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(i),c=Math.cos(i),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 Kg(a){var t=a.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var yc;function Lo(a){if(!yc||Math.abs(yc.tt-a.tt)>1e-6){const t=R5(a),e=Kg(a),i=e+t.deps/3600;yc={tt:a.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ye)/15,mobl:e,tobl:i}}return yc}function D5(a,t){const e=a*ye,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function C5(a,t){return D5(Kg(a),t)}function I5(a){const t=a.tt/36525;function e(Ct,yt){const Ft=[];let kt;for(kt=0;kt<=yt-Ct;++kt)Ft.push(0);return{min:Ct,array:Ft}}function i(Ct,yt,Ft,kt){const zt=[];for(let fe=0;fe<=yt-Ct;++fe)zt.push(e(Ft,kt));return{min:Ct,array:zt}}function n(Ct,yt,Ft){const kt=Ct.array[yt-Ct.min];return kt.array[Ft-kt.min]}function s(Ct,yt,Ft,kt){const zt=Ct.array[yt-Ct.min];zt.array[Ft-zt.min]=kt}let r,o,c,l,h,u,d,f,p,v,m,g,_,w,M,S,b,T,x,A,I,C,P,X=i(-6,6,1,4),z=i(-6,6,1,4);function N(Ct,yt){return n(X,Ct,yt)}function V(Ct,yt){return n(z,Ct,yt)}function k(Ct,yt,Ft){return s(X,Ct,yt,Ft)}function K(Ct,yt,Ft){return s(z,Ct,yt,Ft)}function tt(Ct,yt,Ft,kt,zt){zt(Ct*Ft-yt*kt,yt*Ft+Ct*kt)}function J(Ct){return Math.sin(cs*Ct)}d=t*t,p=0,P=0,m=0,g=3422.7;var it=J(.19833+.05611*t),ot=J(.27869+.04508*t),Vt=J(.16827-.36903*t),Qt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),Y=J(.42681-.41855*t),rt=J(.14943-5.37511*t);for(T=.84*it+.31*ot+14.27*Vt+7.26*Qt+.28*qt+.24*Y,x=2.94*it+.31*ot+14.27*Vt+9.34*Qt+1.12*qt+.83*Y,A=-6.4*it-1.89*Y,I=.21*it+.31*ot+14.27*Vt-88.7*Qt-15.3*qt+.24*Y-1.86*rt,C=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),_=cs*Za(.60643382+1336.85522467*t-313e-8*d)+T/Ns,w=cs*Za(.37489701+1325.55240982*t+2565e-8*d)+x/Ns,M=cs*Za(.99312619+99.99735956*t-44e-8*d)+A/Ns,S=cs*Za(.25909118+1342.2278298*t-892e-8*d)+I/Ns,b=cs*Za(.82736186+1236.85308708*t-397e-8*d)+C/Ns,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),K(0,h,0),K(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(N(u-1,h),V(u-1,h),N(1,h),V(1,h),(Ct,yt)=>(k(u,h,Ct),K(u,h,yt)));for(u=1;u<=o;++u)k(-u,h,N(u,h)),K(-u,h,-V(u,h))}function nt(Ct,yt,Ft,kt){for(var zt={x:1,y:0},fe=[0,Ct,yt,Ft,kt],pe=1;pe<=4;++pe)fe[pe]!==0&&tt(zt.x,zt.y,N(fe[pe],pe),V(fe[pe],pe),(He,Le)=>(zt.x=He,zt.y=Le));return zt}function B(Ct,yt,Ft,kt,zt,fe,pe,He){var Le=nt(zt,fe,pe,He);p+=Ct*Le.y,P+=yt*Le.y,m+=Ft*Le.x,g+=kt*Le.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 At(Ct,yt,Ft,kt,zt){return Ct*nt(yt,Ft,kt,zt).y}v=0,v+=At(-526.069,0,0,1,-2),v+=At(-3.352,0,0,1,-4),v+=At(44.297,1,0,1,-2),v+=At(-6,1,0,1,-4),v+=At(20.599,-1,0,1,0),v+=At(-30.598,-1,0,1,-2),v+=At(-24.649,-2,0,1,0),v+=At(-2,-2,0,1,-2),v+=At(-22.571,0,1,1,-2),v+=At(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),r=S+P/Ns;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:cs*Za((_+p/Ns)/cs),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Ns*_5/(.999953253*g)}}function $g(a,t){return[a.rot[0][0]*t[0]+a.rot[1][0]*t[1]+a.rot[2][0]*t[2],a.rot[0][1]*t[0]+a.rot[1][1]*t[1]+a.rot[2][1]*t[2],a.rot[0][2]*t[0]+a.rot[1][2]*t[1]+a.rot[2][2]*t[2]]}function gl(a,t,e){const i=l0(t,e);return $g(i,a)}function l0(a,t){const e=a.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,r=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=sr,n*=sr,s*=sr,r*=sr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(r),p=Math.cos(r),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,_=-f*h-l*p*d,w=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,S=l*u,b=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Si.Into2000)return new $s([[v,m,g],[_,w,M],[S,b,T]]);if(t===Si.From2000)return new $s([[v,_,S],[m,w,b],[g,M,T]]);throw"Invalid precess direction"}function P5(a){const t=.779057273264+.00273781191135448*a.ut,e=a.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let _c;function Pl(a){if(!_c||_c.tt!==a.tt){const t=a.tt/36525;let e=15*Lo(a).ee;const i=P5(a);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),_c={tt:a.tt,st:s}}return _c.st}function L5(a){const t=Be(a);return Pl(t)}function Zg(a,t){const e=a.latitude*ye,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,od*i),r=y5*s,o=a.height/1e3,c=cd*s+o,l=cd*r+o,h=(15*t+a.longitude)*ye,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/ua,c*n*u/ua,l*i/ua],vel:[-Ep*c*n*u*86400/ua,Ep*c*n*d*86400/ua,0]}}function fd(a,t,e){const i=h0(t,e);return $g(i,a)}function h0(a,t){const e=Lo(a),i=e.mobl*ye,n=e.tobl*ye,s=e.dpsi*sr,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*r,p=-u*o,v=u*c,m=h*r*c+o*l,g=h*o*c-r*l,_=u*l,w=h*r*l-o*c,M=h*o*l+r*c;if(t===Si.From2000)return new $s([[d,v,_],[f,m,w],[p,g,M]]);if(t===Si.Into2000)return new $s([[d,f,p],[v,m,g],[_,w,M]]);throw"Invalid precess direction"}function u0(a,t,e){return e===Si.Into2000?gl(fd(a,t,e),t,e):fd(gl(a,t,e),t,e)}function N5(a,t){const e=Pl(a),i=Zg(t,e).pos;return u0(i,a,Si.Into2000)}class Ce{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Vs{constructor(t,e,i,n,s,r,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=r,this.t=o}}class Ll{constructor(t,e,i){this.lat=Mi(t),this.lon=Mi(e),this.dist=Mi(i)}}class pd{constructor(t,e,i,n){this.ra=Mi(t),this.dec=Mi(e),this.dist=Mi(i),this.vec=n}}class $s{constructor(t){this.rot=t}}class O5{constructor(t,e,i,n){this.azimuth=Mi(t),this.altitude=Mi(e),this.ra=Mi(i),this.dec=Mi(n)}}class U5{constructor(t,e,i){this.vec=t,this.elat=Mi(e),this.elon=Mi(i)}}function Jg(a,t){return new Ce(a[0],a[1],a[2],t)}function F5(a,t){const e=Jg(a,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new pd(0,e.z<0?-90:90,n,e)}let s=Xg*Math.atan2(e.y,e.x);s<0&&(s+=24);const r=ts*Math.atan2(a[2],Math.sqrt(i));return new pd(s,r,n,e)}function Dh(a,t){const e=a*ye,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function jg(a,t,e,i,n){let s=Be(a);d0(t),Mi(e),Mi(i);const r=Math.sin(t.latitude*ye),o=Math.cos(t.latitude*ye),c=Math.sin(t.longitude*ye),l=Math.cos(t.longitude*ye),h=Math.sin(i*ye),u=Math.cos(i*ye),d=Math.sin(e*wp),f=Math.cos(e*wp);let p=[o*l,o*c,r],v=[-r*l,-r*c,o],m=[c,-l,0];const g=-15*Pl(s);let _=Dh(g,p),w=Dh(g,v),M=Dh(g,m),S=[u*f,u*d,h];const b=S[0]*_[0]+S[1]*_[1]+S[2]*_[2],T=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],x=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(T,x),I;A>0?(I=-ts*Math.atan2(x,T),I<0&&(I+=360)):I=0;let C=ts*Math.atan2(A,b),P=e,X=i;if(n){let z=C,N=o1(n,90-C);if(C-=N,N>0&&C>3e-4){const V=Math.sin(C*ye),k=Math.cos(C*ye),K=Math.sin(z*ye),tt=Math.cos(z*ye),J=[];for(let it=0;it<3;++it)J.push((S[it]-tt*_[it])/K*V+_[it]*k);A=Math.hypot(J[0],J[1]),A>0?(P=Xg*Math.atan2(J[1],J[0]),P<0&&(P+=24)):P=0,X=ts*Math.atan2(J[2],A)}}return new O5(I,90-C,P,X)}function d0(a){if(!(a instanceof f0))throw`Not an instance of the Observer class: ${a}`;if(Mi(a.latitude),Mi(a.longitude),Mi(a.height),a.latitude<-90||a.latitude>90)throw`Latitude ${a.latitude} is out of range. Must be -90..+90.`;return a}class f0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,d0(this)}}function k5(a){const t=Be(a).AddDays(-1/r0),e=vr(Jn.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,r]=u0(i,t,Si.From2000),o=ye*Lo(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Ce(n,s,r,t);return Qg(h,c,l)}function z5(a,t,e,i,n){d0(e),ml(i),ml(n);const s=Be(t),r=N5(s,e),o=bd(a,s,n),c=[o.x-r[0],o.y-r[1],o.z-r[2]],l=u0(c,s,Si.From2000);return F5(l,s)}function B5(a,t,e){const i=Be(a),n=Pl(i);let s=Zg(t,n).pos;return Jg(s,i)}function Qg(a,t,e){const i=a.x,n=a.y*t+a.z*e,s=-a.y*e+a.z*t,r=Math.hypot(i,n);let o=0;r>0&&(o=ts*Math.atan2(n,i),o<0&&(o+=360));let c=ts*Math.atan2(s,r),l=new Ce(i,n,s,a.t);return new U5(l,c,o)}function md(a){const t=Lo(a.t),e=[a.x,a.y,a.z],i=gl(e,a.t,Si.From2000),[n,s,r]=fd(i,a.t,Si.From2000),o=new Ce(n,s,r,a.t),c=t.tobl*ye;return Qg(o,Math.cos(c),Math.sin(c))}function wr(a){const t=Be(a),e=I5(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=C5(t,n),r=gl(s,t,Si.Into2000);return new Ce(r[0],r[1],r[2],t)}function t1(a){const t=Be(a),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=wr(i),r=wr(n);return new Vs((s.x+r.x)/2,(s.y+r.y)/2,(s.z+r.z)/2,(r.x-s.x)/(2*e),(r.y-s.y)/(2*e),(r.z-s.z)/(2*e),t)}function H5(a){const t=Be(a),e=t1(t),i=1+Yg;return new Vs(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function gr(a,t,e){let i=1,n=0;for(let s of a){let r=0;for(let[c,l,h]of s)r+=c*Math.cos(l+t*h);let o=i*r;e&&(o%=cs),n+=o,i*=t}return n}function Ch(a,t){let e=1,i=0,n=0,s=0;for(let r of a){let o=0,c=0;for(let[l,h,u]of r){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const io=365250,gd=0,vd=1,Md=2;function xd(a){return new Ri(a[0]+44036e-11*a[1]-190919e-12*a[2],-479966e-12*a[0]+.917482137087*a[1]-.397776982902*a[2],.397776982902*a[1]+.917482137087*a[2])}function e1(a,t,e){const i=e*Math.cos(t),n=Math.cos(a),s=Math.sin(a);return[i*n,i*s,e*Math.sin(t)]}function vr(a,t){const e=t.tt/io,i=gr(a[gd],e,!0),n=gr(a[vd],e,!1),s=gr(a[Md],e,!1),r=e1(i,n,s);return xd(r).ToAstroVector(t)}function yd(a,t){const e=t/io,i=gr(a[gd],e,!0),n=gr(a[vd],e,!1),s=gr(a[Md],e,!1),r=Ch(a[gd],e),o=Ch(a[vd],e),c=Ch(a[Md],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*r,p=+(c*u*h)-s*d*h*o+s*u*l*r,v=+(c*d)+s*u*o,m=e1(i,n,s),g=[f/io,p/io,v/io],_=xd(m),w=xd(g);return new ba(t,_,w)}function Sc(a,t,e,i){const n=i/(i+o0),s=vr(Jn[e],t);a.x+=n*s.x,a.y+=n*s.y,a.z+=n*s.z}function G5(a){const t=new Ce(0,0,0,a);return Sc(t,a,wt.Jupiter,ld),Sc(t,a,wt.Saturn,hd),Sc(t,a,wt.Uranus,ud),Sc(t,a,wt.Neptune,dd),t}const _d=51,V5=29200,ar=146,ls=201,va=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Ri{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Ri(this.x,this.y,this.z)}ToAstroVector(t){return new Ce(this.x,this.y,this.z,t)}static zero(){return new Ri(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Ri(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Ri(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 Ri(t*this.x,t*this.y,t*this.z)}div(t){return new Ri(this.x/t,this.y/t,this.z/t)}mean(t){return new Ri((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Ri(-this.x,-this.y,-this.z)}}class ba{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new ba(this.tt,this.r,this.v)}sub(t){return new ba(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function W5(a){let[t,[e,i,n],[s,r,o]]=a;return new ba(t,new Ri(e,i,n),new Ri(s,r,o))}function wc(a,t,e,i){const n=i/(i+o0),s=yd(Jn[e],t);return a.r.incr(s.r.mul(n)),a.v.incr(s.v.mul(n)),s}function Xr(a,t,e){const i=e.sub(a),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Nl{constructor(t){let e=new ba(t,new Ri(0,0,0),new Ri(0,0,0));this.Jupiter=wc(e,t,wt.Jupiter,ld),this.Saturn=wc(e,t,wt.Saturn,hd),this.Uranus=wc(e,t,wt.Uranus,ud),this.Neptune=wc(e,t,wt.Neptune,dd),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 ba(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=Xr(t,o0,this.Sun.r);return e.incr(Xr(t,ld,this.Jupiter.r)),e.incr(Xr(t,hd,this.Saturn.r)),e.incr(Xr(t,ud,this.Uranus.r)),e.incr(Xr(t,dd,this.Neptune.r)),e}}class Ol{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new Ol(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class i1{constructor(t,e){this.bary=t,this.grav=e}}function vl(a,t,e,i){return new Ri(t.x+a*(e.x+a*i.x/2),t.y+a*(e.y+a*i.y/2),t.z+a*(e.z+a*i.z/2))}function Tp(a,t,e){return new Ri(t.x+a*e.x,t.y+a*e.y,t.z+a*e.z)}function Sd(a,t){const e=a-t.tt,i=new Nl(a),n=vl(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),r=vl(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(r),l=new Ol(a,r,o,c);return new i1(i,l)}const X5=[];function n1(a,t){const e=Math.floor(a);return e<0?0:e>=t?t-1:e}function wd(a){const t=W5(a),e=new Nl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),r=new Ol(t.tt,i,n,s);return new i1(e,r)}function q5(a,t){const e=va[0][0];if(t<e||t>va[_d-1][0])return null;const i=n1((t-e)/V5,_d-1);if(!a[i]){const s=a[i]=[];s[0]=wd(va[i]).grav,s[ls-1]=wd(va[i+1]).grav;let r,o=s[0].tt;for(r=1;r<ls-1;++r)s[r]=Sd(o+=ar,s[r-1]).grav;o=s[ls-1].tt;var n=[];for(n[ls-1]=s[ls-1],r=ls-2;r>0;--r)n[r]=Sd(o-=ar,n[r+1]).grav;for(r=ls-2;r>0;--r){const c=r/(ls-1);s[r].r=s[r].r.mul(1-c).add(n[r].r.mul(c)),s[r].v=s[r].v.mul(1-c).add(n[r].v.mul(c)),s[r].a=s[r].a.mul(1-c).add(n[r].a.mul(c))}}return a[i]}function Rp(a,t,e){let i=wd(a);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Sd(s+1===n?t:i.grav.tt+e,i.grav);return i}function s1(a,t){let e,i,n;const s=q5(X5,a.tt);if(s){const r=n1((a.tt-s[0].tt)/ar,ls-1),o=s[r],c=s[r+1],l=o.a.mean(c.a),h=vl(a.tt-o.tt,o.r,o.v,l),u=Tp(a.tt-o.tt,o.v,l),d=vl(a.tt-c.tt,c.r,c.v,l),f=Tp(a.tt-c.tt,c.v,l),p=(a.tt-o.tt)/ar;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let r;a.tt<va[0][0]?r=Rp(va[0],a.tt,-ar):r=Rp(va[_d-1],a.tt,+ar),e=r.grav.r,i=r.grav.v,n=r.bary}return n||(n=new Nl(a.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new Vs(e.x,e.y,e.z,i.x,i.y,i.z,a)}function qs(a,t){var e=Be(t);if(a in Jn)return vr(Jn[a],e);if(a===wt.Pluto){const r=s1(e);return new Ce(r.x,r.y,r.z,e)}if(a===wt.Sun)return new Ce(0,0,0,e);if(a===wt.Moon){var i=vr(Jn.Earth,e),n=wr(e);return new Ce(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(a===wt.EMB){const r=vr(Jn.Earth,e),o=wr(e),c=1+Yg;return new Ce(r.x+o.x/c,r.y+o.y/c,r.z+o.z/c,e)}if(a===wt.SSB)return G5(e);const s=c0(a);if(s){const r=new Ll(s.dec,15*s.ra,s.dist);return p0(r,e)}throw`HelioVector: Unknown body "${a}"`}function Y5(a,t){let e=t,i=0;for(let n=0;n<10;++n){const s=a(e),r=s.Length()/r0;if(r>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-r);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class K5{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=qs(this.observerBody,t));const e=qs(this.targetBody,t);return new Ce(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function $5(a,t,e,i){ml(i);const n=Be(a);if(c0(e)){const o=qs(e,n);if(i){const l=J5(t,n),h=new Ce(o.x-l.x,o.y-l.y,o.z-l.z,n),u=r0/h.Length();return new Ce(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=qs(t,n);return new Ce(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Ce(0,0,0,n):s=qs(t,n);const r=new K5(t,e,i,s);return Y5(o=>r.Position(o),n)}function bd(a,t,e){ml(e);const i=Be(t);switch(a){case wt.Earth:return new Ce(0,0,0,i);case wt.Moon:return wr(i);default:const n=$5(i,wt.Earth,a,e);return n.t=i,n}}function Z5(a,t){return new Vs(a.r.x,a.r.y,a.r.z,a.v.x,a.v.y,a.v.z,t)}function J5(a,t){const e=Be(t);switch(a){case wt.Sun:return new Vs(0,0,0,0,0,0,e);case wt.SSB:const i=new Nl(e.tt);return new Vs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=yd(Jn[a],e.tt);return Z5(n,e);case wt.Pluto:return s1(e);case wt.Moon:case wt.EMB:const s=yd(Jn.Earth,e.tt),r=a==wt.Moon?t1(e):H5(e);return new Vs(r.x+s.r.x,r.y+s.r.y,r.z+s.r.z,r.vx+s.v.x,r.vy+s.v.y,r.vz+s.v.z,e);default:if(c0(a)){const o=qs(a,e);return new Vs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${a}"`}}function j5(a){for(;a<0;)a+=360;for(;a>=360;)a-=360;return a}function Q5(a,t,e){if(a===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Be(e),n=bd(a,i,!1),s=md(n),r=bd(t,i,!1),o=md(r);return j5(s.elon-o.elon)}function tw(a,t,e,i){let n,s=0,r=0,o=0;switch(a){case wt.Mercury:n=-.6,s=4.98,r=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,r=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${a}`}const c=t/100;let l=n+c*(s+c*(r+c*o));return l+=5*Math.log10(e*i),l}function ew(a,t,e,i,n){const s=md(i),r=ye*28.06,o=ye*(169.51+382e-7*n.tt),c=ye*s.elat,l=ye*s.elon,h=Math.asin(Math.sin(c)*Math.cos(r)-Math.cos(c)*Math.sin(r)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*a;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:ts*h}}function iw(a,t,e){let i=a*ye,n=i*i,s=n*n,r=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/ua;let c=e/o;return r+=5*Math.log10(t*c),r}class nw{constructor(t,e,i,n,s,r,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=r,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ye*i))/2}}function a1(a,t){if(a===wt.Earth)throw"The illumination of the Earth is not defined.";const e=Be(t),i=vr(Jn.Earth,e);let n,s,r,o;a===wt.Sun?(r=new Ce(-i.x,-i.y,-i.z,e),s=new Ce(0,0,0,e),n=0):(a===wt.Moon?(r=wr(e),s=new Ce(i.x+r.x,i.y+r.y,i.z+r.z,e)):(s=qs(a,t),r=new Ce(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=S5(r,s));let c=r.Length(),l=s.Length(),h;if(a===wt.Sun)o=x5+5*Math.log10(c);else if(a===wt.Moon)o=iw(n,l,c);else if(a===wt.Saturn){const u=ew(n,l,c,r,e);o=u.mag,h=u.ring_tilt}else o=tw(a,n,l,c);return new nw(e,o,n,l,c,r,s,h)}function sw(a){return Q5(wt.Moon,wt.Sun,a)}var Dp;(function(a){a[a.Pericenter=0]="Pericenter",a[a.Apocenter=1]="Apocenter"})(Dp||(Dp={}));function r1(a,t){return new $s([[t.rot[0][0]*a.rot[0][0]+t.rot[1][0]*a.rot[0][1]+t.rot[2][0]*a.rot[0][2],t.rot[0][1]*a.rot[0][0]+t.rot[1][1]*a.rot[0][1]+t.rot[2][1]*a.rot[0][2],t.rot[0][2]*a.rot[0][0]+t.rot[1][2]*a.rot[0][1]+t.rot[2][2]*a.rot[0][2]],[t.rot[0][0]*a.rot[1][0]+t.rot[1][0]*a.rot[1][1]+t.rot[2][0]*a.rot[1][2],t.rot[0][1]*a.rot[1][0]+t.rot[1][1]*a.rot[1][1]+t.rot[2][1]*a.rot[1][2],t.rot[0][2]*a.rot[1][0]+t.rot[1][2]*a.rot[1][1]+t.rot[2][2]*a.rot[1][2]],[t.rot[0][0]*a.rot[2][0]+t.rot[1][0]*a.rot[2][1]+t.rot[2][0]*a.rot[2][2],t.rot[0][1]*a.rot[2][0]+t.rot[1][1]*a.rot[2][1]+t.rot[2][1]*a.rot[2][2],t.rot[0][2]*a.rot[2][0]+t.rot[1][2]*a.rot[2][1]+t.rot[2][2]*a.rot[2][2]]])}function p0(a,t){t=Be(t);const e=a.lat*ye,i=a.lon*ye,n=a.dist*Math.cos(e);return new Ce(n*Math.cos(i),n*Math.sin(i),a.dist*Math.sin(e),t)}function m0(a){const t=aw(a);return new pd(t.lon/15,t.lat,t.dist,a)}function aw(a){const t=a.x*a.x+a.y*a.y,e=Math.sqrt(t+a.z*a.z);let i,n;if(t===0){if(a.z===0)throw"Zero-length vector not allowed.";n=0,i=a.z<0?-90:90}else n=ts*Math.atan2(a.y,a.x),n<0&&(n+=360),i=ts*Math.atan2(a.z,Math.sqrt(t));return new Ll(i,n,e)}function o1(a,t){let e;if(Mi(t),t<-90||t>90)return 0;if(a==="normal"||a==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*ye)/60,a==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!a)e=0;else throw`Invalid refraction option: ${a}`;return e}function Mr(a,t){return new Ce(a.rot[0][0]*t.x+a.rot[1][0]*t.y+a.rot[2][0]*t.z,a.rot[0][1]*t.x+a.rot[1][1]*t.y+a.rot[2][1]*t.z,a.rot[0][2]*t.x+a.rot[1][2]*t.y+a.rot[2][2]*t.z,t.t)}function rw(){return new $s([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function ow(){return new $s([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function c1(a){a=Be(a);const t=l0(a,Si.From2000),e=h0(a,Si.From2000);return r1(t,e)}function cw(a){a=Be(a);const t=h0(a,Si.Into2000),e=l0(a,Si.Into2000);return r1(t,e)}function lw(a){const e=Lo(Be(a)).tobl*ye,i=Math.cos(e),n=Math.sin(e);return new $s([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Cp;(function(a){a.Penumbral="penumbral",a.Partial="partial",a.Annular="annular",a.Total="total"})(Cp||(Cp={}));var Ip;(function(a){a[a.Invalid=0]="Invalid",a[a.Ascending=1]="Ascending",a[a.Descending=-1]="Descending"})(Ip||(Ip={}));const hw=["Venus","Mars","Jupiter","Saturn"];function l1(a){return new f0(a.lat,a.lng,a.elevationM)}function g0(a,t,e,i,n=!0){const s=jg(e,l1(i),a,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class An{up;north;west;constructor(t,e){const i=Be(t),n=Math.sin(e.lat*hs),s=Math.cos(e.lat*hs),r=Math.sin(e.lng*hs),o=Math.cos(e.lng*hs),c=-15*L5(i),l=cw(i);this.up=An.rotate(l,An.spin(c,[s*o,s*r,n]),i),this.north=An.rotate(l,An.spin(c,[-n*o,-n*r,s]),i),this.west=An.rotate(l,An.spin(c,[r,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const r=Be(i),o=p0(new Ll(e,t*15,1),r),c=m0(Mr(c1(r),o));return g0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*hs),n=Math.cos(e*hs),s=Math.sin(t*Lp),r=Math.cos(t*Lp),o=n*r,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Pp*Math.atan2(d,u),p<0&&(p+=360));let v=Pp*Math.atan2(f,h);return v-=o1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*hs),r=Math.sin(t*hs);return[s*e+r*i,s*i-r*e,n]}static rotate(t,[e,i,n],s){const r=Mr(t,new Ce(e,i,n,s));return[r.x,r.y,r.z]}}const hs=Math.PI/180,Pp=180/Math.PI,Lp=15*hs;function Ih(a,t,e){const i=l1(e),n=z5(wt[a],t,i,!0,!0),s=jg(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Ph(a,t){return a1(wt[a],t).mag}function uw(a){const t=sw(a),e=a1(wt.Moon,a);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const dw=2e3,fw=3,pw=20;function bc(a,t,e){if(a.year===void 0&&a.month===void 0&&a.day===void 0&&a.hour===void 0)return;const i=a.year!==void 0,n=a.year??dw,s=a.month??(i?1:fw),r=a.day??(i?1:pw),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,r,(a.hour??12)-o,a.minute??0,a.second??0))}class Vn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Vn.CORE,rim:Vn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Vn.patch(e.fragmentShader)}}static patch(t){return t.replace(Vn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5497
|
+
*/const r0=173.1446326846693,ua=14959787069098932e-8,ye=.017453292519943295,wp=.26179938779914946,ts=57.29577951308232,Xg=3.819718634205488,g5=365.24217,bp=new Date("2000-01-01T12:00:00Z"),cs=2*Math.PI,Ns=3600*(180/Math.PI),sr=484813681109536e-20,qg=10800*60,v5=2*qg,Ep=7292115e-11,M5=qg/Math.PI,x5=-.17-5*Math.log10(M5),od=.996647180302104,y5=od*od,cd=6378.1366,_5=cd/ua,Yg=81.30056,o0=.0002959122082855911,ld=2825345909524226e-22,hd=8459715185680659e-23,ud=1292024916781969e-23,dd=1524358900784276e-23;function ml(a){if(a!==!0&&a!==!1)throw console.trace(),`Value is not boolean: ${a}`;return a}function Mi(a){if(!Number.isFinite(a))throw console.trace(),`Value is not a finite number: ${a}`;return a}function Za(a){return a-Math.floor(a)}function S5(a,t){const e=a.x*a.x+a.y*a.y+a.z*a.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const i=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(i)<1e-8)throw"AngleBetween: second vector is too short.";const n=(a.x*t.x+a.y*t.y+a.z*t.z)/Math.sqrt(e*i);return n<=-1?180:n>=1?0:ts*Math.acos(n)}var wt;(function(a){a.Sun="Sun",a.Moon="Moon",a.Mercury="Mercury",a.Venus="Venus",a.Earth="Earth",a.Mars="Mars",a.Jupiter="Jupiter",a.Saturn="Saturn",a.Uranus="Uranus",a.Neptune="Neptune",a.Pluto="Pluto",a.SSB="SSB",a.EMB="EMB",a.Star1="Star1",a.Star2="Star2",a.Star3="Star3",a.Star4="Star4",a.Star5="Star5",a.Star6="Star6",a.Star7="Star7",a.Star8="Star8"})(wt||(wt={}));const w5=[wt.Star1,wt.Star2,wt.Star3,wt.Star4,wt.Star5,wt.Star6,wt.Star7,wt.Star8],b5=[{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 E5(a){const t=w5.indexOf(a);return t>=0?b5[t]:null}function c0(a){const t=E5(a);return t&&t.dist>0?t:null}var Si;(function(a){a[a.From2000=0]="From2000",a[a.Into2000=1]="Into2000"})(Si||(Si={}));const Jn={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 A5(a){var t,e,i,n,s,r,o;const c=2e3+(a-14)/g5;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,10583.6-1014.41*t+33.78311*e-5.952053*i-.1798452*n+.022174192*s+.0090316521*r):c<1600?(t=(c-1e3)/100,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,1574.2-556.01*t+71.23472*e+.319781*i-.8503463*n-.005050998*s+.0083572073*r):c<1700?(t=c-1600,e=t*t,i=t*e,120-.9808*t-.01532*e+i/7129):c<1800?(t=c-1700,e=t*t,i=t*e,n=e*e,8.83+.1603*t-.0059285*e+13336e-8*i-n/1174e3):c<1860?(t=c-1800,e=t*t,i=t*e,n=e*e,s=e*i,r=i*i,o=i*n,13.72-.332447*t+.0068612*e+.0041116*i-37436e-8*n+121272e-10*s-1699e-10*r+875e-12*o):c<1900?(t=c-1860,e=t*t,i=t*e,n=e*e,s=e*i,7.62+.5737*t-.251754*e+.01680668*i-.0004473624*n+s/233174):c<1920?(t=c-1900,e=t*t,i=t*e,n=e*e,-2.79+1.494119*t-.0598939*e+.0061966*i-197e-6*n):c<1941?(t=c-1920,e=t*t,i=t*e,21.2+.84493*t-.0761*e+.0020936*i):c<1961?(t=c-1950,e=t*t,i=t*e,29.07+.407*t-e/233+i/2547):c<1986?(t=c-1975,e=t*t,i=t*e,45.45+1.067*t-e/260-i/718):c<2005?(t=c-2e3,e=t*t,i=t*e,n=e*e,s=e*i,63.86+.3345*t-.060374*e+.0017275*i+651814e-9*n+2373599e-11*s):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 T5=A5;function Ap(a){return a+T5(a)/86400}class mr{constructor(t){if(t instanceof mr){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()-bp.getTime())/e,this.tt=Ap(this.ut);return}if(Number.isFinite(t)){this.date=new Date(bp.getTime()+t*e),this.ut=t,this.tt=Ap(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 mr(t);for(;;){const i=t-e.tt;if(Math.abs(i)<1e-12)return e;e=e.AddDays(i)}}toString(){return this.date.toISOString()}AddDays(t){return new mr(this.ut+t)}}function Be(a){return a instanceof mr?a:new mr(a)}function R5(a){function t(d){return d%v5*sr}const e=a.tt/36525,i=t(128710479305e-5+e*1295965810481e-4),n=t(335779.526232+e*17395272628478e-4),s=t(107226070369e-5+e*1602961601209e-3),r=t(450160.398036-e*69628905431e-4);let o=Math.sin(r),c=Math.cos(r),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(n-s+r);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*(n+r),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*r,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(i),c=Math.cos(i),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 Kg(a){var t=a.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var yc;function Lo(a){if(!yc||Math.abs(yc.tt-a.tt)>1e-6){const t=R5(a),e=Kg(a),i=e+t.deps/3600;yc={tt:a.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ye)/15,mobl:e,tobl:i}}return yc}function D5(a,t){const e=a*ye,i=Math.cos(e),n=Math.sin(e);return[t[0],t[1]*i-t[2]*n,t[1]*n+t[2]*i]}function C5(a,t){return D5(Kg(a),t)}function I5(a){const t=a.tt/36525;function e(Ct,yt){const Ft=[];let kt;for(kt=0;kt<=yt-Ct;++kt)Ft.push(0);return{min:Ct,array:Ft}}function i(Ct,yt,Ft,kt){const zt=[];for(let fe=0;fe<=yt-Ct;++fe)zt.push(e(Ft,kt));return{min:Ct,array:zt}}function n(Ct,yt,Ft){const kt=Ct.array[yt-Ct.min];return kt.array[Ft-kt.min]}function s(Ct,yt,Ft,kt){const zt=Ct.array[yt-Ct.min];zt.array[Ft-zt.min]=kt}let r,o,c,l,h,u,d,f,p,v,m,g,_,w,M,S,b,T,x,A,I,C,L,W=i(-6,6,1,4),X=i(-6,6,1,4);function P(Ct,yt){return n(W,Ct,yt)}function B(Ct,yt){return n(X,Ct,yt)}function k(Ct,yt,Ft){return s(W,Ct,yt,Ft)}function K(Ct,yt,Ft){return s(X,Ct,yt,Ft)}function tt(Ct,yt,Ft,kt,zt){zt(Ct*Ft-yt*kt,yt*Ft+Ct*kt)}function J(Ct){return Math.sin(cs*Ct)}d=t*t,p=0,L=0,m=0,g=3422.7;var it=J(.19833+.05611*t),rt=J(.27869+.04508*t),Gt=J(.16827-.36903*t),Jt=J(.34734-5.37261*t),qt=J(.10498-5.37899*t),Y=J(.42681-.41855*t),at=J(.14943-5.37511*t);for(T=.84*it+.31*rt+14.27*Gt+7.26*Jt+.28*qt+.24*Y,x=2.94*it+.31*rt+14.27*Gt+9.34*Jt+1.12*qt+.83*Y,A=-6.4*it-1.89*Y,I=.21*it+.31*rt+14.27*Gt-88.7*Jt-15.3*qt+.24*Y-1.86*at,C=T-A,f=-3332e-9*J(.59734-5.37261*t)-539e-9*J(.35498-5.37899*t)-64e-9*J(.39943-5.37511*t),_=cs*Za(.60643382+1336.85522467*t-313e-8*d)+T/Ns,w=cs*Za(.37489701+1325.55240982*t+2565e-8*d)+x/Ns,M=cs*Za(.99312619+99.99735956*t-44e-8*d)+A/Ns,S=cs*Za(.25909118+1342.2278298*t-892e-8*d)+I/Ns,b=cs*Za(.82736186+1236.85308708*t-397e-8*d)+C/Ns,h=1;h<=4;++h){switch(h){case 1:c=w,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(k(0,h,1),k(1,h,Math.cos(c)*l),K(0,h,0),K(1,h,Math.sin(c)*l),u=2;u<=o;++u)tt(P(u-1,h),B(u-1,h),P(1,h),B(1,h),(Ct,yt)=>(k(u,h,Ct),K(u,h,yt)));for(u=1;u<=o;++u)k(-u,h,P(u,h)),K(-u,h,-B(u,h))}function nt(Ct,yt,Ft,kt){for(var zt={x:1,y:0},fe=[0,Ct,yt,Ft,kt],pe=1;pe<=4;++pe)fe[pe]!==0&&tt(zt.x,zt.y,P(fe[pe],pe),B(fe[pe],pe),(He,Le)=>(zt.x=He,zt.y=Le));return zt}function z(Ct,yt,Ft,kt,zt,fe,pe,He){var Le=nt(zt,fe,pe,He);p+=Ct*Le.y,L+=yt*Le.y,m+=Ft*Le.x,g+=kt*Le.x}z(13.902,14.06,-.001,.2607,0,0,0,4),z(.403,-4.01,.394,.0023,0,0,0,3),z(2369.912,2373.36,.601,28.2333,0,0,0,2),z(-125.154,-112.79,-.725,-.9781,0,0,0,1),z(1.979,6.98,-.445,.0433,1,0,0,4),z(191.953,192.72,.029,3.0861,1,0,0,2),z(-8.466,-13.51,.455,-.1093,1,0,0,1),z(22639.5,22609.07,.079,186.5398,1,0,0,0),z(18.609,3.59,-.094,.0118,1,0,0,-1),z(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),z(3.215,5.44,.192,-.0386,1,0,0,-3),z(-38.428,-38.64,.001,.6008,1,0,0,-4),z(-.393,-1.43,-.092,.0086,1,0,0,-6),z(-.289,-1.59,.123,-.0053,0,1,0,4),z(-24.42,-25.1,.04,-.3,0,1,0,2),z(18.023,17.93,.007,.1494,0,1,0,1),z(-668.146,-126.98,-1.302,-.3997,0,1,0,0),z(.56,.32,-.001,-.0037,0,1,0,-1),z(-165.145,-165.06,.054,1.9178,0,1,0,-2),z(-1.877,-6.46,-.416,.0339,0,1,0,-4),z(.213,1.02,-.074,.0054,2,0,0,4),z(14.387,14.78,-.017,.2833,2,0,0,2),z(-.586,-1.2,.054,-.01,2,0,0,1),z(769.016,767.96,.107,10.1657,2,0,0,0),z(1.75,2.01,-.018,.0155,2,0,0,-1),z(-211.656,-152.53,5.679,-.3039,2,0,0,-2),z(1.225,.91,-.03,-.0088,2,0,0,-3),z(-30.773,-34.07,-.308,.3722,2,0,0,-4),z(-.57,-1.4,-.074,.0109,2,0,0,-6),z(-2.921,-11.75,.787,-.0484,1,1,0,2),z(1.267,1.52,-.022,.0164,1,1,0,1),z(-109.673,-115.18,.461,-.949,1,1,0,0),z(-205.962,-182.36,2.056,1.4437,1,1,0,-2),z(.233,.36,.012,-.0025,1,1,0,-3),z(-4.391,-9.66,-.471,.0673,1,1,0,-4),z(.283,1.53,-.111,.006,1,-1,0,4),z(14.577,31.7,-1.54,.2302,1,-1,0,2),z(147.687,138.76,.679,1.1528,1,-1,0,0),z(-1.089,.55,.021,0,1,-1,0,-1),z(28.475,23.59,-.443,-.2257,1,-1,0,-2),z(-.276,-.38,-.006,-.0036,1,-1,0,-3),z(.636,2.27,.146,-.0102,1,-1,0,-4),z(-.189,-1.68,.131,-.0028,0,2,0,2),z(-7.486,-.66,-.037,-.0086,0,2,0,0),z(-8.096,-16.35,-.74,.0918,0,2,0,-2),z(-5.741,-.04,0,-9e-4,0,0,2,2),z(.255,0,0,0,0,0,2,1),z(-411.608,-.2,0,-.0124,0,0,2,0),z(.584,.84,0,.0071,0,0,2,-1),z(-55.173,-52.14,0,-.1052,0,0,2,-2),z(.254,.25,0,-.0017,0,0,2,-3),z(.025,-1.67,0,.0031,0,0,2,-4),z(1.06,2.96,-.166,.0243,3,0,0,2),z(36.124,50.64,-1.3,.6215,3,0,0,0),z(-13.193,-16.4,.258,-.1187,3,0,0,-2),z(-1.187,-.74,.042,.0074,3,0,0,-4),z(-.293,-.31,-.002,.0046,3,0,0,-6),z(-.29,-1.45,.116,-.0051,2,1,0,2),z(-7.649,-10.56,.259,-.1038,2,1,0,0),z(-8.627,-7.59,.078,-.0192,2,1,0,-2),z(-2.74,-2.54,.022,.0324,2,1,0,-4),z(1.181,3.32,-.212,.0213,2,-1,0,2),z(9.703,11.67,-.151,.1268,2,-1,0,0),z(-.352,-.37,.001,-.0028,2,-1,0,-1),z(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),z(.36,.2,-.012,-.0043,2,-1,0,-4),z(-1.167,-1.25,.008,-.0106,1,2,0,0),z(-7.412,-6.12,.117,.0484,1,2,0,-2),z(-.311,-.65,-.032,.0044,1,2,0,-4),z(.757,1.82,-.105,.0112,1,-2,0,2),z(2.58,2.32,.027,.0196,1,-2,0,0),z(2.533,2.4,-.014,-.0212,1,-2,0,-2),z(-.344,-.57,-.025,.0036,0,3,0,-2),z(-.992,-.02,0,0,1,0,2,2),z(-45.099,-.02,0,-.001,1,0,2,0),z(-.179,-9.52,0,-.0833,1,0,2,-2),z(-.301,-.33,0,.0014,1,0,2,-4),z(-6.382,-3.37,0,-.0481,1,0,-2,2),z(39.528,85.13,0,-.7136,1,0,-2,0),z(9.366,.71,0,-.0112,1,0,-2,-2),z(.202,.02,0,0,1,0,-2,-4),z(.415,.1,0,.0013,0,1,2,0),z(-2.152,-2.26,0,-.0066,0,1,2,-2),z(-1.44,-1.3,0,.0014,0,1,-2,2),z(.384,-.04,0,0,0,1,-2,-2),z(1.938,3.6,-.145,.0401,4,0,0,0),z(-.952,-1.58,.052,-.013,4,0,0,-2),z(-.551,-.94,.032,-.0097,3,1,0,0),z(-.482,-.57,.005,-.0045,3,1,0,-2),z(.681,.96,-.026,.0115,3,-1,0,0),z(-.297,-.27,.002,-9e-4,2,2,0,-2),z(.254,.21,-.003,0,2,-2,0,-2),z(-.25,-.22,.004,.0014,1,3,0,-2),z(-3.996,0,0,4e-4,2,0,2,0),z(.557,-.75,0,-.009,2,0,2,-2),z(-.459,-.38,0,-.0053,2,0,-2,2),z(-1.298,.74,0,4e-4,2,0,-2,0),z(.538,1.14,0,-.0141,2,0,-2,-2),z(.263,.02,0,0,1,1,2,0),z(.426,.07,0,-6e-4,1,1,-2,-2),z(-.304,.03,0,3e-4,1,-1,2,0),z(-.372,-.19,0,-.0027,1,-1,-2,2),z(.418,0,0,0,0,0,4,0),z(-.33,-.04,0,0,3,0,2,0);function At(Ct,yt,Ft,kt,zt){return Ct*nt(yt,Ft,kt,zt).y}v=0,v+=At(-526.069,0,0,1,-2),v+=At(-3.352,0,0,1,-4),v+=At(44.297,1,0,1,-2),v+=At(-6,1,0,1,-4),v+=At(20.599,-1,0,1,0),v+=At(-30.598,-1,0,1,-2),v+=At(-24.649,-2,0,1,0),v+=At(-2,-2,0,1,-2),v+=At(-22.571,0,1,1,-2),v+=At(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),r=S+L/Ns;let Nt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(r)-6.24*Math.sin(3*r)+v;return{geo_eclip_lon:cs*Za((_+p/Ns)/cs),geo_eclip_lat:Math.PI/(180*3600)*Nt,distance_au:Ns*_5/(.999953253*g)}}function $g(a,t){return[a.rot[0][0]*t[0]+a.rot[1][0]*t[1]+a.rot[2][0]*t[2],a.rot[0][1]*t[0]+a.rot[1][1]*t[1]+a.rot[2][1]*t[2],a.rot[0][2]*t[0]+a.rot[1][2]*t[1]+a.rot[2][2]*t[2]]}function gl(a,t,e){const i=l0(t,e);return $g(i,a)}function l0(a,t){const e=a.tt/36525;let i=84381.406,n=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,s=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+i,r=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;i*=sr,n*=sr,s*=sr,r*=sr;const o=Math.sin(i),c=Math.cos(i),l=Math.sin(-n),h=Math.cos(-n),u=Math.sin(-s),d=Math.cos(-s),f=Math.sin(r),p=Math.cos(r),v=p*h-l*f*d,m=p*l*c+f*d*h*c-o*f*u,g=p*l*o+f*d*h*o+c*f*u,_=-f*h-l*p*d,w=-f*l*c+p*d*h*c-o*p*u,M=-f*l*o+p*d*h*o+c*p*u,S=l*u,b=-u*h*c-o*d,T=-u*h*o+d*c;if(t===Si.Into2000)return new $s([[v,m,g],[_,w,M],[S,b,T]]);if(t===Si.From2000)return new $s([[v,_,S],[m,w,b],[g,M,T]]);throw"Invalid precess direction"}function P5(a){const t=.779057273264+.00273781191135448*a.ut,e=a.ut%1;let i=360*((t+e)%1);return i<0&&(i+=360),i}let _c;function Pl(a){if(!_c||_c.tt!==a.tt){const t=a.tt/36525;let e=15*Lo(a).ee;const i=P5(a);let s=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+i)%360/15;s<0&&(s+=24),_c={tt:a.tt,st:s}}return _c.st}function L5(a){const t=Be(a);return Pl(t)}function Zg(a,t){const e=a.latitude*ye,i=Math.sin(e),n=Math.cos(e),s=1/Math.hypot(n,od*i),r=y5*s,o=a.height/1e3,c=cd*s+o,l=cd*r+o,h=(15*t+a.longitude)*ye,u=Math.sin(h),d=Math.cos(h);return{pos:[c*n*d/ua,c*n*u/ua,l*i/ua],vel:[-Ep*c*n*u*86400/ua,Ep*c*n*d*86400/ua,0]}}function fd(a,t,e){const i=h0(t,e);return $g(i,a)}function h0(a,t){const e=Lo(a),i=e.mobl*ye,n=e.tobl*ye,s=e.dpsi*sr,r=Math.cos(i),o=Math.sin(i),c=Math.cos(n),l=Math.sin(n),h=Math.cos(s),u=Math.sin(s),d=h,f=-u*r,p=-u*o,v=u*c,m=h*r*c+o*l,g=h*o*c-r*l,_=u*l,w=h*r*l-o*c,M=h*o*l+r*c;if(t===Si.From2000)return new $s([[d,v,_],[f,m,w],[p,g,M]]);if(t===Si.Into2000)return new $s([[d,f,p],[v,m,g],[_,w,M]]);throw"Invalid precess direction"}function u0(a,t,e){return e===Si.Into2000?gl(fd(a,t,e),t,e):fd(gl(a,t,e),t,e)}function N5(a,t){const e=Pl(a),i=Zg(t,e).pos;return u0(i,a,Si.Into2000)}class Ce{constructor(t,e,i,n){this.x=t,this.y=e,this.z=i,this.t=n}Length(){return Math.hypot(this.x,this.y,this.z)}}class Vs{constructor(t,e,i,n,s,r,o){this.x=t,this.y=e,this.z=i,this.vx=n,this.vy=s,this.vz=r,this.t=o}}class Ll{constructor(t,e,i){this.lat=Mi(t),this.lon=Mi(e),this.dist=Mi(i)}}class pd{constructor(t,e,i,n){this.ra=Mi(t),this.dec=Mi(e),this.dist=Mi(i),this.vec=n}}class $s{constructor(t){this.rot=t}}class O5{constructor(t,e,i,n){this.azimuth=Mi(t),this.altitude=Mi(e),this.ra=Mi(i),this.dec=Mi(n)}}class U5{constructor(t,e,i){this.vec=t,this.elat=Mi(e),this.elon=Mi(i)}}function Jg(a,t){return new Ce(a[0],a[1],a[2],t)}function F5(a,t){const e=Jg(a,t),i=e.x*e.x+e.y*e.y,n=Math.sqrt(i+e.z*e.z);if(i===0){if(e.z===0)throw"Indeterminate sky coordinates";return new pd(0,e.z<0?-90:90,n,e)}let s=Xg*Math.atan2(e.y,e.x);s<0&&(s+=24);const r=ts*Math.atan2(a[2],Math.sqrt(i));return new pd(s,r,n,e)}function Dh(a,t){const e=a*ye,i=Math.cos(e),n=Math.sin(e);return[i*t[0]+n*t[1],i*t[1]-n*t[0],t[2]]}function jg(a,t,e,i,n){let s=Be(a);d0(t),Mi(e),Mi(i);const r=Math.sin(t.latitude*ye),o=Math.cos(t.latitude*ye),c=Math.sin(t.longitude*ye),l=Math.cos(t.longitude*ye),h=Math.sin(i*ye),u=Math.cos(i*ye),d=Math.sin(e*wp),f=Math.cos(e*wp);let p=[o*l,o*c,r],v=[-r*l,-r*c,o],m=[c,-l,0];const g=-15*Pl(s);let _=Dh(g,p),w=Dh(g,v),M=Dh(g,m),S=[u*f,u*d,h];const b=S[0]*_[0]+S[1]*_[1]+S[2]*_[2],T=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],x=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(T,x),I;A>0?(I=-ts*Math.atan2(x,T),I<0&&(I+=360)):I=0;let C=ts*Math.atan2(A,b),L=e,W=i;if(n){let X=C,P=o1(n,90-C);if(C-=P,P>0&&C>3e-4){const B=Math.sin(C*ye),k=Math.cos(C*ye),K=Math.sin(X*ye),tt=Math.cos(X*ye),J=[];for(let it=0;it<3;++it)J.push((S[it]-tt*_[it])/K*B+_[it]*k);A=Math.hypot(J[0],J[1]),A>0?(L=Xg*Math.atan2(J[1],J[0]),L<0&&(L+=24)):L=0,W=ts*Math.atan2(J[2],A)}}return new O5(I,90-C,L,W)}function d0(a){if(!(a instanceof f0))throw`Not an instance of the Observer class: ${a}`;if(Mi(a.latitude),Mi(a.longitude),Mi(a.height),a.latitude<-90||a.latitude>90)throw`Latitude ${a.latitude} is out of range. Must be -90..+90.`;return a}class f0{constructor(t,e,i){this.latitude=t,this.longitude=e,this.height=i,d0(this)}}function k5(a){const t=Be(a).AddDays(-1/r0),e=vr(Jn.Earth,t),i=[-e.x,-e.y,-e.z],[n,s,r]=u0(i,t,Si.From2000),o=ye*Lo(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new Ce(n,s,r,t);return Qg(h,c,l)}function z5(a,t,e,i,n){d0(e),ml(i),ml(n);const s=Be(t),r=N5(s,e),o=bd(a,s,n),c=[o.x-r[0],o.y-r[1],o.z-r[2]],l=u0(c,s,Si.From2000);return F5(l,s)}function B5(a,t,e){const i=Be(a),n=Pl(i);let s=Zg(t,n).pos;return Jg(s,i)}function Qg(a,t,e){const i=a.x,n=a.y*t+a.z*e,s=-a.y*e+a.z*t,r=Math.hypot(i,n);let o=0;r>0&&(o=ts*Math.atan2(n,i),o<0&&(o+=360));let c=ts*Math.atan2(s,r),l=new Ce(i,n,s,a.t);return new U5(l,c,o)}function md(a){const t=Lo(a.t),e=[a.x,a.y,a.z],i=gl(e,a.t,Si.From2000),[n,s,r]=fd(i,a.t,Si.From2000),o=new Ce(n,s,r,a.t),c=t.tobl*ye;return Qg(o,Math.cos(c),Math.sin(c))}function wr(a){const t=Be(a),e=I5(t),i=e.distance_au*Math.cos(e.geo_eclip_lat),n=[i*Math.cos(e.geo_eclip_lon),i*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],s=C5(t,n),r=gl(s,t,Si.Into2000);return new Ce(r[0],r[1],r[2],t)}function t1(a){const t=Be(a),e=1e-5,i=t.AddDays(-e),n=t.AddDays(+e),s=wr(i),r=wr(n);return new Vs((s.x+r.x)/2,(s.y+r.y)/2,(s.z+r.z)/2,(r.x-s.x)/(2*e),(r.y-s.y)/(2*e),(r.z-s.z)/(2*e),t)}function H5(a){const t=Be(a),e=t1(t),i=1+Yg;return new Vs(e.x/i,e.y/i,e.z/i,e.vx/i,e.vy/i,e.vz/i,t)}function gr(a,t,e){let i=1,n=0;for(let s of a){let r=0;for(let[c,l,h]of s)r+=c*Math.cos(l+t*h);let o=i*r;e&&(o%=cs),n+=o,i*=t}return n}function Ch(a,t){let e=1,i=0,n=0,s=0;for(let r of a){let o=0,c=0;for(let[l,h,u]of r){let d=h+t*u;o+=l*u*Math.sin(d),s>0&&(c+=l*Math.cos(d))}n+=s*i*c-e*o,i=e,e*=t,++s}return n}const io=365250,gd=0,vd=1,Md=2;function xd(a){return new Ri(a[0]+44036e-11*a[1]-190919e-12*a[2],-479966e-12*a[0]+.917482137087*a[1]-.397776982902*a[2],.397776982902*a[1]+.917482137087*a[2])}function e1(a,t,e){const i=e*Math.cos(t),n=Math.cos(a),s=Math.sin(a);return[i*n,i*s,e*Math.sin(t)]}function vr(a,t){const e=t.tt/io,i=gr(a[gd],e,!0),n=gr(a[vd],e,!1),s=gr(a[Md],e,!1),r=e1(i,n,s);return xd(r).ToAstroVector(t)}function yd(a,t){const e=t/io,i=gr(a[gd],e,!0),n=gr(a[vd],e,!1),s=gr(a[Md],e,!1),r=Ch(a[gd],e),o=Ch(a[vd],e),c=Ch(a[Md],e),l=Math.cos(i),h=Math.sin(i),u=Math.cos(n),d=Math.sin(n),f=+(c*u*l)-s*d*l*o-s*u*h*r,p=+(c*u*h)-s*d*h*o+s*u*l*r,v=+(c*d)+s*u*o,m=e1(i,n,s),g=[f/io,p/io,v/io],_=xd(m),w=xd(g);return new ba(t,_,w)}function Sc(a,t,e,i){const n=i/(i+o0),s=vr(Jn[e],t);a.x+=n*s.x,a.y+=n*s.y,a.z+=n*s.z}function G5(a){const t=new Ce(0,0,0,a);return Sc(t,a,wt.Jupiter,ld),Sc(t,a,wt.Saturn,hd),Sc(t,a,wt.Uranus,ud),Sc(t,a,wt.Neptune,dd),t}const _d=51,V5=29200,ar=146,ls=201,va=[[-73e4,[-26.118207232108,-14.376168177825,3.384402515299],[.0016339372163656,-.0027861699588508,-.0013585880229445]],[-700800,[41.974905202127,-.448502952929,-12.770351505989],[.00073458569351457,.0022785014891658,.00048619778602049]],[-671600,[14.706930780744,44.269110540027,9.353698474772],[-.00210001479998,.00022295915939915,.00070143443551414]],[-642400,[-29.441003929957,-6.43016153057,6.858481011305],[.00084495803960544,-.0030783914758711,-.0012106305981192]],[-613200,[39.444396946234,-6.557989760571,-13.913760296463],[.0011480029005873,.0022400006880665,.00035168075922288]],[-584e3,[20.2303809507,43.266966657189,7.382966091923],[-.0019754081700585,.00053457141292226,.00075929169129793]],[-554800,[-30.65832536462,2.093818874552,9.880531138071],[61010603013347e-18,-.0031326500935382,-.00099346125151067]],[-525600,[35.737703251673,-12.587706024764,-14.677847247563],[.0015802939375649,.0021347678412429,.00019074436384343]],[-496400,[25.466295188546,41.367478338417,5.216476873382],[-.0018054401046468,.0008328308359951,.00080260156912107]],[-467200,[-29.847174904071,10.636426313081,12.297904180106],[-.00063257063052907,-.0029969577578221,-.00074476074151596]],[-438e3,[30.774692107687,-18.236637015304,-14.945535879896],[.0020113162005465,.0019353827024189,-20937793168297e-19]],[-408800,[30.243153324028,38.656267888503,2.938501750218],[-.0016052508674468,.0011183495337525,.00083333973416824]],[-379600,[-27.288984772533,18.643162147874,14.023633623329],[-.0011856388898191,-.0027170609282181,-.00049015526126399]],[-350400,[24.519605196774,-23.245756064727,-14.626862367368],[.0024322321483154,.0016062008146048,-.00023369181613312]],[-321200,[34.505274805875,35.125338586954,.557361475637],[-.0013824391637782,.0013833397561817,.00084823598806262]],[-292e3,[-23.275363915119,25.818514298769,15.055381588598],[-.0016062295460975,-.0023395961498533,-.00024377362639479]],[-262800,[17.050384798092,-27.180376290126,-13.608963321694],[.0028175521080578,.0011358749093955,-.00049548725258825]],[-233600,[38.093671910285,30.880588383337,-1.843688067413],[-.0011317697153459,.0016128814698472,.00084177586176055]],[-204400,[-18.197852930878,31.932869934309,15.438294826279],[-.0019117272501813,-.0019146495909842,-19657304369835e-18]],[-175200,[8.528924039997,-29.618422200048,-11.805400994258],[.0031034370787005,.0005139363329243,-.00077293066202546]],[-146e3,[40.94685725864,25.904973592021,-4.256336240499],[-.00083652705194051,.0018129497136404,.0008156422827306]],[-116800,[-12.326958895325,36.881883446292,15.217158258711],[-.0021166103705038,-.001481442003599,.00017401209844705]],[-87600,[-.633258375909,-30.018759794709,-9.17193287495],[.0032016994581737,-.00025279858672148,-.0010411088271861]],[-58400,[42.936048423883,20.344685584452,-6.588027007912],[-.00050525450073192,.0019910074335507,.00077440196540269]],[-29200,[-5.975910552974,40.61180995846,14.470131723673],[-.0022184202156107,-.0010562361130164,.00033652250216211]],[0,[-9.875369580774,-27.978926224737,-5.753711824704],[.0030287533248818,-.0011276087003636,-.0012651326732361]],[29200,[43.958831986165,14.214147973292,-8.808306227163],[-.00014717608981871,.0021404187242141,.00071486567806614]],[58400,[.67813676352,43.094461639362,13.243238780721],[-.0022358226110718,-.00063233636090933,.00047664798895648]],[87600,[-18.282602096834,-23.30503958666,-1.766620508028],[.0025567245263557,-.0019902940754171,-.0013943491701082]],[116800,[43.873338744526,7.700705617215,-10.814273666425],[.00023174803055677,.0022402163127924,.00062988756452032]],[146e3,[7.392949027906,44.382678951534,11.629500214854],[-.002193281545383,-.00021751799585364,.00059556516201114]],[175200,[-24.981690229261,-16.204012851426,2.466457544298],[.001819398914958,-.0026765419531201,-.0013848283502247]],[204400,[42.530187039511,.845935508021,-12.554907527683],[.00065059779150669,.0022725657282262,.00051133743202822]],[233600,[13.999526486822,44.462363044894,9.669418486465],[-.0021079296569252,.00017533423831993,.00069128485798076]],[262800,[-29.184024803031,-7.371243995762,6.493275957928],[.00093581363109681,-.0030610357109184,-.0012364201089345]],[292e3,[39.831980671753,-6.078405766765,-13.909815358656],[.0011117769689167,.0022362097830152,.00036230548231153]],[321200,[20.294955108476,43.417190420251,7.450091985932],[-.0019742157451535,.00053102050468554,.00075938408813008]],[350400,[-30.66999230216,2.318743558955,9.973480913858],[45605107450676e-18,-.0031308219926928,-.00099066533301924]],[379600,[35.626122155983,-12.897647509224,-14.777586508444],[.0016015684949743,.0021171931182284,.00018002516202204]],[408800,[26.133186148561,41.232139187599,5.00640132622],[-.0017857704419579,.00086046232702817,.00080614690298954]],[438e3,[-29.57674022923,11.863535943587,12.631323039872],[-.00072292830060955,-.0029587820140709,-.000708242964503]],[467200,[29.910805787391,-19.159019294,-15.013363865194],[.0020871080437997,.0018848372554514,-38528655083926e-18]],[496400,[31.375957451819,38.050372720763,2.433138343754],[-.0015546055556611,.0011699815465629,.00083565439266001]],[525600,[-26.360071336928,20.662505904952,14.414696258958],[-.0013142373118349,-.0026236647854842,-.00042542017598193]],[554800,[22.599441488648,-24.508879898306,-14.484045731468],[.0025454108304806,.0014917058755191,-.00030243665086079]],[584e3,[35.877864013014,33.894226366071,-.224524636277],[-.0012941245730845,.0014560427668319,.00084762160640137]],[613200,[-21.538149762417,28.204068269761,15.321973799534],[-.001731211740901,-.0021939631314577,-.0001631691327518]],[642400,[13.971521374415,-28.339941764789,-13.083792871886],[.0029334630526035,.00091860931752944,-.00059939422488627]],[671600,[39.526942044143,28.93989736011,-2.872799527539],[-.0010068481658095,.001702113288809,.00083578230511981]],[700800,[-15.576200701394,34.399412961275,15.466033737854],[-.0020098814612884,-.0017191109825989,70414782780416e-18]],[73e4,[4.24325283709,-30.118201690825,-10.707441231349],[.0031725847067411,.0001609846120227,-.00090672150593868]]];class Ri{constructor(t,e,i){this.x=t,this.y=e,this.z=i}clone(){return new Ri(this.x,this.y,this.z)}ToAstroVector(t){return new Ce(this.x,this.y,this.z,t)}static zero(){return new Ri(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new Ri(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new Ri(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 Ri(t*this.x,t*this.y,t*this.z)}div(t){return new Ri(this.x/t,this.y/t,this.z/t)}mean(t){return new Ri((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new Ri(-this.x,-this.y,-this.z)}}class ba{constructor(t,e,i){this.tt=t,this.r=e,this.v=i}clone(){return new ba(this.tt,this.r,this.v)}sub(t){return new ba(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function W5(a){let[t,[e,i,n],[s,r,o]]=a;return new ba(t,new Ri(e,i,n),new Ri(s,r,o))}function wc(a,t,e,i){const n=i/(i+o0),s=yd(Jn[e],t);return a.r.incr(s.r.mul(n)),a.v.incr(s.v.mul(n)),s}function Xr(a,t,e){const i=e.sub(a),n=i.quadrature();return i.mul(t/(n*Math.sqrt(n)))}class Nl{constructor(t){let e=new ba(t,new Ri(0,0,0),new Ri(0,0,0));this.Jupiter=wc(e,t,wt.Jupiter,ld),this.Saturn=wc(e,t,wt.Saturn,hd),this.Uranus=wc(e,t,wt.Uranus,ud),this.Neptune=wc(e,t,wt.Neptune,dd),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 ba(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=Xr(t,o0,this.Sun.r);return e.incr(Xr(t,ld,this.Jupiter.r)),e.incr(Xr(t,hd,this.Saturn.r)),e.incr(Xr(t,ud,this.Uranus.r)),e.incr(Xr(t,dd,this.Neptune.r)),e}}class Ol{constructor(t,e,i,n){this.tt=t,this.r=e,this.v=i,this.a=n}clone(){return new Ol(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class i1{constructor(t,e){this.bary=t,this.grav=e}}function vl(a,t,e,i){return new Ri(t.x+a*(e.x+a*i.x/2),t.y+a*(e.y+a*i.y/2),t.z+a*(e.z+a*i.z/2))}function Tp(a,t,e){return new Ri(t.x+a*e.x,t.y+a*e.y,t.z+a*e.z)}function Sd(a,t){const e=a-t.tt,i=new Nl(a),n=vl(e,t.r,t.v,t.a),s=i.Acceleration(n).mean(t.a),r=vl(e,t.r,t.v,s),o=t.v.add(s.mul(e)),c=i.Acceleration(r),l=new Ol(a,r,o,c);return new i1(i,l)}const X5=[];function n1(a,t){const e=Math.floor(a);return e<0?0:e>=t?t-1:e}function wd(a){const t=W5(a),e=new Nl(t.tt),i=t.r.add(e.Sun.r),n=t.v.add(e.Sun.v),s=e.Acceleration(i),r=new Ol(t.tt,i,n,s);return new i1(e,r)}function q5(a,t){const e=va[0][0];if(t<e||t>va[_d-1][0])return null;const i=n1((t-e)/V5,_d-1);if(!a[i]){const s=a[i]=[];s[0]=wd(va[i]).grav,s[ls-1]=wd(va[i+1]).grav;let r,o=s[0].tt;for(r=1;r<ls-1;++r)s[r]=Sd(o+=ar,s[r-1]).grav;o=s[ls-1].tt;var n=[];for(n[ls-1]=s[ls-1],r=ls-2;r>0;--r)n[r]=Sd(o-=ar,n[r+1]).grav;for(r=ls-2;r>0;--r){const c=r/(ls-1);s[r].r=s[r].r.mul(1-c).add(n[r].r.mul(c)),s[r].v=s[r].v.mul(1-c).add(n[r].v.mul(c)),s[r].a=s[r].a.mul(1-c).add(n[r].a.mul(c))}}return a[i]}function Rp(a,t,e){let i=wd(a);const n=Math.ceil((t-i.grav.tt)/e);for(let s=0;s<n;++s)i=Sd(s+1===n?t:i.grav.tt+e,i.grav);return i}function s1(a,t){let e,i,n;const s=q5(X5,a.tt);if(s){const r=n1((a.tt-s[0].tt)/ar,ls-1),o=s[r],c=s[r+1],l=o.a.mean(c.a),h=vl(a.tt-o.tt,o.r,o.v,l),u=Tp(a.tt-o.tt,o.v,l),d=vl(a.tt-c.tt,c.r,c.v,l),f=Tp(a.tt-c.tt,c.v,l),p=(a.tt-o.tt)/ar;e=h.mul(1-p).add(d.mul(p)),i=u.mul(1-p).add(f.mul(p))}else{let r;a.tt<va[0][0]?r=Rp(va[0],a.tt,-ar):r=Rp(va[_d-1],a.tt,+ar),e=r.grav.r,i=r.grav.v,n=r.bary}return n||(n=new Nl(a.tt)),e=e.sub(n.Sun.r),i=i.sub(n.Sun.v),new Vs(e.x,e.y,e.z,i.x,i.y,i.z,a)}function qs(a,t){var e=Be(t);if(a in Jn)return vr(Jn[a],e);if(a===wt.Pluto){const r=s1(e);return new Ce(r.x,r.y,r.z,e)}if(a===wt.Sun)return new Ce(0,0,0,e);if(a===wt.Moon){var i=vr(Jn.Earth,e),n=wr(e);return new Ce(i.x+n.x,i.y+n.y,i.z+n.z,e)}if(a===wt.EMB){const r=vr(Jn.Earth,e),o=wr(e),c=1+Yg;return new Ce(r.x+o.x/c,r.y+o.y/c,r.z+o.z/c,e)}if(a===wt.SSB)return G5(e);const s=c0(a);if(s){const r=new Ll(s.dec,15*s.ra,s.dist);return p0(r,e)}throw`HelioVector: Unknown body "${a}"`}function Y5(a,t){let e=t,i=0;for(let n=0;n<10;++n){const s=a(e),r=s.Length()/r0;if(r>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-r);if(i=Math.abs(o.tt-e.tt),i<1e-9)return s;e=o}throw`Light-travel time solver did not converge: dt = ${i}`}class K5{constructor(t,e,i,n){this.observerBody=t,this.targetBody=e,this.aberration=i,this.observerPos=n}Position(t){this.aberration&&(this.observerPos=qs(this.observerBody,t));const e=qs(this.targetBody,t);return new Ce(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function $5(a,t,e,i){ml(i);const n=Be(a);if(c0(e)){const o=qs(e,n);if(i){const l=J5(t,n),h=new Ce(o.x-l.x,o.y-l.y,o.z-l.z,n),u=r0/h.Length();return new Ce(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,n)}const c=qs(t,n);return new Ce(o.x-c.x,o.y-c.y,o.z-c.z,n)}let s;i?s=new Ce(0,0,0,n):s=qs(t,n);const r=new K5(t,e,i,s);return Y5(o=>r.Position(o),n)}function bd(a,t,e){ml(e);const i=Be(t);switch(a){case wt.Earth:return new Ce(0,0,0,i);case wt.Moon:return wr(i);default:const n=$5(i,wt.Earth,a,e);return n.t=i,n}}function Z5(a,t){return new Vs(a.r.x,a.r.y,a.r.z,a.v.x,a.v.y,a.v.z,t)}function J5(a,t){const e=Be(t);switch(a){case wt.Sun:return new Vs(0,0,0,0,0,0,e);case wt.SSB:const i=new Nl(e.tt);return new Vs(-i.Sun.r.x,-i.Sun.r.y,-i.Sun.r.z,-i.Sun.v.x,-i.Sun.v.y,-i.Sun.v.z,e);case wt.Mercury:case wt.Venus:case wt.Earth:case wt.Mars:case wt.Jupiter:case wt.Saturn:case wt.Uranus:case wt.Neptune:const n=yd(Jn[a],e.tt);return Z5(n,e);case wt.Pluto:return s1(e);case wt.Moon:case wt.EMB:const s=yd(Jn.Earth,e.tt),r=a==wt.Moon?t1(e):H5(e);return new Vs(r.x+s.r.x,r.y+s.r.y,r.z+s.r.z,r.vx+s.v.x,r.vy+s.v.y,r.vz+s.v.z,e);default:if(c0(a)){const o=qs(a,e);return new Vs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${a}"`}}function j5(a){for(;a<0;)a+=360;for(;a>=360;)a-=360;return a}function Q5(a,t,e){if(a===wt.Earth||t===wt.Earth)throw"The Earth does not have a longitude as seen from itself.";const i=Be(e),n=bd(a,i,!1),s=md(n),r=bd(t,i,!1),o=md(r);return j5(s.elon-o.elon)}function tw(a,t,e,i){let n,s=0,r=0,o=0;switch(a){case wt.Mercury:n=-.6,s=4.98,r=-4.88,o=3.02;break;case wt.Venus:t<163.6?(n=-4.47,s=1.03,r=.57,o=.13):(n=.98,s=-1.02);break;case wt.Mars:n=-1.52,s=1.6;break;case wt.Jupiter:n=-9.4,s=.5;break;case wt.Uranus:n=-7.19,s=.25;break;case wt.Neptune:n=-6.87;break;case wt.Pluto:n=-1,s=4;break;default:throw`VisualMagnitude: unsupported body ${a}`}const c=t/100;let l=n+c*(s+c*(r+c*o));return l+=5*Math.log10(e*i),l}function ew(a,t,e,i,n){const s=md(i),r=ye*28.06,o=ye*(169.51+382e-7*n.tt),c=ye*s.elat,l=ye*s.elon,h=Math.asin(Math.sin(c)*Math.cos(r)-Math.cos(c)*Math.sin(r)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*a;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:ts*h}}function iw(a,t,e){let i=a*ye,n=i*i,s=n*n,r=-12.717+1.49*Math.abs(i)+.0431*s;const o=385000.6/ua;let c=e/o;return r+=5*Math.log10(t*c),r}class nw{constructor(t,e,i,n,s,r,o,c){this.time=t,this.mag=e,this.phase_angle=i,this.helio_dist=n,this.geo_dist=s,this.gc=r,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ye*i))/2}}function a1(a,t){if(a===wt.Earth)throw"The illumination of the Earth is not defined.";const e=Be(t),i=vr(Jn.Earth,e);let n,s,r,o;a===wt.Sun?(r=new Ce(-i.x,-i.y,-i.z,e),s=new Ce(0,0,0,e),n=0):(a===wt.Moon?(r=wr(e),s=new Ce(i.x+r.x,i.y+r.y,i.z+r.z,e)):(s=qs(a,t),r=new Ce(s.x-i.x,s.y-i.y,s.z-i.z,e)),n=S5(r,s));let c=r.Length(),l=s.Length(),h;if(a===wt.Sun)o=x5+5*Math.log10(c);else if(a===wt.Moon)o=iw(n,l,c);else if(a===wt.Saturn){const u=ew(n,l,c,r,e);o=u.mag,h=u.ring_tilt}else o=tw(a,n,l,c);return new nw(e,o,n,l,c,r,s,h)}function sw(a){return Q5(wt.Moon,wt.Sun,a)}var Dp;(function(a){a[a.Pericenter=0]="Pericenter",a[a.Apocenter=1]="Apocenter"})(Dp||(Dp={}));function r1(a,t){return new $s([[t.rot[0][0]*a.rot[0][0]+t.rot[1][0]*a.rot[0][1]+t.rot[2][0]*a.rot[0][2],t.rot[0][1]*a.rot[0][0]+t.rot[1][1]*a.rot[0][1]+t.rot[2][1]*a.rot[0][2],t.rot[0][2]*a.rot[0][0]+t.rot[1][2]*a.rot[0][1]+t.rot[2][2]*a.rot[0][2]],[t.rot[0][0]*a.rot[1][0]+t.rot[1][0]*a.rot[1][1]+t.rot[2][0]*a.rot[1][2],t.rot[0][1]*a.rot[1][0]+t.rot[1][1]*a.rot[1][1]+t.rot[2][1]*a.rot[1][2],t.rot[0][2]*a.rot[1][0]+t.rot[1][2]*a.rot[1][1]+t.rot[2][2]*a.rot[1][2]],[t.rot[0][0]*a.rot[2][0]+t.rot[1][0]*a.rot[2][1]+t.rot[2][0]*a.rot[2][2],t.rot[0][1]*a.rot[2][0]+t.rot[1][1]*a.rot[2][1]+t.rot[2][1]*a.rot[2][2],t.rot[0][2]*a.rot[2][0]+t.rot[1][2]*a.rot[2][1]+t.rot[2][2]*a.rot[2][2]]])}function p0(a,t){t=Be(t);const e=a.lat*ye,i=a.lon*ye,n=a.dist*Math.cos(e);return new Ce(n*Math.cos(i),n*Math.sin(i),a.dist*Math.sin(e),t)}function m0(a){const t=aw(a);return new pd(t.lon/15,t.lat,t.dist,a)}function aw(a){const t=a.x*a.x+a.y*a.y,e=Math.sqrt(t+a.z*a.z);let i,n;if(t===0){if(a.z===0)throw"Zero-length vector not allowed.";n=0,i=a.z<0?-90:90}else n=ts*Math.atan2(a.y,a.x),n<0&&(n+=360),i=ts*Math.atan2(a.z,Math.sqrt(t));return new Ll(i,n,e)}function o1(a,t){let e;if(Mi(t),t<-90||t>90)return 0;if(a==="normal"||a==="jplhor"){let i=t;i<-1&&(i=-1),e=1.02/Math.tan((i+10.3/(i+5.11))*ye)/60,a==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!a)e=0;else throw`Invalid refraction option: ${a}`;return e}function Mr(a,t){return new Ce(a.rot[0][0]*t.x+a.rot[1][0]*t.y+a.rot[2][0]*t.z,a.rot[0][1]*t.x+a.rot[1][1]*t.y+a.rot[2][1]*t.z,a.rot[0][2]*t.x+a.rot[1][2]*t.y+a.rot[2][2]*t.z,t.t)}function rw(){return new $s([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function ow(){return new $s([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function c1(a){a=Be(a);const t=l0(a,Si.From2000),e=h0(a,Si.From2000);return r1(t,e)}function cw(a){a=Be(a);const t=h0(a,Si.Into2000),e=l0(a,Si.Into2000);return r1(t,e)}function lw(a){const e=Lo(Be(a)).tobl*ye,i=Math.cos(e),n=Math.sin(e);return new $s([[1,0,0],[0,+i,+n],[0,-n,+i]])}var Cp;(function(a){a.Penumbral="penumbral",a.Partial="partial",a.Annular="annular",a.Total="total"})(Cp||(Cp={}));var Ip;(function(a){a[a.Invalid=0]="Invalid",a[a.Ascending=1]="Ascending",a[a.Descending=-1]="Descending"})(Ip||(Ip={}));const hw=["Venus","Mars","Jupiter","Saturn"];function l1(a){return new f0(a.lat,a.lng,a.elevationM)}function g0(a,t,e,i,n=!0){const s=jg(e,l1(i),a,t,n?"normal":void 0);return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}class An{up;north;west;constructor(t,e){const i=Be(t),n=Math.sin(e.lat*hs),s=Math.cos(e.lat*hs),r=Math.sin(e.lng*hs),o=Math.cos(e.lng*hs),c=-15*L5(i),l=cw(i);this.up=An.rotate(l,An.spin(c,[s*o,s*r,n]),i),this.north=An.rotate(l,An.spin(c,[-n*o,-n*r,s]),i),this.west=An.rotate(l,An.spin(c,[r,-o,0]),i)}static ofJ2000(t,e,i,n,s=!0){const r=Be(i),o=p0(new Ll(e,t*15,1),r),c=m0(Mr(c1(r),o));return g0(c.ra,c.dec,i,n,s)}position(t,e){const i=Math.sin(e*hs),n=Math.cos(e*hs),s=Math.sin(t*Lp),r=Math.cos(t*Lp),o=n*r,c=n*s,l=i,h=o*this.up[0]+c*this.up[1]+l*this.up[2],u=o*this.north[0]+c*this.north[1]+l*this.north[2],d=o*this.west[0]+c*this.west[1]+l*this.west[2],f=Math.hypot(u,d);let p=0;f>0&&(p=-Pp*Math.atan2(d,u),p<0&&(p+=360));let v=Pp*Math.atan2(f,h);return v-=o1("normal",90-v),{altitudeDeg:90-v,azimuthDeg:p}}static spin(t,[e,i,n]){const s=Math.cos(t*hs),r=Math.sin(t*hs);return[s*e+r*i,s*i-r*e,n]}static rotate(t,[e,i,n],s){const r=Mr(t,new Ce(e,i,n,s));return[r.x,r.y,r.z]}}const hs=Math.PI/180,Pp=180/Math.PI,Lp=15*hs;function Ih(a,t,e){const i=l1(e),n=z5(wt[a],t,i,!0,!0),s=jg(t,i,n.ra,n.dec,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Ph(a,t){return a1(wt[a],t).mag}function uw(a){const t=sw(a),e=a1(wt.Moon,a);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const dw=2e3,fw=3,pw=20;function bc(a,t,e){if(a.year===void 0&&a.month===void 0&&a.day===void 0&&a.hour===void 0)return;const i=a.year!==void 0,n=a.year??dw,s=a.month??(i?1:fw),r=a.day??(i?1:pw),o=e??Math.round(t/15);return new Date(Date.UTC(n,s-1,r,(a.hour??12)-o,a.minute??0,a.second??0))}class Vn{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static FALLOFF={core:Vn.CORE,rim:Vn.RIM};static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Vn.patch(e.fragmentShader)}}static patch(t){return t.replace(Vn.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
5494
5498
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
5495
5499
|
if ( distanceFromCentre > ${Vn.RIM.toFixed(2)} ) discard;
|
|
5496
5500
|
float glare = 1.0 - smoothstep( ${Vn.CORE.toFixed(2)}, ${Vn.RIM.toFixed(2)}, distanceFromCentre );
|
|
@@ -5565,7 +5569,7 @@ void main() {`).replace("gl_PointSize = size;",`gl_PointSize = size;
|
|
|
5565
5569
|
if (which < 2) gl_FragColor = vec4(sum * 4.0 * PI / SAMPLES, 1.0);
|
|
5566
5570
|
else gl_FragColor = vec4(count > 0.0 ? logSum / count : -27.6, count, 0.0, 1.0);
|
|
5567
5571
|
}
|
|
5568
|
-
`,depthTest:!1,depthWrite:!1}),this.scene.add(new Dt(new ki(2,2),this.material))}measure(t,e,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=e;const r=Math.cos(uo.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,r):h.set(0,-1,0,2)});const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(this.scene,this.camera),t.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);t.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const mw=[{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}],no=64,fi=no+1,Np=2048,gw=900,vw=700/900,Mw=0,xw=.01;function h1(a,t,e){return{north:ps(0,-e,a,t).lat,south:ps(0,e,a,t).lat,east:ps(e,0,a,t).lng,west:ps(-e,0,a,t).lng}}async function yw(a,t,e,i=gw){const n=i,s=i*vw,r=h1(a,t,n),o={width:fi,height:fi},[c,l]=await Promise.all([e.elevation.getElevationGrid(r,o),e.imagery.getImageryTexture(r,{width:Np,height:Np})]),h=Math.floor(fi/2),u=c.heights[h*fi+h],d=new Float32Array(fi*fi*3),f=new Float32Array(fi*fi*2),p=new Float32Array(fi*fi*4);for(let S=0;S<fi;S++){const b=S/(fi-1),T=r.north+(r.south-r.north)*b;for(let x=0;x<fi;x++){const A=x/(fi-1),I=r.west+(r.east-r.west)*A,{x:C,z:P}=li(T,I,a,t),X=c.heights[S*fi+x],z=Math.max(Math.abs(C),Math.abs(P)),N=1-_w((z-s)/(n-s),0,1),V=Mw+xw+(X-u),k=S*fi+x;d[k*3]=C,d[k*3+1]=V,d[k*3+2]=P;const K=Km(l.bounds,I,T);f[k*2]=K.x,f[k*2+1]=K.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=N}}const v=new Uint16Array(no*no*6);let m=0;for(let S=0;S<no;S++)for(let b=0;b<no;b++){const T=S*fi+b,x=T+1,A=T+fi,I=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new ue;g.setAttribute("position",new te(d,3)),g.setAttribute("uv",new te(f,2)),g.setAttribute("color",new te(p,4)),g.setIndex(new te(v,1)),g.computeVertexNormals();const _=new ws(l.source);_.flipY=!1,_.colorSpace=Fi,_.anisotropy=8;const w=new Er({map:_,color:new st(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new Dt(g,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function _w(a,t,e){return Math.max(t,Math.min(e,a))}class hn{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new De;surveyed=new De;stated=new De;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(t,e,i,n,s){hn.empty(this.surveyed);const r=new Map;for(const o of t){const c=r.get(o.surface)??{positions:[],indices:[]};r.set(o.surface,c),this.appendRibbon(o,e,i,n,c)}for(const[o,c]of r){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(t,e){hn.empty(this.stated);const i=new Map;for(const n of t){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(r=>({x:r.eastM,z:-r.northM})),n.widthM,e,s)}for(const[n,s]of i){const r=this.meshOf(n,s,!1);r&&this.stated.add(r)}}clear(){hn.empty(this.surveyed)}static empty(t){for(const e of[...t.children]){t.remove(e);const i=e;i.geometry?.dispose(),i.material?.dispose()}}dispose(){hn.empty(this.surveyed),hn.empty(this.stated)}appendRibbon(t,e,i,n,s){this.appendPath(t.points.map(r=>li(r.lat,r.lng,e,i)),t.widthM,n,s)}appendPath(t,e,i,n){const s=this.resample(t);if(s.length<2)return;const r=Math.max(.5,e/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*r,v=u*r,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+hn.LIFT_M,m.z,g.x,i(g.x,g.z)+hn.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(t,e,i){if(e.indices.length===0)return;const n=new ue;n.setAttribute("position",new te(new Float32Array(e.positions),3)),n.setIndex(new te(new Uint32Array(e.indices),1)),n.computeVertexNormals();const s=hn.ALBEDO[t],r=new Er({color:new st(s[0],s[1],s[2]),transparent:i,opacity:i?hn.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new Dt(n,r);return o.name=`roads ${t}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1],o=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(o/hn.STEP_M));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}const Sw=18,ww=.55,bw=.5,Ew=`
|
|
5572
|
+
`,depthTest:!1,depthWrite:!1}),this.scene.add(new Dt(new ki(2,2),this.material))}measure(t,e,i,n){if(this.reading)return;const s=this.material.uniforms;s.uProbe.value=e;const r=Math.cos(uo.SOURCE_CONE_DEG*Math.PI/180);[s.uExcludeA.value,s.uExcludeB.value].forEach((h,u)=>{const d=i[u];d?h.set(d.x,d.y,d.z,r):h.set(0,-1,0,2)});const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(this.scene,this.camera),t.setRenderTarget(c),this.reading=!0;const l=new Float32Array(12);t.readRenderTargetPixelsAsync(this.target,0,0,3,1,l).then(()=>n({up:[l[0],l[1],l[2]],down:[l[4],l[5],l[6]],logAverage:l[8]})).catch(()=>{}).finally(()=>{this.reading=!1})}dispose(){this.target.dispose(),this.material.dispose(),this.scene.children[0].geometry.dispose()}}const mw=[{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}],no=64,fi=no+1,Np=2048,gw=900,vw=700/900,Mw=0,xw=.01;function h1(a,t,e){return{north:ps(0,-e,a,t).lat,south:ps(0,e,a,t).lat,east:ps(e,0,a,t).lng,west:ps(-e,0,a,t).lng}}async function yw(a,t,e,i=gw){const n=i,s=i*vw,r=h1(a,t,n),o={width:fi,height:fi},[c,l]=await Promise.all([e.elevation.getElevationGrid(r,o),e.imagery.getImageryTexture(r,{width:Np,height:Np})]),h=Math.floor(fi/2),u=c.heights[h*fi+h],d=new Float32Array(fi*fi*3),f=new Float32Array(fi*fi*2),p=new Float32Array(fi*fi*4);for(let S=0;S<fi;S++){const b=S/(fi-1),T=r.north+(r.south-r.north)*b;for(let x=0;x<fi;x++){const A=x/(fi-1),I=r.west+(r.east-r.west)*A,{x:C,z:L}=li(T,I,a,t),W=c.heights[S*fi+x],X=Math.max(Math.abs(C),Math.abs(L)),P=1-_w((X-s)/(n-s),0,1),B=Mw+xw+(W-u),k=S*fi+x;d[k*3]=C,d[k*3+1]=B,d[k*3+2]=L;const K=Km(l.bounds,I,T);f[k*2]=K.x,f[k*2+1]=K.y,p[k*4]=1,p[k*4+1]=1,p[k*4+2]=1,p[k*4+3]=P}}const v=new Uint16Array(no*no*6);let m=0;for(let S=0;S<no;S++)for(let b=0;b<no;b++){const T=S*fi+b,x=T+1,A=T+fi,I=A+1;v[m++]=T,v[m++]=A,v[m++]=x,v[m++]=x,v[m++]=A,v[m++]=I}const g=new ue;g.setAttribute("position",new te(d,3)),g.setAttribute("uv",new te(f,2)),g.setAttribute("color",new te(p,4)),g.setIndex(new te(v,1)),g.computeVertexNormals();const _=new ws(l.source);_.flipY=!1,_.colorSpace=Fi,_.anisotropy=8;const w=new Er({map:_,color:new st(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new Dt(g,w);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution,originElevationM:Number.isFinite(u)?u:void 0}}function _w(a,t,e){return Math.max(t,Math.min(e,a))}class hn{static STEP_M=8;static LIFT_M=.06;static CONTEMPORARY_OPACITY=.45;static ALBEDO={paved:[.16,.16,.17],gravel:[.42,.38,.31],dirt:[.34,.28,.21]};group=new De;surveyed=new De;stated=new De;constructor(){this.group.name="roads",this.surveyed.name="roads surveyed",this.stated.name="roads stated",this.group.add(this.surveyed,this.stated)}set(t,e,i,n,s){hn.empty(this.surveyed);const r=new Map;for(const o of t){const c=r.get(o.surface)??{positions:[],indices:[]};r.set(o.surface,c),this.appendRibbon(o,e,i,n,c)}for(const[o,c]of r){const l=this.meshOf(o,c,s);l&&this.surveyed.add(l)}}setStated(t,e){hn.empty(this.stated);const i=new Map;for(const n of t){const s=i.get(n.surface)??{positions:[],indices:[]};i.set(n.surface,s),this.appendPath(n.path.map(r=>({x:r.eastM,z:-r.northM})),n.widthM,e,s)}for(const[n,s]of i){const r=this.meshOf(n,s,!1);r&&this.stated.add(r)}}clear(){hn.empty(this.surveyed)}static empty(t){for(const e of[...t.children]){t.remove(e);const i=e;i.geometry?.dispose(),i.material?.dispose()}}dispose(){hn.empty(this.surveyed),hn.empty(this.stated)}appendRibbon(t,e,i,n,s){this.appendPath(t.points.map(r=>li(r.lat,r.lng,e,i)),t.widthM,n,s)}appendPath(t,e,i,n){const s=this.resample(t);if(s.length<2)return;const r=Math.max(.5,e/2),o=n.positions.length/3;for(let c=0;c<s.length;c++){const l=s[Math.max(0,c-1)],h=s[Math.min(s.length-1,c+1)];let u=h.x-l.x,d=h.z-l.z;const f=Math.hypot(u,d);f<1e-6?(u=1,d=0):(u/=f,d/=f);const p=-d*r,v=u*r,m={x:s[c].x+p,z:s[c].z+v},g={x:s[c].x-p,z:s[c].z-v};n.positions.push(m.x,i(m.x,m.z)+hn.LIFT_M,m.z,g.x,i(g.x,g.z)+hn.LIFT_M,g.z)}for(let c=0;c<s.length-1;c++){const l=o+c*2;n.indices.push(l,l+2,l+1,l+1,l+2,l+3)}}meshOf(t,e,i){if(e.indices.length===0)return;const n=new ue;n.setAttribute("position",new te(new Float32Array(e.positions),3)),n.setIndex(new te(new Uint32Array(e.indices),1)),n.computeVertexNormals();const s=hn.ALBEDO[t],r=new Er({color:new st(s[0],s[1],s[2]),transparent:i,opacity:i?hn.CONTEMPORARY_OPACITY:1,fog:!0,polygonOffset:!0,polygonOffsetFactor:-2,polygonOffsetUnits:-2}),o=new Dt(n,r);return o.name=`roads ${t}`,o.receiveShadow=!0,o.castShadow=!1,o}resample(t){const e=[];for(let n=0;n<t.length-1;n++){const s=t[n],r=t[n+1],o=Math.hypot(r.x-s.x,r.z-s.z),c=Math.max(1,Math.ceil(o/hn.STEP_M));for(let l=0;l<c;l++){const h=l/c;e.push({x:s.x+(r.x-s.x)*h,z:s.z+(r.z-s.z)*h})}}const i=t[t.length-1];return i&&e.push({x:i.x,z:i.z}),e}}const Sw=18,ww=.55,bw=.5,Ew=`
|
|
5569
5573
|
attribute float aSpeed;
|
|
5570
5574
|
uniform float uTime;
|
|
5571
5575
|
uniform float uOverallSpeed;
|
|
@@ -6421,7 +6425,7 @@ void main()
|
|
|
6421
6425
|
vec4 overlay = texture2D(uOverlay, vUv);
|
|
6422
6426
|
${lo}
|
|
6423
6427
|
}
|
|
6424
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Dt(new ki(2,2),this.material))}render(t,e,i,n,s,r){const o=t.getRenderTarget(),c=r??{scene:this.scene,overlay:this.overlay};t.setRenderTarget(c.scene),t.render(e,i),s?.(),(n||r)&&(mi.clearTransparent(t,c.overlay),n?.()),t.setRenderTarget(o),!r&&(this.material.uniforms.uMode.value=tn.Finished,t.render(this.quadScene,this.quadCamera))}resize(t,e){this.scene.setSize(Math.max(1,t),Math.max(1,e)),this.overlay.setSize(Math.max(1,t),Math.max(1,e))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class de{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(t,e){this.maxRatio=de.clamp(t),this.ratio=this.maxRatio,this.timer=e?Ml.create(e):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(t){t-this.lastEditMs>de.SETTLE_MS&&(this.editStreakStartMs=t),this.lastEditMs=t}changing(t){return t-this.lastEditMs<=de.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=de.SUSTAINED_MS}ratioFor(t,e){return this.changing(t)?this.wasChanging?(this.update(t,e),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=de.clamp(t),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const t=Math.floor(this.maxRatio*de.MIN_SHARE_OF_DISPLAY/de.STEP)*de.STEP;return Math.max(de.MIN_RATIO,t)}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 i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(t,i):this.followIntervals(t,e)}followGpu(t,e){if(e>de.GPU_LATE_MS)return this.lower(t,de.LOWER_COOLDOWN_MS);if(e<de.GPU_ROOM_MS)return this.raise(t,de.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 i=this.intervalMs>de.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+de.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=de.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+de.PROBE_EVERY_MS);return}if(i){const n=this.lower(t,de.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=t+de.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=de.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(t,0);return s!==void 0&&(this.probe={sinceMs:t,ratioBefore:n}),s}}lower(t,e){if(!(this.ratio<=this.minimum||t-this.lastChangeMs<e))return this.ratio=Math.max(this.minimum,de.clamp(this.ratio-de.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,de.clamp(this.ratio+de.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(de.MIN_RATIO,Math.round(t/de.STEP)*de.STEP):de.MIN_RATIO}}class Ml{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 Ml(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Ml.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 i=this.pending[e];if(!t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=t.getQueryParameter(i,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}t.deleteQuery(i),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class le{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=le.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 i=t*Math.PI/180,n=e*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(t,e){const i=e*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(i)**2)/n}static parheliaAzimuthDeg(t,e=le.ICE_INDEX_RED){const i=le.minimumDeviationDeg(le.SIDE_PRISM_ANGLE_DEG,le.effectiveIndex(e,t));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(t,e=le.ICE_INDEX_RED){const i=le.parheliaAzimuthDeg(t,e);if(i===void 0)return;const n=t*Math.PI/180,s=Math.sin(n)**2,r=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=le.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=le.ICE_INDEX_RED){if(t<0||t>90-le.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(t*Math.PI/180),n=Math.sqrt(e*e-i*i);if(!(n>=1))return Math.asin(n)*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 le.ringOf("halo22",le.SIDE_PRISM_ANGLE_DEG)}static halo46(){return le.ringOf("halo46",le.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const i=le.minimumDeviationDeg(e,le.ICE_INDEX_RED),n=le.minimumDeviationDeg(e,le.ICE_INDEX_BLUE);return{id:t,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(t,e,i=90,n=0){const s=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*r*o}static formsAt(t,e=0){if(t<=-e)return[];const i=[le.halo22(),le.halo46()],n=t>0?le.parheliaDistanceDeg(t):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:le.parheliaDistanceDeg(t,le.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:le.halo22().angleDeg}),t>0&&i.push({id:"parhelicCircle",angleDeg:t});const s=le.circumzenithalAltitudeDeg(t);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),t>le.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),t<le.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class $i{static get WATER_INDEX_RED(){return gi.indexAt(gi.RED_NM)}static get WATER_INDEX_BLUE(){return gi.indexAt(gi.BLUE_NM)}static radiusDeg(t,e){const i=(e*e-1)/(t*t-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/e),r=2*(n-s)+(t-1)*(Math.PI-2*s),o=2*Math.PI;let c=r%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return $i.bowOf("primary",2,0)}static secondary(){return $i.bowOf("secondary",3,0)}static bowOf(t,e,i){const n=$i.radiusDeg(e,$i.WATER_INDEX_RED),s=$i.radiusDeg(e,$i.WATER_INDEX_BLUE),r=(n+s)/2;return{id:t,radiusDeg:r,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:r-i}}static alexandersBandDeg(){return{fromDeg:$i.primary().redRadiusDeg,toDeg:$i.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[$i.bowOf("primary",2,t),$i.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-$i.FULL_MOON_MAGNITUDE)))}static strength(t,e,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,t)),s=Math.max(0,1-Math.max(0,Math.min(1,e)));return n*s}}class Zi{constructor(t){this.radius=t;const e=Zi.SEGMENTS*Zi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const i=new ue;i.setAttribute("position",new te(this.positions,3)),i.setAttribute("color",new te(this.colors,3)),i.setDrawRange(0,0),this.object=new Dt(i,new gn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:en})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Zi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zi.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,i){this.head=t&&ni(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&ni(e.altitudeDeg,e.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,i=this.tip;if(!e||!i||this.brightness<=0){t.setDrawRange(0,0);return}const n=this.angleBetween(e,i);if(n<=0){t.setDrawRange(0,0);return}const s=n*Zi.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(e,i,h),this.radius),o=h=>this.radius*(Zi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**Zi.FADE_POWER;let l=0;for(let h=1;h<Zi.POINTS;h++){const u=(h-1)/Zi.SEGMENTS,d=h/Zi.SEGMENTS;l=this.pushBand(l,r(u),r(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<Zi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;t=this.push(t,d,m(h,r)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,r)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,r))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=Et.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,t+1}slerp(t,e,i){const n=this.angleBetweenRadians(t,e);if(n<1e-9)return t;const s=Math.sin(n),r=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:t.x*r+e.x*o,y:t.y*r+e.y*o,z:t.z*r+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const i=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,i)))}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 Ow{object=new De;radius;tiers;drawn=[];constructor(t){this.radius=t,this.object.name="satellites",this.tiers=ho.map(e=>{const i=new ds(new ue,Oe.material(e.size));return Oe.track(i),i.frustumCulled=!1,this.object.add(i),i})}set(t,e,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const r of t){const o=i(r.position);if(o<=0)continue;const c=r.magnitude-2.5*Math.log10(o);if(c>e)continue;const l=eo(c,e),h=Wg(l),{x:u,y:d,z:f}=ni(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),[p,v,m]=n(r.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m}),this.drawn.push({satellite:r,direction:new D(u,d,f).normalize()})}this.tiers.forEach((r,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3);c.forEach((d,f)=>{l.set([d.x,d.y,d.z],f*3),h.set([d.r,d.g,d.b],f*3)}),r.geometry.dispose();const u=new ue;u.setAttribute("position",new te(l,3)),u.setAttribute("color",new te(h,3)),r.geometry=u})}get count(){return this.drawn.length}nearest(t,e){let i,n=e;for(const s of this.drawn){const r=s.direction.dot(t);r>n&&(n=r,i=s.satellite)}return i}dispose(){for(const t of this.tiers)t.geometry.dispose(),t.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Ul{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 xa{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:i,velocityKmS:n,seed:s}=t;if(e<=0||i<=0)return[];const r=e*i/36e5,o=new Ul(s),c=Math.floor(r),l=c+(o.next()<r-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=xa.MAX_DURATION_MS-d*(xa.MAX_DURATION_MS-xa.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(t,e){return t.filter(i=>e>=i.t&&e<=i.t+i.durationMs).map(i=>({meteor:i,progress:(e-i.t)/i.durationMs}))}}class Fs{object=new De;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(t){this.radius=t,this.object.name="lightning-bolt",this.core=new gn({color:15659775,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.glow=new gn({color:10466559,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(t,e,i){if(!t||!t.cloudToGround||e<=.01){this.object.visible=!1;return}const n=`${t.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(t,i,n),this.core.color.setHex(15659775).multiplyScalar(Fs.CORE_RELATIVE*Math.min(1,e*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Fs.CORE_RELATIVE*e*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(t,e,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new Ul(t.channelSeed),s=Math.atan2(e,t.distanceM)*180/Math.PI,r=this.channel(n,t.azimuthDeg,s,0,1),o=[r],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=r[Math.floor(n.between(.15,.5)*r.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new Dt(this.ribbon(l,Fs.GLOW_WIDTH_DEG),this.glow)),this.object.add(new Dt(this.ribbon(l,Fs.CORE_WIDTH_DEG),this.core))}channel(t,e,i,n,s){const r=[],o=i-n;let c=e;for(let l=0;l<=Fs.SEGMENTS;l++){const h=i-o*l/Fs.SEGMENTS;r.push({azimuthDeg:c,altitudeDeg:h}),c+=t.between(-1,1)*o*.06*s}return r}ribbon(t,e){const i=new Float32Array(t.length*2*3),n=[],s=this.radius*Math.tan(e*Math.PI/180)/2,r=t.map(c=>{const{x:l,y:h,z:u}=ni(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});r.forEach((c,l)=>{const h=r[Math.min(l+1,r.length-1)],u=r[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<r.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ue;return o.setAttribute("position",new te(i,3)),o.setIndex(n),o}dispose(){for(const t of this.object.children)t.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class oi{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(t){const e=new Ul(t.seed),i=[],{minS:n,maxS:s}=oi.intervalFor(t.intensity??.5);let r=e.between(0,s)*1e3;for(;r<t.durationMs;){const o=e.next()<oi.CLOUD_TO_GROUND_FRACTION,c=oi.MIN_DISTANCE_M,l=oi.MAX_DISTANCE_M,h=Math.sqrt(e.between(c*c,l*l)),u=o?1+Math.floor(e.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:e.between(.4,.9)}),f+=oi.INTERSTROKE_MS*e.between(.5,1.6);i.push({t:r,azimuthDeg:e.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(e.next()*2**31)}),r+=e.between(n,s)*1e3}return i}static intervalFor(t){const e=Math.min(1,Math.max(0,(t-.5)/.5));return{minS:oi.MIN_INTERVAL_S-e*(oi.MIN_INTERVAL_S-oi.SEVERE_MIN_INTERVAL_S),maxS:oi.MAX_INTERVAL_S-e*(oi.MAX_INTERVAL_S-oi.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(t,e){let i=0;for(const n of t.strokes){const s=e-t.t-n.offsetMs;s<0||s>oi.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/oi.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(t){const e=t.strokes[t.strokes.length-1];return t.t+e.offsetMs+oi.STROKE_DECAY_MS*6}static thunderDelayMs(t){return t.distanceM/oi.SOUND_SPEED_M_S*1e3}}class Hi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Hi.ANCHOR_BLUE-Hi.ANCHOR_RED)/(1/(Hi.BLUE_NM*Hi.BLUE_NM)-1/(Hi.RED_NM*Hi.RED_NM));static A=Hi.ANCHOR_RED-Hi.B/(Hi.RED_NM*Hi.RED_NM);static indexAt(t){return Hi.A+Hi.B/(t*t)}}class Ro{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,i,n,s,r){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-e,c=t,l=0):(o=0,c=-i,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-i*c,d=i*o-t*l,f=t*c-e*o,p=s/2,v=r/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,_=Math.cos(g),w=Math.sin(g);this.normals[m*3]=o*_+u*w,this.normals[m*3+1]=c*_+d*w,this.normals[m*3+2]=l*_+f*w,this.offsets[m]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,i,n,s,r,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-i*l,f=i*c-t*h,p=t*l-e*c,v=c*n+d*s-t*this.radius*2,m=l*n+f*s-e*this.radius*2,g=h*n+p*s-i*this.radius*2;let _=-1,w=-1/0,M=1/0;for(let J=0;J<8;J++){const it=this.normals[J*3],ot=this.normals[J*3+1],Vt=this.normals[J*3+2],Qt=it*t+ot*e+Vt*i,qt=this.offsets[J]-(it*v+ot*m+Vt*g);if(Qt>1e-9){const Y=qt/Qt;Y<M&&(M=Y)}else if(Qt<-1e-9){const Y=qt/Qt;Y>w&&(w=Y,_=J)}else if(qt<0)return 0}if(_<0||w>=M)return 0;let S=0;const b=this.normals[_*3],T=this.normals[_*3+1],x=this.normals[_*3+2],A=-(b*t+T*e+x*i),I=fl.reflectance(A,1,r);o[S].x=t+2*A*b,o[S].y=e+2*A*T,o[S].z=i+2*A*x,o[S].weight=I,S++;const C=1/r,P=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let X=C*t+(C*A-P)*b,z=C*e+(C*A-P)*T,N=C*i+(C*A-P)*x,V=v+t*w,k=m+e*w,K=g+i*w,tt=1-I;for(let J=0;J<Ro.MAX_BOUNCES&&tt>Ro.MIN_WEIGHT;J++){let it=-1,ot=1/0;for(let B=0;B<8;B++){const At=this.normals[B*3],Nt=this.normals[B*3+1],Ct=this.normals[B*3+2],yt=At*X+Nt*z+Ct*N;if(yt<=1e-9)continue;const Ft=(this.offsets[B]-(At*V+Nt*k+Ct*K))/yt;Ft>1e-9&&Ft<ot&&(ot=Ft,it=B)}if(it<0)break;const Vt=this.normals[it*3],Qt=this.normals[it*3+1],qt=this.normals[it*3+2],Y=Vt*X+Qt*z+qt*N,rt=r*Math.sqrt(Math.max(0,1-Y*Y));if(V+=X*ot,k+=z*ot,K+=N*ot,rt<1){const B=Math.sqrt(Math.max(0,1-rt*rt)),At=fl.reflectance(Y,r,1);if(o[S].x=r*X-(r*Y-B)*Vt,o[S].y=r*z-(r*Y-B)*Qt,o[S].z=r*N-(r*Y-B)*qt,o[S].weight=tt*(1-At),S++,S>=o.length)return S;tt*=At}const nt=2*Y;X-=nt*Vt,z-=nt*Qt,N-=nt*qt}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Ne{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 Ro;emergent=Array.from({length:Ro.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);radiance=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);scratch=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,i=2654435769){this.seed=i>>>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 n=Ne.WORST_TILT_DEG*(Ne.BEST_TILT_DEG/Ne.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(t){const e=Ne.AZIMUTH_BINS,i=Ne.ALTITUDE_BINS,n=this.tally,s=Ne.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(Ne.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=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,_=(this.random()*2-1)*g,w=(this.random()*2-1)*g,M=4*g*g,S=ci.SAMPLES[this.random()*ci.SAMPLES.length|0],b=this.crystal.trace(p,v,m,_,w,Hi.indexAt(S.wavelengthNm),this.emergent);for(let T=0;T<b;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const I=x.x/A,C=x.y/A,P=x.z/A;if(I*p+C*v+P*m>r)continue;const X=Math.asin(Math.max(-1,Math.min(1,-P))),z=Math.abs(Math.atan2(-C,-I)),N=Math.min(e-1,z/Math.PI*e|0),k=(Math.min(i-1,(X+Math.PI/2)/Math.PI*i|0)*e+N)*3,K=x.weight*M*ci.SAMPLES.length;n[k]+=K*S.r,n[k+1]+=K*S.g,n[k+2]+=K*S.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=Ne.AZIMUTH_BINS,e=Ne.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,i,n){return this.begin(t,e,n),this.trace(i),this.harvest()}toRadiance(t,e){const i=2*Math.PI/t,n=Math.max(1,this.traced),s=4*Ne.REFERENCE_MICRONS*Ne.REFERENCE_MICRONS;for(let r=0;r<e;r++){const o=Math.sin(r/e*Math.PI-Math.PI/2),c=Math.sin((r+1)/e*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<t;h++){const u=(r*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 i=this.scratch,n=this.radiance;i.set(n);for(let r=0;r<e;r++){const o=r*t*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=t*3;for(let r=0;r<e;r++){const o=r>0?-s:0,c=r+1<e?s:0,l=r*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const i of Ne.POPULATIONS)if(e+=i.share,t<=e)return i;return Ne.POPULATIONS[Ne.POPULATIONS.length-1]}orient(t,e){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,r=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i),t.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(s,r,o,n,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),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const i=this.gaussian()*t;if(i>=-1&&i<=1)return i}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 Ti{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new Ne;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const t=Ne.AZIMUTH_BINS,e=Ne.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new Js(this.texels,t,e,_i,ze),this.texture.minFilter=se,this.texture.magFilter=se,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new ae({uniforms:{uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new D},uMap:{value:this.texture},uGain:{value:Ti.GAIN}},vertexShader:`
|
|
6428
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new Dt(new ki(2,2),this.material))}render(t,e,i,n,s,r){const o=t.getRenderTarget(),c=r??{scene:this.scene,overlay:this.overlay};t.setRenderTarget(c.scene),t.render(e,i),s?.(),(n||r)&&(mi.clearTransparent(t,c.overlay),n?.()),t.setRenderTarget(o),!r&&(this.material.uniforms.uMode.value=tn.Finished,t.render(this.quadScene,this.quadCamera))}resize(t,e){this.scene.setSize(Math.max(1,t),Math.max(1,e)),this.overlay.setSize(Math.max(1,t),Math.max(1,e))}dispose(){this.scene.dispose(),this.overlay.dispose(),this.material.dispose(),this.quadScene.children[0].geometry.dispose()}}class de{static MIN_RATIO=1;static STEP=.25;static MIN_SHARE_OF_DISPLAY=.75;static GPU_LATE_MS=12;static GPU_ROOM_MS=6;static INTERVAL_LATE_MS=21;static LOWER_COOLDOWN_MS=750;static RAISE_COOLDOWN_MS=2e3;static PROBE_WATCH_MS=2e3;static PROBE_EVERY_MS=6e3;static PROBE_BACKOFF_MS=3e4;ratio;maxRatio;timer;intervalMs;lastChangeMs=-1/0;nextProbeMs=0;probe;constructor(t,e){this.maxRatio=de.clamp(t),this.ratio=this.maxRatio,this.timer=e?Ml.create(e):void 0}get pixelRatio(){return this.ratio}static SETTLE_MS=400;static SUSTAINED_MS=100;lastEditMs=-1/0;editStreakStartMs=-1/0;wasChanging=!1;noteChange(t){t-this.lastEditMs>de.SETTLE_MS&&(this.editStreakStartMs=t),this.lastEditMs=t}changing(t){return t-this.lastEditMs<=de.SETTLE_MS&&this.lastEditMs-this.editStreakStartMs>=de.SUSTAINED_MS}ratioFor(t,e){return this.changing(t)?this.wasChanging?(this.update(t,e),this.ratio):(this.wasChanging=!0,this.reset(),this.ratio):(this.wasChanging=!1,this.maxRatio)}get timesGpu(){return this.timer!==void 0}set maximum(t){this.maxRatio=de.clamp(t),this.ratio>this.maxRatio&&(this.ratio=this.maxRatio),this.ratio<this.minimum&&(this.ratio=Math.min(this.maxRatio,this.minimum))}get minimum(){const t=Math.floor(this.maxRatio*de.MIN_SHARE_OF_DISPLAY/de.STEP)*de.STEP;return Math.max(de.MIN_RATIO,t)}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 i=this.timer?.poll();if(!(this.timer&&i===void 0))return i!==void 0?this.followGpu(t,i):this.followIntervals(t,e)}followGpu(t,e){if(e>de.GPU_LATE_MS)return this.lower(t,de.LOWER_COOLDOWN_MS);if(e<de.GPU_ROOM_MS)return this.raise(t,de.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 i=this.intervalMs>de.INTERVAL_LATE_MS;if(this.probe){if(i)return this.ratio=this.probe.ratioBefore,this.probe=void 0,this.lastChangeMs=t,this.nextProbeMs=t+de.PROBE_BACKOFF_MS,this.ratio;t-this.probe.sinceMs>=de.PROBE_WATCH_MS&&(this.probe=void 0,this.nextProbeMs=t+de.PROBE_EVERY_MS);return}if(i){const n=this.lower(t,de.LOWER_COOLDOWN_MS);return n!==void 0&&(this.nextProbeMs=t+de.PROBE_EVERY_MS),n}if(this.ratio<this.maxRatio&&t>=this.nextProbeMs&&t-this.lastChangeMs>=de.RAISE_COOLDOWN_MS){const n=this.ratio,s=this.raise(t,0);return s!==void 0&&(this.probe={sinceMs:t,ratioBefore:n}),s}}lower(t,e){if(!(this.ratio<=this.minimum||t-this.lastChangeMs<e))return this.ratio=Math.max(this.minimum,de.clamp(this.ratio-de.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,de.clamp(this.ratio+de.STEP)),this.lastChangeMs=t,this.ratio}static clamp(t){return Number.isFinite(t)?Math.max(de.MIN_RATIO,Math.round(t/de.STEP)*de.STEP):de.MIN_RATIO}}class Ml{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 Ml(t,e):void 0}pending=[];active;smoothedMs;begin(){if(!(this.active||this.pending.length>=Ml.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 i=this.pending[e];if(!t.getQueryParameter(i,t.QUERY_RESULT_AVAILABLE))continue;if(!t.getParameter(this.extension.GPU_DISJOINT_EXT)){const s=t.getQueryParameter(i,t.QUERY_RESULT)/1e6;this.smoothedMs=this.smoothedMs===void 0?s:this.smoothedMs*.8+s*.2}t.deleteQuery(i),this.pending.splice(e,1),e--}}catch{this.pending.length=0}return this.smoothedMs}reset(){this.smoothedMs=void 0}}class le{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=le.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 i=t*Math.PI/180,n=e*Math.sin(i/2);return n>1?Number.NaN:(2*Math.asin(n)-i)*180/Math.PI}static effectiveIndex(t,e){const i=e*Math.PI/180,n=Math.cos(i);return n<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(i)**2)/n}static parheliaAzimuthDeg(t,e=le.ICE_INDEX_RED){const i=le.minimumDeviationDeg(le.SIDE_PRISM_ANGLE_DEG,le.effectiveIndex(e,t));return Number.isFinite(i)?i:void 0}static parheliaDistanceDeg(t,e=le.ICE_INDEX_RED){const i=le.parheliaAzimuthDeg(t,e);if(i===void 0)return;const n=t*Math.PI/180,s=Math.sin(n)**2,r=Math.cos(n)**2*Math.cos(i*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,s+r)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=le.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=le.ICE_INDEX_RED){if(t<0||t>90-le.PLATE_END_FACE_LIMIT_DEG)return;const i=Math.cos(t*Math.PI/180),n=Math.sqrt(e*e-i*i);if(!(n>=1))return Math.asin(n)*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 le.ringOf("halo22",le.SIDE_PRISM_ANGLE_DEG)}static halo46(){return le.ringOf("halo46",le.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const i=le.minimumDeviationDeg(e,le.ICE_INDEX_RED),n=le.minimumDeviationDeg(e,le.ICE_INDEX_BLUE);return{id:t,angleDeg:(i+n)/2,redAngleDeg:i,blueAngleDeg:n}}static strength(t,e,i=90,n=0){const s=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e))),o=i>=0?1:n<=0?0:Math.max(0,1+i/n);return s*r*o}static formsAt(t,e=0){if(t<=-e)return[];const i=[le.halo22(),le.halo46()],n=t>0?le.parheliaDistanceDeg(t):void 0;n!==void 0&&i.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:le.parheliaDistanceDeg(t,le.ICE_INDEX_BLUE)}),i.push({id:"tangentArc",angleDeg:le.halo22().angleDeg}),t>0&&i.push({id:"parhelicCircle",angleDeg:t});const s=le.circumzenithalAltitudeDeg(t);return s!==void 0&&i.push({id:"circumzenithal",angleDeg:s}),t>le.PLATE_END_FACE_LIMIT_DEG&&i.push({id:"circumhorizontal"}),t<le.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&i.push({id:"pillar"}),i}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class $i{static get WATER_INDEX_RED(){return gi.indexAt(gi.RED_NM)}static get WATER_INDEX_BLUE(){return gi.indexAt(gi.BLUE_NM)}static radiusDeg(t,e){const i=(e*e-1)/(t*t-1);if(i<0||i>1)return Number.NaN;const n=Math.acos(Math.sqrt(i)),s=Math.asin(Math.sin(n)/e),r=2*(n-s)+(t-1)*(Math.PI-2*s),o=2*Math.PI;let c=r%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return $i.bowOf("primary",2,0)}static secondary(){return $i.bowOf("secondary",3,0)}static bowOf(t,e,i){const n=$i.radiusDeg(e,$i.WATER_INDEX_RED),s=$i.radiusDeg(e,$i.WATER_INDEX_BLUE),r=(n+s)/2;return{id:t,radiusDeg:r,redRadiusDeg:n,violetRadiusDeg:s,topAltitudeDeg:r-i}}static alexandersBandDeg(){return{fromDeg:$i.primary().redRadiusDeg,toDeg:$i.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[$i.bowOf("primary",2,t),$i.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-$i.FULL_MOON_MAGNITUDE)))}static strength(t,e,i){if(i<=0)return 0;const n=Math.max(0,Math.min(1,t)),s=Math.max(0,1-Math.max(0,Math.min(1,e)));return n*s}}class Zi{constructor(t){this.radius=t;const e=Zi.SEGMENTS*Zi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const i=new ue;i.setAttribute("position",new te(this.positions,3)),i.setAttribute("color",new te(this.colors,3)),i.setDrawRange(0,0),this.object=new Dt(i,new gn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:en})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=Zi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Zi.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,i){this.head=t&&ni(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&ni(e.altitudeDeg,e.azimuthDeg,1),this.brightness=i,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,i=this.tip;if(!e||!i||this.brightness<=0){t.setDrawRange(0,0);return}const n=this.angleBetween(e,i);if(n<=0){t.setDrawRange(0,0);return}const s=n*Zi.SPREAD_FRACTION*Math.PI/180,r=h=>this.scale(this.slerp(e,i,h),this.radius),o=h=>this.radius*(Zi.HEAD_HALF_WIDTH_DEG*Math.PI/180+s*h),c=h=>this.brightness*(1-h)**Zi.FADE_POWER;let l=0;for(let h=1;h<Zi.POINTS;h++){const u=(h-1)/Zi.SEGMENTS,d=h/Zi.SEGMENTS;l=this.pushBand(l,r(u),r(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<Zi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;t=this.push(t,d,m(h,r)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,r)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,r))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=Et.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.55,this.colors[n+1]=s*.75,this.colors[n+2]=s,t+1}slerp(t,e,i){const n=this.angleBetweenRadians(t,e);if(n<1e-9)return t;const s=Math.sin(n),r=Math.sin((1-i)*n)/s,o=Math.sin(i*n)/s;return{x:t.x*r+e.x*o,y:t.y*r+e.y*o,z:t.z*r+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const i=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,i)))}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 Ow{object=new De;radius;tiers;drawn=[];constructor(t){this.radius=t,this.object.name="satellites",this.tiers=ho.map(e=>{const i=new ds(new ue,Oe.material(e.size));return Oe.track(i),i.frustumCulled=!1,this.object.add(i),i})}set(t,e,i,n){const s=this.tiers.map(()=>[]);this.drawn=[];for(const r of t){const o=i(r.position);if(o<=0)continue;const c=r.magnitude-2.5*Math.log10(o);if(c>e)continue;const l=eo(c,e),h=Wg(l),{x:u,y:d,z:f}=ni(r.position.altitudeDeg,r.position.azimuthDeg,this.radius),[p,v,m]=n(r.position,c);s[h].push({x:u,y:d,z:f,r:p,g:v,b:m}),this.drawn.push({satellite:r,direction:new D(u,d,f).normalize()})}this.tiers.forEach((r,o)=>{const c=s[o],l=new Float32Array(c.length*3),h=new Float32Array(c.length*3);c.forEach((d,f)=>{l.set([d.x,d.y,d.z],f*3),h.set([d.r,d.g,d.b],f*3)}),r.geometry.dispose();const u=new ue;u.setAttribute("position",new te(l,3)),u.setAttribute("color",new te(h,3)),r.geometry=u})}get count(){return this.drawn.length}nearest(t,e){let i,n=e;for(const s of this.drawn){const r=s.direction.dot(t);r>n&&(n=r,i=s.satellite)}return i}dispose(){for(const t of this.tiers)t.geometry.dispose(),t.material.dispose();this.object.removeFromParent(),this.drawn=[]}}class Ul{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 xa{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:i,velocityKmS:n,seed:s}=t;if(e<=0||i<=0)return[];const r=e*i/36e5,o=new Ul(s),c=Math.floor(r),l=c+(o.next()<r-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(n-20)/52)),f=xa.MAX_DURATION_MS-d*(xa.MAX_DURATION_MS-xa.MIN_DURATION_MS),p=o.between(5,70);h.push({t:o.between(0,i),durationMs:f*o.between(.7,1.3),fromRadiantDeg:p,bearingDeg:o.between(0,360),lengthDeg:Math.sin(p*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,m)=>v.t-m.t)}return h}static aliveAt(t,e){return t.filter(i=>e>=i.t&&e<=i.t+i.durationMs).map(i=>({meteor:i,progress:(e-i.t)/i.durationMs}))}}class Fs{object=new De;radius;core;glow;flashKey;static CORE_WIDTH_DEG=.06;static GLOW_WIDTH_DEG=.5;static SEGMENTS=28;static CORE_RELATIVE=1e3;constructor(t){this.radius=t,this.object.name="lightning-bolt",this.core=new gn({color:15659775,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.glow=new gn({color:10466559,transparent:!0,opacity:0,blending:Ci,depthWrite:!1,fog:!1}),this.object.visible=!1,this.object.renderOrder=5.95}set(t,e,i){if(!t||!t.cloudToGround||e<=.01){this.object.visible=!1;return}const n=`${t.channelSeed}:${Math.round(i)}`;n!==this.flashKey&&this.build(t,i,n),this.core.color.setHex(15659775).multiplyScalar(Fs.CORE_RELATIVE*Math.min(1,e*1.4)),this.glow.color.setHex(10466559).multiplyScalar(.1*Fs.CORE_RELATIVE*e*.35),this.core.opacity=1,this.glow.opacity=1,this.object.visible=!0}build(t,e,i){this.flashKey=i;for(const l of[...this.object.children])l.geometry.dispose(),this.object.remove(l);const n=new Ul(t.channelSeed),s=Math.atan2(e,t.distanceM)*180/Math.PI,r=this.channel(n,t.azimuthDeg,s,0,1),o=[r],c=1+Math.floor(n.next()*2);for(let l=0;l<c;l++){const h=r[Math.floor(n.between(.15,.5)*r.length)];o.push(this.channel(n,h.azimuthDeg,h.altitudeDeg,h.altitudeDeg*n.between(.3,.7),.5))}for(const l of o)this.object.add(new Dt(this.ribbon(l,Fs.GLOW_WIDTH_DEG),this.glow)),this.object.add(new Dt(this.ribbon(l,Fs.CORE_WIDTH_DEG),this.core))}channel(t,e,i,n,s){const r=[],o=i-n;let c=e;for(let l=0;l<=Fs.SEGMENTS;l++){const h=i-o*l/Fs.SEGMENTS;r.push({azimuthDeg:c,altitudeDeg:h}),c+=t.between(-1,1)*o*.06*s}return r}ribbon(t,e){const i=new Float32Array(t.length*2*3),n=[],s=this.radius*Math.tan(e*Math.PI/180)/2,r=t.map(c=>{const{x:l,y:h,z:u}=ni(c.altitudeDeg,c.azimuthDeg,this.radius);return new D(l,h,u)});r.forEach((c,l)=>{const h=r[Math.min(l+1,r.length-1)],u=r[Math.max(l-1,0)],f=h.clone().sub(u).normalize().cross(c.clone().normalize()).normalize().multiplyScalar(s);if(i.set([c.x+f.x,c.y+f.y,c.z+f.z],l*6),i.set([c.x-f.x,c.y-f.y,c.z-f.z],l*6+3),l<r.length-1){const p=l*2;n.push(p,p+1,p+2,p+1,p+3,p+2)}});const o=new ue;return o.setAttribute("position",new te(i,3)),o.setIndex(n),o}dispose(){for(const t of this.object.children)t.geometry.dispose();this.core.dispose(),this.glow.dispose(),this.object.removeFromParent()}}class oi{static MIN_INTERVAL_S=8;static MAX_INTERVAL_S=25;static SEVERE_MIN_INTERVAL_S=2;static SEVERE_MAX_INTERVAL_S=8;static CLOUD_TO_GROUND_FRACTION=.25;static MIN_DISTANCE_M=1e3;static MAX_DISTANCE_M=15e3;static INTERSTROKE_MS=60;static STROKE_DECAY_MS=40;static SOUND_SPEED_M_S=343;static schedule(t){const e=new Ul(t.seed),i=[],{minS:n,maxS:s}=oi.intervalFor(t.intensity??.5);let r=e.between(0,s)*1e3;for(;r<t.durationMs;){const o=e.next()<oi.CLOUD_TO_GROUND_FRACTION,c=oi.MIN_DISTANCE_M,l=oi.MAX_DISTANCE_M,h=Math.sqrt(e.between(c*c,l*l)),u=o?1+Math.floor(e.next()*4):1,d=[];let f=0;for(let p=0;p<u;p++)d.push({offsetMs:f,intensity:p===0?1:e.between(.4,.9)}),f+=oi.INTERSTROKE_MS*e.between(.5,1.6);i.push({t:r,azimuthDeg:e.between(0,360),distanceM:h,cloudToGround:o,strokes:d,channelSeed:Math.floor(e.next()*2**31)}),r+=e.between(n,s)*1e3}return i}static intervalFor(t){const e=Math.min(1,Math.max(0,(t-.5)/.5));return{minS:oi.MIN_INTERVAL_S-e*(oi.MIN_INTERVAL_S-oi.SEVERE_MIN_INTERVAL_S),maxS:oi.MAX_INTERVAL_S-e*(oi.MAX_INTERVAL_S-oi.SEVERE_MAX_INTERVAL_S)}}static brightnessAt(t,e){let i=0;for(const n of t.strokes){const s=e-t.t-n.offsetMs;s<0||s>oi.STROKE_DECAY_MS*6||(i+=n.intensity*Math.exp(-s/oi.STROKE_DECAY_MS))}return Math.min(1,i)}static endOf(t){const e=t.strokes[t.strokes.length-1];return t.t+e.offsetMs+oi.STROKE_DECAY_MS*6}static thunderDelayMs(t){return t.distanceM/oi.SOUND_SPEED_M_S*1e3}}class Hi{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Hi.ANCHOR_BLUE-Hi.ANCHOR_RED)/(1/(Hi.BLUE_NM*Hi.BLUE_NM)-1/(Hi.RED_NM*Hi.RED_NM));static A=Hi.ANCHOR_RED-Hi.B/(Hi.RED_NM*Hi.RED_NM);static indexAt(t){return Hi.A+Hi.B/(t*t)}}class Ro{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,i,n,s,r){let o=0,c=0,l=0;Math.abs(i)<.9?(o=-e,c=t,l=0):(o=0,c=-i,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-i*c,d=i*o-t*l,f=t*c-e*o,p=s/2,v=r/2;for(let m=0;m<6;m++){const g=n+m*Math.PI/3,_=Math.cos(g),w=Math.sin(g);this.normals[m*3]=o*_+u*w,this.normals[m*3+1]=c*_+d*w,this.normals[m*3+2]=l*_+f*w,this.offsets[m]=p}this.normals[18]=t,this.normals[19]=e,this.normals[20]=i,this.offsets[6]=v,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-i,this.offsets[7]=v,this.radius=Math.hypot(p,v)}get aimRadius(){return this.radius}trace(t,e,i,n,s,r,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-i*l,f=i*c-t*h,p=t*l-e*c,v=c*n+d*s-t*this.radius*2,m=l*n+f*s-e*this.radius*2,g=h*n+p*s-i*this.radius*2;let _=-1,w=-1/0,M=1/0;for(let J=0;J<8;J++){const it=this.normals[J*3],rt=this.normals[J*3+1],Gt=this.normals[J*3+2],Jt=it*t+rt*e+Gt*i,qt=this.offsets[J]-(it*v+rt*m+Gt*g);if(Jt>1e-9){const Y=qt/Jt;Y<M&&(M=Y)}else if(Jt<-1e-9){const Y=qt/Jt;Y>w&&(w=Y,_=J)}else if(qt<0)return 0}if(_<0||w>=M)return 0;let S=0;const b=this.normals[_*3],T=this.normals[_*3+1],x=this.normals[_*3+2],A=-(b*t+T*e+x*i),I=fl.reflectance(A,1,r);o[S].x=t+2*A*b,o[S].y=e+2*A*T,o[S].z=i+2*A*x,o[S].weight=I,S++;const C=1/r,L=Math.sqrt(Math.max(0,1-C*C*(1-A*A)));let W=C*t+(C*A-L)*b,X=C*e+(C*A-L)*T,P=C*i+(C*A-L)*x,B=v+t*w,k=m+e*w,K=g+i*w,tt=1-I;for(let J=0;J<Ro.MAX_BOUNCES&&tt>Ro.MIN_WEIGHT;J++){let it=-1,rt=1/0;for(let z=0;z<8;z++){const At=this.normals[z*3],Nt=this.normals[z*3+1],Ct=this.normals[z*3+2],yt=At*W+Nt*X+Ct*P;if(yt<=1e-9)continue;const Ft=(this.offsets[z]-(At*B+Nt*k+Ct*K))/yt;Ft>1e-9&&Ft<rt&&(rt=Ft,it=z)}if(it<0)break;const Gt=this.normals[it*3],Jt=this.normals[it*3+1],qt=this.normals[it*3+2],Y=Gt*W+Jt*X+qt*P,at=r*Math.sqrt(Math.max(0,1-Y*Y));if(B+=W*rt,k+=X*rt,K+=P*rt,at<1){const z=Math.sqrt(Math.max(0,1-at*at)),At=fl.reflectance(Y,r,1);if(o[S].x=r*W-(r*Y-z)*Gt,o[S].y=r*X-(r*Y-z)*Jt,o[S].z=r*P-(r*Y-z)*qt,o[S].weight=tt*(1-At),S++,S>=o.length)return S;tt*=At}const nt=2*Y;W-=nt*Gt,X-=nt*Jt,P-=nt*qt}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class Ne{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 Ro;emergent=Array.from({length:Ro.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);radiance=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);scratch=new Float32Array(Ne.AZIMUTH_BINS*Ne.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,i=2654435769){this.seed=i>>>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 n=Ne.WORST_TILT_DEG*(Ne.BEST_TILT_DEG/Ne.WORST_TILT_DEG)**this.alignment;this.tilt=n*Math.PI/180}trace(t){const e=Ne.AZIMUTH_BINS,i=Ne.ALTITUDE_BINS,n=this.tally,s=Ne.SOURCE_RADIUS_DEG*Math.PI/180,r=Math.cos(Ne.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=s*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),p=-Math.cos(d)*Math.cos(f),v=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),g=this.crystal.aimRadius,_=(this.random()*2-1)*g,w=(this.random()*2-1)*g,M=4*g*g,S=ci.SAMPLES[this.random()*ci.SAMPLES.length|0],b=this.crystal.trace(p,v,m,_,w,Hi.indexAt(S.wavelengthNm),this.emergent);for(let T=0;T<b;T++){const x=this.emergent[T],A=Math.hypot(x.x,x.y,x.z);if(A<1e-9||x.weight<=0)continue;const I=x.x/A,C=x.y/A,L=x.z/A;if(I*p+C*v+L*m>r)continue;const W=Math.asin(Math.max(-1,Math.min(1,-L))),X=Math.abs(Math.atan2(-C,-I)),P=Math.min(e-1,X/Math.PI*e|0),k=(Math.min(i-1,(W+Math.PI/2)/Math.PI*i|0)*e+P)*3,K=x.weight*M*ci.SAMPLES.length;n[k]+=K*S.r,n[k+1]+=K*S.g,n[k+2]+=K*S.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=Ne.AZIMUTH_BINS,e=Ne.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,i,n){return this.begin(t,e,n),this.trace(i),this.harvest()}toRadiance(t,e){const i=2*Math.PI/t,n=Math.max(1,this.traced),s=4*Ne.REFERENCE_MICRONS*Ne.REFERENCE_MICRONS;for(let r=0;r<e;r++){const o=Math.sin(r/e*Math.PI-Math.PI/2),c=Math.sin((r+1)/e*Math.PI-Math.PI/2),l=1/(i*(c-o)*n*s);for(let h=0;h<t;h++){const u=(r*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 i=this.scratch,n=this.radiance;i.set(n);for(let r=0;r<e;r++){const o=r*t*3;for(let c=0;c<3;c++){let l=i[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?i[u+3]:i[u];n[u]=(l+2*i[u]+d)/4,l=i[u]}}}i.set(n);const s=t*3;for(let r=0;r<e;r++){const o=r>0?-s:0,c=r+1<e?s:0,l=r*s;for(let h=l;h<l+s;h++)n[h]=(i[h+o]+2*i[h]+i[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const i of Ne.POPULATIONS)if(e+=i.share,t<=e)return i;return Ne.POPULATIONS[Ne.POPULATIONS.length-1]}orient(t,e){const i=this.random()*2*Math.PI;let n=this.random()*2*Math.PI,s=0,r=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));s=c*Math.cos(i),r=c*Math.sin(i),t.orientation==="parry"&&(n=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(s,r,o,n,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),i=Math.max(1e-12,this.random()),n=1+Math.log(i+(1-i)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,n))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const i=this.gaussian()*t;if(i>=-1&&i<=1)return i}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 Ti{static RADIUS=880;static RAYS=9e5;static RAYS_PER_BATCH=2e3;static BUDGET_MS=6;static URGENT_BUDGET_MS=40;static ALTITUDE_STEP_DEG=1;static ALIGNMENT_STEP=.05;static LEAP_ALTITUDE_DEG=5;static LEAP_ALIGNMENT=.25;static GAIN=.55;setCloudOffset(t){this.material.uniforms.uFieldOffset.value.copy(t)}object;material;sky=new Ne;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;urgent=!1;workHandle;onRepaint;constructor(){const t=Ne.AZIMUTH_BINS,e=Ne.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new Js(this.texels,t,e,_i,ze),this.texture.minFilter=se,this.texture.magFilter=se,this.texture.wrapS=yi,this.texture.wrapT=yi,this.texture.needsUpdate=!0,this.material=new ae({uniforms:{uSource:{value:new D(0,1,0)},uUp:{value:new D(0,1,0)},uStrength:{value:0},uTint:{value:new D(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uFieldOffset:{value:new D},uMap:{value:this.texture},uGain:{value:Ti.GAIN}},vertexShader:`
|
|
6425
6429
|
varying vec3 vDirection;
|
|
6426
6430
|
void main() {
|
|
6427
6431
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -6450,7 +6454,7 @@ void main()
|
|
|
6450
6454
|
if (ice <= 0.0) discard;
|
|
6451
6455
|
gl_FragColor = vec4(iceHaloLight(dir, ice), 1.0);
|
|
6452
6456
|
}
|
|
6453
|
-
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ue,fog:!1}),this.object=new Dt(new Qe(Ti.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,r){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,r)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ti.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ti.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ti.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ti.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ti.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ti.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ti.URGENT_BUDGET_MS:Ti.BUDGET_MS;do this.sky.trace(Ti.RAYS_PER_BATCH);while(this.sky.tracedRays<Ti.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ti.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Cn.toHalfFloat(e[n]),this.texels[i+1]=Cn.toHalfFloat(e[n+1]),this.texels[i+2]=Cn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class pi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=pi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(pi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=pi.MAX_CONCURRENT*pi.SEGMENTS*pi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ue;e.setAttribute("position",new te(this.positions,3)),e.setAttribute("color",new te(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new gn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:en})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=xa.aliveAt(this.meteors,t).slice(0,pi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:r}of i){const o=this.radiantOf(s);if(!o)continue;const c=ni(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+r*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=w=>v*w**1.6,g=w=>this.onSphere(c,p,d+(u-d)*w),_=w=>pi.RADIUS*((pi.MIN_HALF_WIDTH_DEG+pi.BRIGHT_HALF_WIDTH_DEG*s.brightness*w)*Math.PI/180);for(let w=1;w<pi.POINTS;w++){const M=(w-1)/pi.SEGMENTS,S=w/pi.SEGMENTS;n=this.pushRibbon(n,g(M),g(S),_(M),_(S),m(M),m(S))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=ni(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),r=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,r,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,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<pi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;t=this.push(t,d,m(h,r)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,r)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,r))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=Et.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:t.x*s+e.x*r,y:t.y*s+e.y*r,z:t.z*s+e.z*r}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:(t.x*s+e.x*r)*pi.RADIUS,y:(t.y*s+e.y*r)*pi.RADIUS,z:(t.z*s+e.z*r)*pi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}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 Lh=Math.PI/180;function Ye(a,t,e,i,n=!1){const s=n?new gn({color:new st(...e)}):new Er({color:new st(...e)}),r=new Dt(t,s);return r.position.y=i,r.userData={emissive:n},r.castShadow=!n,r.receiveShadow=!n,a.add(r),r}const Nh=.25,Uw=.002,Fw=100,kw=1500,zw=.25,Bw=1e3,Hw=.15;function Gw(a){const t=/^#([0-9a-f]{6})$/i.exec(a);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 Vw=[.32,.32,.3],u1=[1,.85,.5],Ww=[.25,.25,.25],d1=[1,.97,.85],Xw=[.55,.68,.72],Xn=.03,qn=.05,f1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Oi(a,t){return a?.[t]}function Yn(a,t,e,i,n,s,r,o){if(o===void 0)return;const c=new Er({color:new st(...Xw),transparent:!0,opacity:o/100}),l=new Dt(new an(t,e,i),c);l.position.set(n,s,r),a.add(l)}const un=.05,Oh=[.6,.58,.53],Up=[.5,.5,.48];function rr(a,t,e,i,n,s,r,o){const c=new Er({color:new st(...o),side:Ue}),l=new Dt(new an(t,e,i),c);l.position.set(n,s,r),a.add(l)}function qw(a,t,e,i,n,s,r,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?rr(a,p,v,un,m,o+g,r,c):rr(a,un,v,p,r,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function p1(a,t,e,i,n,s,r,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?rr(a,v,u,un,0,h,m,Oh):rr(a,un,u,v,m,h,0,Oh):qw(a,p,v,u,f,s,m,h,Oh)};d(r,!0,t*2,-e+un),d(o,!0,t*2,e-un),d(c,!1,e*2,-t+un),d(l,!1,e*2,t-un),rr(a,t*2,un,e*2,0,i+un,0,Up),rr(a,t*2,un,e*2,0,n-un,0,Up)}function Ed(a,t,e,i){switch(a){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-Kn};case"front-right":return{x:t-i,z:-Kn};case"behind-left":return{x:-(t-i),z:Kn};case"behind-right":return{x:t-i,z:Kn}}}function m1(a,t,e,i,n,s,r){const o=Rd();o.scale.setScalar(i),o.rotation.y=f1[t];const{x:c,z:l}=Ed(t,n,s,r);o.position.set(c,e,l),a.add(o)}const Ad=6,Td=6,ks=3,qr=1.4,Yr=ks*.5,g1=1.2,v1=.35,Yw=.75,Kw=1.6;function Fp(a,t,e,i){const n=new De,s=Math.max(1,a+1),r=s*ks;Ye(n,new an(Ad,r,Td),[.55,.54,.5],r/2);const o=Ad/2,c=Td/2;for(let l=0;l<s;l++){const h=l*ks+ks/2;Yn(n,qr,Yr,qn,0,h,-c-Xn,Oi(t,"front")),Yn(n,qr,Yr,qn,0,h,c+Xn,Oi(t,"behind")),Yn(n,qn,Yr,qr,-o-Xn,h,0,Oi(t,"left")),Yn(n,qn,Yr,qr,o+Xn,h,0,Oi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);m1(n,e,l*ks,.72,o,c,g1);const h=u=>Oi(t,u)!==void 0?[{main:qr,center:0}]:[];p1(n,o,c,l*ks,(l+1)*ks,Yr,h("front"),h("behind"),h("left"),h("right"))}return n}function kp(){const a=new De,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const r=new Qe(n,10,7);r.scale(1,.85,1),r.translate(e,0,i),Ye(a,r,[.26,.28,.17],s)}return a}function zp(){const a=new De;return Ye(a,new es(.15,.22,2,8),[.32,.22,.14],1),Ye(a,new br(1.4,3,8),[.16,.32,.14],3.5),a}const Bp=.275,$w=.35,Zw=.9,Jw=34,jw=8,Qw=1.4;function Hp(){const a=new De,t=new Qe(Bp,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,$w/Bp,1);const e=vi.repeatOnGrid(t,Jw,Zw,jw,Qw),i=Ye(a,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),a}function Gp(){const a=new De,t=new Qe(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ye(a,t,[.38,.36,.32],0),a}function Vp(a){const t=new De;return Ye(t,new es(.05,.08,5,8),[.28,.28,.3],2.5),Ye(t,new Qe(.25,12,8),a?u1:Vw,5.1,!0),t}const tb=[.08,.08,.08],Os=.8,tr=1,Bn=1.7,Uh=.6,sa=.4,Tc=1.2,Ja=.7,Kn=.5,eb=Bn;function Wp(a,t,e){const i=new De;Ye(i,new an(1.8,1.4,4.2),[.45,.14,.14],.7),Ye(i,new an(Os*2,Uh,tr*2),[.4,.12,.12],Bn);for(const s of[-1.4,1.4])for(const r of[-.95,.95]){const o=Ye(i,new es(.4,.4,.3,12),tb,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=s}const n=a?d1:Ww;for(const s of[-.7,.7])Ye(i,new Qe(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Yn(i,Tc,sa,qn,0,Bn,-tr-Xn,Oi(t,"front")),Yn(i,Tc,sa,qn,0,Bn,tr+Xn,Oi(t,"behind")),Yn(i,qn,sa,Ja,-Os-Xn,Bn,-Kn,Oi(t,"front-left")),Yn(i,qn,sa,Ja,-Os-Xn,Bn,Kn,Oi(t,"behind-left")),Yn(i,qn,sa,Ja,Os+Xn,Bn,-Kn,Oi(t,"front-right")),Yn(i,qn,sa,Ja,Os+Xn,Bn,Kn,Oi(t,"behind-right")),e){m1(i,e,Yw,.5,Os,tr,v1);const s=(c,l)=>{const h=[];return Oi(t,c)!==void 0&&h.push({main:Ja,center:-Kn}),Oi(t,l)!==void 0&&h.push({main:Ja,center:Kn}),h},r=Oi(t,"front")!==void 0?[{main:Tc,center:0}]:[],o=Oi(t,"behind")!==void 0?[{main:Tc,center:0}]:[];p1(i,Os,tr,Bn-Uh/2,Bn+Uh/2,sa,r,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const Xp=new Map;function qp(a,t){if(!a)return;const e=[[a.lengthM,t.lengthM],[a.heightM,t.heightM],[a.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function Fh(a,t){return t>1e-6?a/t:1}const M1=[.95,.9,.82],Yp=[.72,.74,.78];function Kp(){const a=new De;Ye(a,new es(.25,.3,1.5,10),Yp,.75),Ye(a,new Qe(.26,10,8),Yp,1.74);const t=Ye(a,new br(.07,.16,8),M1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,a}function Rd(){const a=new De;Ye(a,new es(.25,.3,1.5,10),[.3,.3,.35],.75),Ye(a,new Qe(.22,10,8),[.62,.52,.46],1.72);const t=Ye(a,new br(.07,.16,8),M1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,a}const ib=17,$p=18.5,kh=[.16,.16,.18];function Zp(){const a=new De,t=Ye(a,new es(1.8,1.8,$p*2,10),kh,0);t.rotation.x=Math.PI/2,Ye(a,new an(ib*2,.5,4.5),kh,0);const e=Ye(a,new an(.4,5.5,4),kh,3);return e.position.z=-$p+2,a}class vi{static groundUnderFootprint(t,e,i,n,s,r=0){const o=vi.sizeOf(t);if(r>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1));let u=-1/0;for(let d=0;d<l;d++){const f=(d/(l-1)-.5)*o.lengthM;for(let p=0;p<h;p++){const v=(p/(h-1)-.5)*o.widthM,m=e+Math.sin(c)*f+Math.cos(c)*v,g=i-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,s(m,g))}}return Number.isFinite(u)?u:s(e,i)}static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Ed(e,Os,tr,v1):Ed(e,Ad/2,Td/2,g1),s=t.kind==="vehicle"?eb:(t.occupiedFloor??0)*ks+Kw,r=(t.headingDeg??0)-f1[e]/Lh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(vi.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const r=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=r.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let _=0;_<n;_++)for(let w=0;w<e;w++,m++){const M=v+_*s,S=p+w*i;for(let b=0;b<l;b++){const T=(m*l+b)*3;u[T]=r.getX(b)+M,u[T+1]=r.getY(b),u[T+2]=r.getZ(b)+S,d[T]=o.getX(b),d[T+1]=o.getY(b),d[T+2]=o.getZ(b)}for(let b=0;b<c.count;b++)f[m*c.count+b]=c.getX(b)+m*l}const g=new ue;return g.setAttribute("position",new _e(u,3)),g.setAttribute("normal",new _e(d,3)),g.setIndex(new Kd(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new D;t.traverse(n=>{const s=n,r=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!r||!o)return;const c=s.geometry.getAttribute("position"),l=new Zt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(r[h*3],0,r[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,r[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const r=n.material;r?.color&&r.color.set(e)})}static build(t,e){const i=t.kind==="building"?Fp(t.floors??X0,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?zp():t.kind==="shrub"?kp():t.kind==="crop"?Hp():t.kind==="mound"?Gp():t.kind==="streetlight"?Vp(e):t.kind==="vehicle"?Wp(e,t.windows,t.witnessSide):t.kind==="aircraft"?Zp():t.kind==="entity"?Kp():Rd();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new De;return i.name=vi.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Lh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e)return new D(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new D(e.widthM===void 0?1:Fh(e.widthM,i.widthM),e.heightM===void 0?1:Fh(e.heightM,i.heightM),e.lengthM===void 0?1:Fh(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??X0)+1):0,n=`${t}:${i}`,s=Xp.get(n);if(s)return s;const r=t==="building"?Fp(i-1,void 0,void 0,void 0):t==="tree"?zp():t==="shrub"?kp():t==="crop"?Hp():t==="mound"?Gp():t==="streetlight"?Vp(!1):t==="vehicle"?Wp(!1,void 0,void 0):t==="aircraft"?Zp():t==="entity"?Kp():Rd(),o=new Mn().setFromObject(r),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),Xp.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&zm(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),r=new De;r.name=vi.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Lh,i.updateMatrixWorld(!0);const o=new Mn().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=qp(e.sizeM,c)??qp(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new D).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),r.add(i),s.parent?(s.parent.add(r),s.removeFromParent()):t.add(r),this.dispose(s)}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 addLights(t,e){for(const i of e??[]){const n=Gw(i.color),s=Ye(t,new Qe(Nh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,r=1){if(!e||e.length===0)return;const o=new Map(e.map(u=>[u.id,u])),c=Math.max(1,n*Uw/Nh),l=Nh*c,h=r/(Math.PI*l*l);for(const u of t.children){if(!(u instanceof Dt))continue;const d=u.userData.lightId;if(!d)continue;const f=o.get(d);if(!f)continue;const p=s>0?Bm(f,i,i+s):m2(f,i)?1:0;u.visible=p>0;const v=u.material,m=u.userData.lightColor;if(m){const g=p*Fw*(f.intensity??1)*h;v.color.setRGB(m[0]*g,m[1]*g,m[2]*g)}u.scale.setScalar(c)}}static setLit(t,e,i,n=1){const[s,r,o]=e==="streetlight"?[kw,zw,u1]:[Bw,Hw,d1],c=i?s*n/(Math.PI*r*r):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const zh="https://ufoathome.org/models/index.json";class nb{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??sb()}async entries(t){const e=await this.load();return t?e.filter(i=>i.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 i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function sb(){const a=`?v=${encodeURIComponent("0.65.2")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==zh?[t,zh]:[zh]).map(e=>e+a)}const ab=[{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 nb}];async function Jp(a){const{GLTFLoader:t}=await Kc(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(a,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${a}: ${s instanceof Error?s.message:String(s)}`)))})}const x1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class Qi{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new ki(2,2),new ae({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:Qi.VERTEX,fragmentShader:Qi.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ci,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*Qi.MIN_ANGLE_RAD),r=Qi.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(Qi.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(Qi.MAX_SHARE*Qi.FILL*Math.PI))}static VERTEX=`
|
|
6457
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ue,fog:!1}),this.object=new Dt(new Qe(Ti.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1;const i=this.material.uniforms;this.deckUniforms={uSource:i.uSource,uUp:i.uUp,uStrength:i.uStrength,uTint:i.uTint,uMap:i.uMap,uGain:i.uGain,uHaloShown:{value:0}}}deckUniforms;shown=!1;hostedByDeck=!1;set hosted(t){this.hostedByDeck=t,this.show(this.shown)}show(t){this.shown=t,this.object.visible=t&&!this.hostedByDeck,this.deckUniforms.uHaloShown.value=t?1:0}get awaitingFirstDisplay(){return this.tracing&&!this.everDisplayed}setUrgent(t){this.urgent=t}set onReady(t){this.onRepaint=t}update(t,e,i,n,s,r){const o=this.material.uniforms;if(i<=0){o.uStrength.value=0,this.show(!1),this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=i,o.uTint.value.set(n[0],n[1],n[2]),o.uIceCover.value=s.cover,o.uIceHeight.value=s.layerHeight,this.show(this.everDisplayed),this.requestMap(e,r)}requestMap(t,e){if(!(!(Math.abs(t-this.mappedAltitudeDeg)<Ti.ALTITUDE_STEP_DEG)||!(Math.abs(e-this.mappedAlignment)<Ti.ALIGNMENT_STEP))){this.next=void 0;return}if(this.tracing){if(this.tracingFor(t,e)){this.next=void 0;return}if(!(!(Math.abs(t-this.pendingAltitudeDeg)<Ti.LEAP_ALTITUDE_DEG)||!(Math.abs(e-this.pendingAlignment)<Ti.LEAP_ALIGNMENT))){this.next={sourceAltitudeDeg:t,alignment:e};return}}this.next=void 0,this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.scheduleWork()}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;next;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Ti.ALTITUDE_STEP_DEG&&Math.abs(e-this.pendingAlignment)<Ti.ALIGNMENT_STEP}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;const e=performance.now(),i=this.urgent?Ti.URGENT_BUDGET_MS:Ti.BUDGET_MS;do this.sky.trace(Ti.RAYS_PER_BATCH);while(this.sky.tracedRays<Ti.RAYS&&performance.now()-e<i);if(this.sky.tracedRays>=Ti.RAYS){this.publish(),this.tracing=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;const s=this.next;s&&this.requestMap(s.sourceAltitudeDeg,s.alignment);return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1,this.next=void 0}publish(){const e=this.sky.harvest().data;for(let i=0,n=0;n<e.length;i+=4,n+=3)this.texels[i]=Cn.toHalfFloat(e[n]),this.texels[i+1]=Cn.toHalfFloat(e[n+1]),this.texels[i+2]=Cn.toHalfFloat(e[n+2]),this.texels[i+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.show(this.material.uniforms.uStrength.value>0),this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class pi{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=pi.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(pi.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const t=pi.MAX_CONCURRENT*pi.SEGMENTS*pi.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new ue;e.setAttribute("position",new te(this.positions,3)),e.setAttribute("color",new te(this.colors,3)),e.setDrawRange(0,0),this.object=new Dt(e,new gn({vertexColors:!0,transparent:!0,blending:Ci,depthWrite:!1,fog:!1,side:en})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,i){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=i}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const i=xa.aliveAt(this.meteors,t).slice(0,pi.MAX_CONCURRENT);let n=0;for(const{meteor:s,progress:r}of i){const o=this.radiantOf(s);if(!o)continue;const c=ni(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=s.fromRadiantDeg+r*s.lengthDeg,d=Math.max(s.fromRadiantDeg,u-s.lengthDeg*.6),f=Math.min(1,(1-r)*2.5),p=this.turn(l,h,s.bearingDeg),v=(.15+.85*s.brightness)*f,m=w=>v*w**1.6,g=w=>this.onSphere(c,p,d+(u-d)*w),_=w=>pi.RADIUS*((pi.MIN_HALF_WIDTH_DEG+pi.BRIGHT_HALF_WIDTH_DEG*s.brightness*w)*Math.PI/180);for(let w=1;w<pi.POINTS;w++){const M=(w-1)/pi.SEGMENTS,S=w/pi.SEGMENTS;n=this.pushRibbon(n,g(M),g(S),_(M),_(S),m(M),m(S))}}e.setDrawRange(0,n),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const i=ni(e.altitudeDeg,e.azimuthDeg,1),[n,s]=this.basisAround(i),r=this.turn(n,s,t.bearingDeg),o=this.onSphere(i,r,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,i,n,s,r,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(i,e))));for(let l=0;l<pi.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,n,h),f=this.across(i,c,s,h),p=this.across(e,c,n,u),v=this.across(i,c,s,u),m=(g,_)=>g===0?_:0;t=this.push(t,d,m(h,r)),t=this.push(t,f,m(h,o)),t=this.push(t,p,m(u,r)),t=this.push(t,f,m(h,o)),t=this.push(t,v,m(u,o)),t=this.push(t,p,m(u,r))}return t}across(t,e,i,n){return{x:t.x+e.x*i*n,y:t.y+e.y*i*n,z:t.z+e.z*i*n}}push(t,e,i){const n=t*3;this.positions[n]=e.x,this.positions[n+1]=e.y,this.positions[n+2]=e.z;const s=Et.relativeOfResponse(Math.max(0,Math.min(1,i)));return this.colors[n]=s*.9,this.colors[n+1]=s*.95,this.colors[n+2]=s,t+1}turn(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:t.x*s+e.x*r,y:t.y*s+e.y*r,z:t.z*s+e.z*r}}onSphere(t,e,i){const n=i*Math.PI/180,s=Math.cos(n),r=Math.sin(n);return{x:(t.x*s+e.x*r)*pi.RADIUS,y:(t.y*s+e.y*r)*pi.RADIUS,z:(t.z*s+e.z*r)*pi.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},i=this.normalise(this.cross(t,e));return[i,this.normalise(this.cross(t,i))]}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 Lh=Math.PI/180;function Ye(a,t,e,i,n=!1){const s=n?new gn({color:new st(...e)}):new Er({color:new st(...e)}),r=new Dt(t,s);return r.position.y=i,r.userData={emissive:n},r.castShadow=!n,r.receiveShadow=!n,a.add(r),r}const Nh=.25,Uw=.002,Fw=100,kw=1500,zw=.25,Bw=1e3,Hw=.15;function Gw(a){const t=/^#([0-9a-f]{6})$/i.exec(a);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 Vw=[.32,.32,.3],u1=[1,.85,.5],Ww=[.25,.25,.25],d1=[1,.97,.85],Xw=[.55,.68,.72],Xn=.03,qn=.05,f1={front:0,behind:Math.PI,left:Math.PI/2,right:-Math.PI/2,"front-left":Math.PI/2,"behind-left":Math.PI/2,"front-right":-Math.PI/2,"behind-right":-Math.PI/2};function Oi(a,t){return a?.[t]}function Yn(a,t,e,i,n,s,r,o){if(o===void 0)return;const c=new Er({color:new st(...Xw),transparent:!0,opacity:o/100}),l=new Dt(new an(t,e,i),c);l.position.set(n,s,r),a.add(l)}const un=.05,Oh=[.6,.58,.53],Up=[.5,.5,.48];function rr(a,t,e,i,n,s,r,o){const c=new Er({color:new st(...o),side:Ue}),l=new Dt(new an(t,e,i),c);l.position.set(n,s,r),a.add(l)}function qw(a,t,e,i,n,s,r,o,c){const l=(i-s)/2,h=(p,v,m,g)=>{p<=0||(t?rr(a,p,v,un,m,o+g,r,c):rr(a,un,v,p,r,o+g,m,c))};h(e,l,0,i/2-l/2),h(e,l,0,-(i/2-l/2));const u=[...n].sort((p,v)=>p.center-v.center);let d=-e/2;for(const p of u){const m=p.center-p.main/2-d;h(m,s,d+m/2,0),d=p.center+p.main/2}const f=e/2-d;h(f,s,d+f/2,0)}function p1(a,t,e,i,n,s,r,o,c,l){const h=(i+n)/2,u=n-i,d=(f,p,v,m)=>{f.length===0?p?rr(a,v,u,un,0,h,m,Oh):rr(a,un,u,v,m,h,0,Oh):qw(a,p,v,u,f,s,m,h,Oh)};d(r,!0,t*2,-e+un),d(o,!0,t*2,e-un),d(c,!1,e*2,-t+un),d(l,!1,e*2,t-un),rr(a,t*2,un,e*2,0,i+un,0,Up),rr(a,t*2,un,e*2,0,n-un,0,Up)}function Ed(a,t,e,i){switch(a){case"front":return{x:0,z:-(e-i)};case"behind":return{x:0,z:e-i};case"left":return{x:-(t-i),z:0};case"right":return{x:t-i,z:0};case"front-left":return{x:-(t-i),z:-Kn};case"front-right":return{x:t-i,z:-Kn};case"behind-left":return{x:-(t-i),z:Kn};case"behind-right":return{x:t-i,z:Kn}}}function m1(a,t,e,i,n,s,r){const o=Rd();o.scale.setScalar(i),o.rotation.y=f1[t];const{x:c,z:l}=Ed(t,n,s,r);o.position.set(c,e,l),a.add(o)}const Ad=6,Td=6,ks=3,qr=1.4,Yr=ks*.5,g1=1.2,v1=.35,Yw=.75,Kw=1.6;function Fp(a,t,e,i){const n=new De,s=Math.max(1,a+1),r=s*ks;Ye(n,new an(Ad,r,Td),[.55,.54,.5],r/2);const o=Ad/2,c=Td/2;for(let l=0;l<s;l++){const h=l*ks+ks/2;Yn(n,qr,Yr,qn,0,h,-c-Xn,Oi(t,"front")),Yn(n,qr,Yr,qn,0,h,c+Xn,Oi(t,"behind")),Yn(n,qn,Yr,qr,-o-Xn,h,0,Oi(t,"left")),Yn(n,qn,Yr,qr,o+Xn,h,0,Oi(t,"right"))}if(e){const l=Math.min(Math.max(i??0,0),s-1);m1(n,e,l*ks,.72,o,c,g1);const h=u=>Oi(t,u)!==void 0?[{main:qr,center:0}]:[];p1(n,o,c,l*ks,(l+1)*ks,Yr,h("front"),h("behind"),h("left"),h("right"))}return n}function kp(){const a=new De,t=[[0,0,.55,.5],[.4,.1,.35,.4],[-.35,-.2,.4,.38],[.1,-.4,.35,.36],[-.15,.4,.3,.34]];for(const[e,i,n,s]of t){const r=new Qe(n,10,7);r.scale(1,.85,1),r.translate(e,0,i),Ye(a,r,[.26,.28,.17],s)}return a}function zp(){const a=new De;return Ye(a,new es(.15,.22,2,8),[.32,.22,.14],1),Ye(a,new br(1.4,3,8),[.16,.32,.14],3.5),a}const Bp=.275,$w=.35,Zw=.9,Jw=34,jw=8,Qw=1.4;function Hp(){const a=new De,t=new Qe(Bp,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,$w/Bp,1);const e=vi.repeatOnGrid(t,Jw,Zw,jw,Qw),i=Ye(a,e,[.26,.28,.22],0);return i.castShadow=!0,i.userData.cropBasePositions=e.getAttribute("position").array.slice(),i.userData.cropVerticesPerClump=t.getAttribute("position").count,t.dispose(),a}function Gp(){const a=new De,t=new Qe(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ye(a,t,[.38,.36,.32],0),a}function Vp(a){const t=new De;return Ye(t,new es(.05,.08,5,8),[.28,.28,.3],2.5),Ye(t,new Qe(.25,12,8),a?u1:Vw,5.1,!0),t}const tb=[.08,.08,.08],Os=.8,tr=1,Bn=1.7,Uh=.6,sa=.4,Tc=1.2,Ja=.7,Kn=.5,eb=Bn;function Wp(a,t,e){const i=new De;Ye(i,new an(1.8,1.4,4.2),[.45,.14,.14],.7),Ye(i,new an(Os*2,Uh,tr*2),[.4,.12,.12],Bn);for(const s of[-1.4,1.4])for(const r of[-.95,.95]){const o=Ye(i,new es(.4,.4,.3,12),tb,.4);o.rotation.z=Math.PI/2,o.position.x=r,o.position.z=s}const n=a?d1:Ww;for(const s of[-.7,.7])Ye(i,new Qe(.15,8,6),n,.7,!0).position.set(s,.7,-2.1);if(Yn(i,Tc,sa,qn,0,Bn,-tr-Xn,Oi(t,"front")),Yn(i,Tc,sa,qn,0,Bn,tr+Xn,Oi(t,"behind")),Yn(i,qn,sa,Ja,-Os-Xn,Bn,-Kn,Oi(t,"front-left")),Yn(i,qn,sa,Ja,-Os-Xn,Bn,Kn,Oi(t,"behind-left")),Yn(i,qn,sa,Ja,Os+Xn,Bn,-Kn,Oi(t,"front-right")),Yn(i,qn,sa,Ja,Os+Xn,Bn,Kn,Oi(t,"behind-right")),e){m1(i,e,Yw,.5,Os,tr,v1);const s=(c,l)=>{const h=[];return Oi(t,c)!==void 0&&h.push({main:Ja,center:-Kn}),Oi(t,l)!==void 0&&h.push({main:Ja,center:Kn}),h},r=Oi(t,"front")!==void 0?[{main:Tc,center:0}]:[],o=Oi(t,"behind")!==void 0?[{main:Tc,center:0}]:[];p1(i,Os,tr,Bn-Uh/2,Bn+Uh/2,sa,r,o,s("front-left","behind-left"),s("front-right","behind-right"))}return i}const Xp=new Map;function qp(a,t){if(!a)return;const e=[[a.lengthM,t.lengthM],[a.heightM,t.heightM],[a.widthM,t.widthM]];for(const[i,n]of e)if(i!==void 0&&n>1e-6)return i/n}function Fh(a,t){return t>1e-6?a/t:1}const M1=[.95,.9,.82],Yp=[.72,.74,.78];function Kp(){const a=new De;Ye(a,new es(.25,.3,1.5,10),Yp,.75),Ye(a,new Qe(.26,10,8),Yp,1.74);const t=Ye(a,new br(.07,.16,8),M1,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,a}function Rd(){const a=new De;Ye(a,new es(.25,.3,1.5,10),[.3,.3,.35],.75),Ye(a,new Qe(.22,10,8),[.62,.52,.46],1.72);const t=Ye(a,new br(.07,.16,8),M1,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,a}const ib=17,$p=18.5,kh=[.16,.16,.18];function Zp(){const a=new De,t=Ye(a,new es(1.8,1.8,$p*2,10),kh,0);t.rotation.x=Math.PI/2,Ye(a,new an(ib*2,.5,4.5),kh,0);const e=Ye(a,new an(.4,5.5,4),kh,3);return e.position.z=-$p+2,a}class vi{static groundUnderFootprint(t,e,i,n,s,r=0){const o=vi.sizeOf(t);if(r>o.heightM)return s(e,i);const c=(n??0)*Math.PI/180,l=Math.min(21,Math.max(2,Math.ceil(o.lengthM/.75)+1)),h=Math.min(21,Math.max(2,Math.ceil(o.widthM/.75)+1));let u=-1/0;for(let d=0;d<l;d++){const f=(d/(l-1)-.5)*o.lengthM;for(let p=0;p<h;p++){const v=(p/(h-1)-.5)*o.widthM,m=e+Math.sin(c)*f+Math.cos(c)*v,g=i-Math.cos(c)*f+Math.sin(c)*v;u=Math.max(u,s(m,g))}}return Number.isFinite(u)?u:s(e,i)}static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:i,z:n}=t.kind==="vehicle"?Ed(e,Os,tr,v1):Ed(e,Ad/2,Td/2,g1),s=t.kind==="vehicle"?eb:(t.occupiedFloor??0)*ks+Kw,r=(t.headingDeg??0)-f1[e]/Lh,o=this.scaleFor(t);return{x:i*o.x,z:n*o.z,eyeY:s*o.y,headingDeg:r}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(vi.BODY_NAME)??t}static repeatOnGrid(t,e,i,n,s){const r=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=r.count,h=e*n,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),p=-((e-1)*i)/2,v=-((n-1)*s)/2;let m=0;for(let _=0;_<n;_++)for(let w=0;w<e;w++,m++){const M=v+_*s,S=p+w*i;for(let b=0;b<l;b++){const T=(m*l+b)*3;u[T]=r.getX(b)+M,u[T+1]=r.getY(b),u[T+2]=r.getZ(b)+S,d[T]=o.getX(b),d[T+1]=o.getY(b),d[T+2]=o.getZ(b)}for(let b=0;b<c.count;b++)f[m*c.count+b]=c.getX(b)+m*l}const g=new ue;return g.setAttribute("position",new _e(u,3)),g.setAttribute("normal",new _e(d,3)),g.setIndex(new Kd(f,1)),g}static fitCropToGround(t,e){t.updateMatrixWorld(!0);const i=new D;t.traverse(n=>{const s=n,r=s.userData.cropBasePositions,o=s.userData.cropVerticesPerClump;if(!s.isMesh||!r||!o)return;const c=s.geometry.getAttribute("position"),l=new Zt().copy(s.matrixWorld).invert();for(let h=0;h<c.count;h+=o){i.set(r[h*3],0,r[h*3+2]).applyMatrix4(s.matrixWorld),i.y=e(i.x,i.z),i.applyMatrix4(l);for(let u=h;u<h+o;u++)c.setY(u,r[u*3+1]+i.y)}c.needsUpdate=!0,s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere()})}static paint(t,e){t.traverse(i=>{const n=i,s=n.userData;if(!n.isMesh||s?.emissive)return;const r=n.material;r?.color&&r.color.set(e)})}static build(t,e){const i=t.kind==="building"?Fp(t.floors??X0,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?zp():t.kind==="shrub"?kp():t.kind==="crop"?Hp():t.kind==="mound"?Gp():t.kind==="streetlight"?Vp(e):t.kind==="vehicle"?Wp(e,t.windows,t.witnessSide):t.kind==="aircraft"?Zp():t.kind==="entity"?Kp():Rd();t.color&&this.paint(i,t.color);const n=this.scaleFor(t),s=new De;return i.name=vi.BODY_NAME,i.scale.copy(n),s.add(i),t.headingDeg!==void 0&&(s.rotation.y=-t.headingDeg*Lh),this.addLights(s,t.lights),s}static scaleFor(t){const e=t.sizeM;if(!e)return new D(1,1,1);const i=this.naturalSize(t.kind,t.floors);return new D(e.widthM===void 0?1:Fh(e.widthM,i.widthM),e.heightM===void 0?1:Fh(e.heightM,i.heightM),e.lengthM===void 0?1:Fh(e.lengthM,i.lengthM))}static naturalSize(t,e){const i=t==="building"?Math.max(1,(e??X0)+1):0,n=`${t}:${i}`,s=Xp.get(n);if(s)return s;const r=t==="building"?Fp(i-1,void 0,void 0,void 0):t==="tree"?zp():t==="shrub"?kp():t==="crop"?Hp():t==="mound"?Gp():t==="streetlight"?Vp(!1):t==="vehicle"?Wp(!1,void 0,void 0):t==="aircraft"?Zp():t==="entity"?Kp():Rd(),o=new Mn().setFromObject(r),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(r),Xp.set(n,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&zm(t.kind))}static applyModel(t,e,i,n={}){const s=this.bodyOf(t),r=new De;r.name=vi.BODY_NAME,i.rotation.y=-(n.headingOffsetDeg??0)*Lh,i.updateMatrixWorld(!0);const o=new Mn().setFromObject(i),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=qp(e.sizeM,c)??qp(n.depictedSizeM,c)??1;i.scale.multiplyScalar(l);const h=o.getCenter(new D).multiplyScalar(l);i.position.x-=h.x,i.position.z-=h.z,i.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,i.traverse(u=>{u instanceof Dt&&(u.castShadow=!0,u.receiveShadow=!0)}),r.add(i),s.parent?(s.parent.add(r),s.removeFromParent()):t.add(r),this.dispose(s)}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 addLights(t,e){for(const i of e??[]){const n=Gw(i.color),s=Ye(t,new Qe(Nh,8,6),n,i.offsetM.y,!0);s.position.set(i.offsetM.x,i.offsetM.y,i.offsetM.z),s.userData={emissive:!0,lightId:i.id,lightColor:n},s.visible=!1}}static setLights(t,e,i,n,s=0,r=1){if(!e||e.length===0)return;const o=new Map(e.map(u=>[u.id,u])),c=Math.max(1,n*Uw/Nh),l=Nh*c,h=r/(Math.PI*l*l);for(const u of t.children){if(!(u instanceof Dt))continue;const d=u.userData.lightId;if(!d)continue;const f=o.get(d);if(!f)continue;const p=s>0?Bm(f,i,i+s):m2(f,i)?1:0;u.visible=p>0;const v=u.material,m=u.userData.lightColor;if(m){const g=p*Fw*(f.intensity??1)*h;v.color.setRGB(m[0]*g,m[1]*g,m[2]*g)}u.scale.setScalar(c)}}static setLit(t,e,i,n=1){const[s,r,o]=e==="streetlight"?[kw,zw,u1]:[Bw,Hw,d1],c=i?s*n/(Math.PI*r*r):0,l=[o[0]*c,o[1]*c,o[2]*c];t.traverse(h=>{const u=h.userData;!(h instanceof Dt)||!u.emissive||u.lightId||h.material.color.setRGB(...l)})}static dispose(t){t.traverse(e=>{if(!(e instanceof Dt))return;e.geometry.dispose();const i=e.material;for(const n of Array.isArray(i)?i:[i])n.dispose()})}}const zh="https://ufoathome.org/models/index.json";class nb{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??sb()}async entries(t){const e=await this.load();return t?e.filter(i=>i.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 i=await e.json();return Array.isArray(i?.models)?i.models.map(({file:n,...s})=>({...s,url:new URL(n,t).href})):void 0}catch{return}}}function sb(){const a=`?v=${encodeURIComponent("0.65.3")}`,t=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return(t&&t!==zh?[t,zh]:[zh]).map(e=>e+a)}const ab=[{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 nb}];async function Jp(a){const{GLTFLoader:t}=await Kc(async()=>{const{GLTFLoader:i}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:i}},[],import.meta.url),e=new t;return new Promise((i,n)=>{e.load(a,s=>i(Object.assign(s.scene,{animations:s.animations})),void 0,s=>n(new Error(`Could not load 3D model ${a}: ${s instanceof Error?s.message:String(s)}`)))})}const x1=["ellipsoid","sphere","disc","cylinder","cone","box","torus","figure"];class Qi{static MIN_ANGLE_RAD=.002;static FILL=(1-Math.exp(-4))/4;static MAX_SHARE=.3;mesh;constructor(t,e){this.mesh=new Dt(new ki(2,2),new ae({uniforms:{uColor:{value:new st(0,0,0)},uRadius:{value:1}},vertexShader:Qi.VERTEX,fragmentShader:Qi.FRAGMENT,transparent:!0,depthWrite:!1,blending:Ci,toneMapped:!1})),this.mesh.name=t,this.mesh.frustumCulled=!1,this.mesh.renderOrder=e,this.mesh.visible=!1}shine(t,e,i){this.mesh.visible=!0,this.mesh.position.set(t.x,t.y,t.z),this.mesh.material.uniforms.uRadius.value=e,this.mesh.material.uniforms.uColor.value.setRGB(i[0],i[1],i[2])}hide(){this.mesh.visible=!1}dispose(){this.mesh.geometry.dispose(),this.mesh.material.dispose()}static spread(t,e,i,n){const s=Math.max(t,n*Qi.MIN_ANGLE_RAD),r=Qi.FILL*Math.PI*s*s;return{radiusM:s,luminanceCdM2:i*Math.min(Qi.MAX_SHARE,e/r)}}static conserving(t){return Math.sqrt(t/(Qi.MAX_SHARE*Qi.FILL*Math.PI))}static VERTEX=`
|
|
6454
6458
|
uniform float uRadius;
|
|
6455
6459
|
varying vec2 vOffset;
|
|
6456
6460
|
void main() {
|
|
@@ -6594,7 +6598,7 @@ void main()
|
|
|
6594
6598
|
`+n.vertexShader,n.vertexShader=n.vertexShader.replace("#include <project_vertex>",`#include <project_vertex>
|
|
6595
6599
|
cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let s=`varying vec3 cloudPoint;
|
|
6596
6600
|
`,r="";e.forEach((o,c)=>{const l=`cloud${c}_`;for(const[h,u]of Object.entries(o.uniforms))n.uniforms[l+h]=u;s+=JS(l),r+=`diffuseColor.a *= ${l}transmissionAt(normalize(cloudPoint), length(cloudPoint));
|
|
6597
|
-
`}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",r+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new D;up=new D;lookAt=new Zt;vertex=new D;centre=new D;right=new D;above=new D;set(t,e){this.placed=t,this.frame=e;const i=new Set(t.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of t){let s=this.meshes.get(n.sourceId);s||(s=new Dt(new ki(1,1,bn.SEGMENTS,bn.SEGMENTS),new gn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(y1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=rb+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,e)}}place(t,e,i){const n=this.frame;if(n)for(const s of this.placed){const r=this.meshes.get(s.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(bn.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<bn.FURTHEST_NDC&&Math.abs(d.ndcY)<bn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(r,t,e,n,o,l,h,s.distanceM):this.flat(r,t,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(t,e,i,n,s,r,o,c){const l=r-s.width/2,h=o-s.height/2,u=t.geometry.attributes.position,d=bn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(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(Re.sizeMAt(c,n.projection.pxToDeg(s.width)),Re.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(t,e,i,n,s){const r=t.geometry.attributes.position,o=bn.SEGMENTS,c=Re.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Re.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,s),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),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.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 i=t.azimuthDeg*Math.PI/180,n=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}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,i){const{shape:n}=e,s=xo.paintExtent(n),r=e.ghost?3:0,o={x:s.x-r,y:s.y-r,width:s.width+2*r,height:s.height+2*r};this.extents.set(e.sourceId,o);const c=`${bn.signatureOf(n,i)}|${e.ghost?"ghost":""}`;if(this.signatures.get(e.sourceId)===c&&t.material.map)return;this.signatures.set(e.sourceId,c);const l=Math.min(i.scale,ob/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=t.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new xo(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,e.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new ws(f);g.colorSpace=Fi,g.minFilter=se,g.generateMipmaps=!1,t.material.map=g,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:i}=t;return JSON.stringify([t.kind,Math.round(i.width*10),Math.round(i.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=[]}}const _1=3,Dc=800,Kr=Math.PI/180;class fa{constructor(t,e,i=fa.fetchImage){this.scene=t,this.onImageLoaded=e,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(t,e=this.views){this.references=t,this.views=e;const i=new Set(t.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const r=t.find(o=>o.id===n);r&&r.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of t){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(t){this.shown=t;for(const e of this.meshes.values())e.visible=t&&this.opacityOf(e.userData.id)>0}setView(t,e){this.views.set(t,e);const i=this.meshes.get(t);i&&this.applyOpacity(i,t)}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}place(t){for(const e of this.meshes.values())e.visible&&(e.position.copy(t.position),e.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Dc:0}directionOfPixel(t,e,i,n){const s=this.images.get(t.id),r=s?s.width/s.height:1,o=Math.tan(t.registration.fovDeg/2*Kr),c=o*r;return n.set((e*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(fa.orientation(t))}aspectOf(t){const e=this.images.get(t);return e?e.width/e.height:void 0}failedToLoad(t){return this.failed.has(t)}load(t){const e=t.src;if(this.loading.has(t.id)||this.failed.has(e))return;const i=this.loadImage(e).then(n=>{this.loading.delete(t.id);const s=this.references.find(r=>r.id===t.id);if(!s||s.src!==e){n.texture.dispose();return}n.texture.userData.src=e,this.images.set(t.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(t.id),this.failed.add(e)});this.loading.set(t.id,i)}static async fetchImage(t){const e=await fetch(t);if(!e.ok)throw new Error(`${t}: ${e.status}`);const i=await createImageBitmap(await e.blob(),{imageOrientation:"flipY"}),n=new xi(i);return n.flipY=!1,n.colorSpace=Fi,n.minFilter=se,n.magFilter=se,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(t,e){const i=fa.signatureOf(t,e);let n=this.meshes.get(t.id);if(n&&this.signatures.get(t.id)===i){this.applyOpacity(n,t.id);return}n&&(this.dispose(n),this.meshes.delete(t.id)),n=new Dt(fa.geometryOf(t,e),new gn({map:e.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),t.kind==="panorama"&&(n.material.side=Ue),n.frustumCulled=!1,n.layers.set(_1),n.userData.id=t.id,n.quaternion.copy(fa.orientation(t)),this.scene.add(n),this.meshes.set(t.id,n),this.signatures.set(t.id,i),this.applyOpacity(n,t.id)}static geometryOf(t,e){if(t.kind==="panorama"){const r=new Qe(Dc,64,32,Math.PI/2,Math.PI*2),o=r.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,r}const i=2*Dc*Math.tan(t.registration.fovDeg/2*Kr),n=i*(e.width/Math.max(e.height,1)),s=new ki(n,i);return s.translate(0,0,-Dc),s}static orientation(t){const{headingDeg:e,pitchDeg:i,rollDeg:n}=t.registration,s=new Pe;return s.rotation.set(i*Kr,-e*Kr,-(n??0)*Kr,"YXZ"),s.quaternion}opacityOf(t){const e=this.references.find(n=>n.id===t);return this.views.get(t)?.opacity??e?.opacity??0}applyOpacity(t,e){const i=this.opacityOf(e);t.material.opacity=i,t.visible=this.shown&&i>0}static signatureOf(t,e){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:r}=t.registration;return[t.kind,t.src,e.width,e.height,i,n,s??0,r].join("|")}dispose(t){this.scene.remove(t),t.geometry.dispose(),t.material.dispose()}disposeAll(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear();for(const t of this.images.values())t.texture.dispose();this.images.clear()}}class Ot{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(t,e)=>410+20*e);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(t={}){const e=Ot.WAVELENGTHS_NM.length,i=t.aerosolOpticalDepth??Ot.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=t.ozoneDobson??Ot.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(e),this.aerosolScattering=new Float64Array(e),this.aerosolExtinction=new Float64Array(e),this.ozoneAbsorption=new Float64Array(e);const s=n*2687e17/Ot.OZONE_HALF_WIDTH_M;for(let r=0;r<e;r++){const o=Ot.WAVELENGTHS_NM[r];this.rayleighScattering[r]=Ot.rayleighAt(o);const c=i/Ot.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[r]=c,this.aerosolScattering[r]=c*Ot.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[r]=Ot.OZONE_CROSS_SECTION[r]*1e-25*s}}static rayleighAt(t){const e=t/1e3,i=1/(e*e),n=e*e;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(t){return Math.exp(-Math.max(t,0)/Ot.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(t){return Math.exp(-Math.max(t,0)/Ot.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(t){return Math.max(0,1-Math.abs(t-Ot.OZONE_PEAK_ALTITUDE_M)/Ot.OZONE_HALF_WIDTH_M)}static rayleighPhase(t){return 3/(16*Math.PI)*(1+t*t)}static aerosolPhase(t,e=Ot.AEROSOL_ASYMMETRY){const i=e*e;return 3/(8*Math.PI)*(1-i)*(1+t*t)/((2+i)*Math.pow(Math.max(1+i-2*e*t,1e-6),1.5))}}class Gt{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new ys;camera=new In(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(t){this.renderer=t,this.supported=t.capabilities.isWebGL2&&t.extensions.has("EXT_color_buffer_float"),this.transmittance=new je(Gt.TRANSMITTANCE_WIDTH,Gt.TRANSMITTANCE_HEIGHT,{count:4,type:ze,minFilter:se,magFilter:se,depthBuffer:!1}),this.multiple=new je(Gt.MULTIPLE_SIZE,Gt.MULTIPLE_ROWS,{count:4,type:Di,minFilter:we,magFilter:we,depthBuffer:!1});const e=()=>new je(Gt.SKY_VIEW_WIDTH,Gt.SKY_VIEW_HEIGHT,{type:Di,minFilter:we,magFilter:we,depthBuffer:!1});this.sunView=e(),this.moonView=e();const i=Gt.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(r,o={})=>new Eg({glslVersion:rl,uniforms:{...i,...n,...o},vertexShader:Gt.VERTEX,fragmentShader:r,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Gt.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Gt.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Gt.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ot.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new Dt(new ki(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Gt.MULTIPLE_ROWS)}setMedium(t){const e=[t.rayleighScattering,t.aerosolScattering,t.aerosolExtinction,t.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(e===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=e;const i=(n,s)=>{const r=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)r[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",t.rayleighScattering),i("uAerosolScattering",t.aerosolScattering),i("uAerosolExtinction",t.aerosolExtinction),i("uOzone",t.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(t){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const e=Gt.shared.get(this.mediumKey);if(e&&e!=="building")return this.adopt(e),!0;if(e==="building"&&!this.building)return!1;e||(Gt.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,t);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Gt.MULTIPLE_SIZE,r=Gt.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Gt.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,r,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=r,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(t){this.building=!1;try{const e=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===t?Gt.shared.set(t,{transmittance:e,multiple:i}):Gt.shared.delete(t)}catch{Gt.shared.delete(t)}}async readRaw(t,e,i){const n=new i(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n,void 0,e),n}adopt(t){const e=(s,r,o,c)=>{const l=new Js(s,r,o,_i,c?ze:Di);return l.minFilter=l.magFilter=c?se:we,l.needsUpdate=!0,l},i=t.transmittance.map(s=>e(s,Gt.TRANSMITTANCE_WIDTH,Gt.TRANSMITTANCE_HEIGHT,!0)),n=t.multiple.map(s=>e(s,Gt.MULTIPLE_SIZE,Gt.MULTIPLE_ROWS,!1));i.forEach((s,r)=>this.tableUniforms[`uT${r}`].value=s),n.forEach((s,r)=>this.tableUniforms[`uM${r}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const t of this.adopted)t.dispose();this.adopted=void 0;for(let t=0;t<4;t++)this.tableUniforms[`uT${t}`].value=this.transmittance.textures[t],this.tableUniforms[`uM${t}`].value=this.multiple.textures[t]}}abandonBuilding(){this.building&&(this.building=!1,Gt.shared.get(this.mediumKey)==="building"&&Gt.shared.delete(this.mediumKey))}renderSkyViews(t,e,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ot.GROUND_RADIUS_M+Math.max(t,2),s.uSourceMu.value=Math.sin(e*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(t,e,i){const n=Ot.GROUND_RADIUS_M+Math.max(t,2),s=Ot.GROUND_RADIUS_M,r=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-r,c=e<o?.5*(1-Math.sqrt(Math.max(1-e/o,0))):.5+.5*Math.sqrt(Math.min((e-o)/r,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(t,e){if(t==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,e),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,e),Float32Array.from(n,s=>Cn.fromHalfFloat(s))}readSkyViewNow(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(e,0,0,e.width,e.height,i),i}async readSkyView(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(t,e){this.quad.material=t,this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const t=()=>[new ie,new ie,new ie,new ie],e=(i,n)=>{const s=t();return Ot.WAVELENGTHS_NM.forEach((r,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(r)*n*Ot.WAVELENGTH_STEP_NM*Ot.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:t()},uAerosolScattering:{value:t()},uAerosolExtinction:{value:t()},uOzone:{value:t()},uCieX:{value:e(i=>ci.colourMatching(i)[0],683)},uCieY:{value:e(i=>ci.colourMatching(i)[1],683)},uCieZ:{value:e(i=>ci.colourMatching(i)[2],683)},uScotopic:{value:e(i=>ci.scotopic(i),1700)}}}static VERTEX=`
|
|
6601
|
+
`}),n.fragmentShader=s+n.fragmentShader,n.fragmentShader=n.fragmentShader.replace("#include <opaque_fragment>",r+"#include <opaque_fragment>")},t.needsUpdate=!0}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new D;up=new D;lookAt=new Zt;vertex=new D;centre=new D;right=new D;above=new D;set(t,e){this.placed=t,this.frame=e;const i=new Set(t.map(n=>n.sourceId));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n),this.extents.delete(n));for(const n of t){let s=this.meshes.get(n.sourceId);s||(s=new Dt(new ki(1,1,bn.SEGMENTS,bn.SEGMENTS),new gn({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),this.configureCloudMaterial(s.material),s.frustumCulled=!1,s.layers.set(y1),this.scene.add(s),this.meshes.set(n.sourceId,s)),s.renderOrder=rb+n.renderOrder,s.visible=!n.hidden&&n.shape.transparency<1,s.visible&&this.paint(s,n,e)}}place(t,e,i){const n=this.frame;if(n)for(const s of this.placed){const r=this.meshes.get(s.sourceId);if(!r||!r.visible)continue;const o=this.extents.get(s.sourceId);if(!o)continue;const{bounds:c}=s.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(s.aim){const d=i(bn.directionOf(s.aim,this.direction));d&&Math.abs(d.ndcX)<bn.FURTHEST_NDC&&Math.abs(d.ndcY)<bn.FURTHEST_NDC?(l=(d.ndcX+1)/2*n.canvasWidthPx,h=(1-d.ndcY)/2*n.canvasHeightPx):u=!1}u?this.curve(r,t,e,n,o,l,h,s.distanceM):this.flat(r,t,n,o,s.distanceM)}}static FURTHEST_NDC=4;curve(t,e,i,n,s,r,o,c){const l=r-s.width/2,h=o-s.height/2,u=t.geometry.attributes.position,d=bn.SEGMENTS;let f=0;for(let p=0;p<=d;p++){const v=h+p/d*s.height;for(let m=0;m<=d;m++){const g=l+m/d*s.width;i(g/n.canvasWidthPx*2-1,-(v/n.canvasHeightPx*2-1),this.direction),this.vertex.copy(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(Re.sizeMAt(c,n.projection.pxToDeg(s.width)),Re.sizeMAt(c,n.projection.pxToDeg(s.height)),1)}flat(t,e,i,n,s){const r=t.geometry.attributes.position,o=bn.SEGMENTS,c=Re.sizeMAt(s,i.projection.pxToDeg(n.width)),l=Re.sizeMAt(s,i.projection.pxToDeg(n.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,s),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),r.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}r.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 i=t.azimuthDeg*Math.PI/180,n=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(i)*Math.cos(n),Math.sin(n),-Math.cos(i)*Math.cos(n))}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,i){const{shape:n}=e,s=xo.paintExtent(n),r=e.ghost?3:0,o={x:s.x-r,y:s.y-r,width:s.width+2*r,height:s.height+2*r};this.extents.set(e.sourceId,o);const c=`${bn.signatureOf(n,i)}|${e.ghost?"ghost":""}`;if(this.signatures.get(e.sourceId)===c&&t.material.map)return;this.signatures.set(e.sourceId,c);const l=Math.min(i.scale,ob/Math.max(o.width,o.height,1)),h=Math.max(1,Math.ceil(o.width*l)),u=Math.max(1,Math.ceil(o.height*l)),d=t.material.map,f=d?.image??document.createElement("canvas"),p=f.width!==h||f.height!==u;p&&(f.width=h,f.height=u);const v=f.getContext("2d");if(!v)return;v.clearRect(0,0,h,u);const m=new xo(v);if(m.setStarPoints(i.starPoints),m.setRoll(i.rollRad),m.paintInto(n,o,l,e.ghost),d&&!p){d.needsUpdate=!0;return}d?.dispose();const g=new ws(f);g.colorSpace=Fi,g.minFilter=se,g.generateMipmaps=!1,t.material.map=g,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:i}=t;return JSON.stringify([t.kind,Math.round(i.width*10),Math.round(i.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=[]}}const _1=3,Dc=800,Kr=Math.PI/180;class fa{constructor(t,e,i=fa.fetchImage){this.scene=t,this.onImageLoaded=e,this.loadImage=i}meshes=new Map;signatures=new Map;images=new Map;loading=new Map;failed=new Set;references=[];views=new Map;shown=!0;set(t,e=this.views){this.references=t,this.views=e;const i=new Set(t.map(n=>n.id));for(const[n,s]of this.meshes)i.has(n)||(this.dispose(s),this.meshes.delete(n),this.signatures.delete(n));for(const[n,s]of this.images){const r=t.find(o=>o.id===n);r&&r.src===s.texture.userData.src||(s.texture.dispose(),this.images.delete(n))}for(const n of t){const s=this.images.get(n.id);if(!s){this.load(n);continue}this.build(n,s)}}setShown(t){this.shown=t;for(const e of this.meshes.values())e.visible=t&&this.opacityOf(e.userData.id)>0}setView(t,e){this.views.set(t,e);const i=this.meshes.get(t);i&&this.applyOpacity(i,t)}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}place(t){for(const e of this.meshes.values())e.visible&&(e.position.copy(t.position),e.updateMatrixWorld())}get furthestM(){return this.meshes.size>0?Dc:0}directionOfPixel(t,e,i,n){const s=this.images.get(t.id),r=s?s.width/s.height:1,o=Math.tan(t.registration.fovDeg/2*Kr),c=o*r;return n.set((e*2-1)*c,(1-i*2)*o,-1).normalize(),n.applyQuaternion(fa.orientation(t))}aspectOf(t){const e=this.images.get(t);return e?e.width/e.height:void 0}failedToLoad(t){return this.failed.has(t)}load(t){const e=t.src;if(this.loading.has(t.id)||this.failed.has(e))return;const i=this.loadImage(e).then(n=>{this.loading.delete(t.id);const s=this.references.find(r=>r.id===t.id);if(!s||s.src!==e){n.texture.dispose();return}n.texture.userData.src=e,this.images.set(t.id,n),this.build(s,n),this.onImageLoaded()},()=>{this.loading.delete(t.id),this.failed.add(e)});this.loading.set(t.id,i)}static async fetchImage(t){const e=await fetch(t);if(!e.ok)throw new Error(`${t}: ${e.status}`);const i=await createImageBitmap(await e.blob(),{imageOrientation:"flipY"}),n=new xi(i);return n.flipY=!1,n.colorSpace=Fi,n.minFilter=se,n.magFilter=se,n.generateMipmaps=!1,n.needsUpdate=!0,{texture:n,width:i.width,height:i.height}}build(t,e){const i=fa.signatureOf(t,e);let n=this.meshes.get(t.id);if(n&&this.signatures.get(t.id)===i){this.applyOpacity(n,t.id);return}n&&(this.dispose(n),this.meshes.delete(t.id)),n=new Dt(fa.geometryOf(t,e),new gn({map:e.texture,transparent:!0,depthTest:!1,depthWrite:!1,fog:!1,toneMapped:!1})),t.kind==="panorama"&&(n.material.side=Ue),n.frustumCulled=!1,n.layers.set(_1),n.userData.id=t.id,n.quaternion.copy(fa.orientation(t)),this.scene.add(n),this.meshes.set(t.id,n),this.signatures.set(t.id,i),this.applyOpacity(n,t.id)}static geometryOf(t,e){if(t.kind==="panorama"){const r=new Qe(Dc,64,32,Math.PI/2,Math.PI*2),o=r.attributes.uv;for(let c=0;c<o.count;c++)o.setX(c,1-o.getX(c));return o.needsUpdate=!0,r}const i=2*Dc*Math.tan(t.registration.fovDeg/2*Kr),n=i*(e.width/Math.max(e.height,1)),s=new ki(n,i);return s.translate(0,0,-Dc),s}static orientation(t){const{headingDeg:e,pitchDeg:i,rollDeg:n}=t.registration,s=new Pe;return s.rotation.set(i*Kr,-e*Kr,-(n??0)*Kr,"YXZ"),s.quaternion}opacityOf(t){const e=this.references.find(n=>n.id===t);return this.views.get(t)?.opacity??e?.opacity??0}applyOpacity(t,e){const i=this.opacityOf(e);t.material.opacity=i,t.visible=this.shown&&i>0}static signatureOf(t,e){const{headingDeg:i,pitchDeg:n,rollDeg:s,fovDeg:r}=t.registration;return[t.kind,t.src,e.width,e.height,i,n,s??0,r].join("|")}dispose(t){this.scene.remove(t),t.geometry.dispose(),t.material.dispose()}disposeAll(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear();for(const t of this.images.values())t.texture.dispose();this.images.clear()}}class Ot{static GROUND_RADIUS_M=636e4;static TOP_RADIUS_M=646e4;static WAVELENGTHS_NM=Array.from({length:15},(t,e)=>410+20*e);static WAVELENGTH_STEP_NM=20;static SOLAR_IRRADIANCE=[1.707,1.676,1.982,2.02,1.941,1.87,1.879,1.856,1.839,1.799,1.728,1.668,1.57,1.532,1.452];static OZONE_CROSS_SECTION=[.021,.069,.19,.418,.827,1.531,2.439,3.291,4.468,4.55,4.663,3.477,2.447,1.658,1.071];static RAYLEIGH_SCALE_HEIGHT_M=8e3;static AEROSOL_SCALE_HEIGHT_M=1200;static OZONE_PEAK_ALTITUDE_M=25e3;static OZONE_HALF_WIDTH_M=15e3;static DEFAULT_AEROSOL_OPTICAL_DEPTH=.1;static DEFAULT_OZONE_DOBSON=300;static AEROSOL_SINGLE_SCATTERING_ALBEDO=.9;static AEROSOL_ANGSTROM_EXPONENT=1.3;static AEROSOL_ASYMMETRY=.8;rayleighScattering;aerosolScattering;aerosolExtinction;ozoneAbsorption;constructor(t={}){const e=Ot.WAVELENGTHS_NM.length,i=t.aerosolOpticalDepth??Ot.DEFAULT_AEROSOL_OPTICAL_DEPTH,n=t.ozoneDobson??Ot.DEFAULT_OZONE_DOBSON;this.rayleighScattering=new Float64Array(e),this.aerosolScattering=new Float64Array(e),this.aerosolExtinction=new Float64Array(e),this.ozoneAbsorption=new Float64Array(e);const s=n*2687e17/Ot.OZONE_HALF_WIDTH_M;for(let r=0;r<e;r++){const o=Ot.WAVELENGTHS_NM[r];this.rayleighScattering[r]=Ot.rayleighAt(o);const c=i/Ot.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosolExtinction[r]=c,this.aerosolScattering[r]=c*Ot.AEROSOL_SINGLE_SCATTERING_ALBEDO,this.ozoneAbsorption[r]=Ot.OZONE_CROSS_SECTION[r]*1e-25*s}}static rayleighAt(t){const e=t/1e3,i=1/(e*e),n=e*e;return(1.0455996-341.29061*i-.9023085*n)/(1+.0027059889*i-85.968563*n)*1e-28*1e-4*2546899e19}static rayleighDensity(t){return Math.exp(-Math.max(t,0)/Ot.RAYLEIGH_SCALE_HEIGHT_M)}static aerosolDensity(t){return Math.exp(-Math.max(t,0)/Ot.AEROSOL_SCALE_HEIGHT_M)}static ozoneDensity(t){return Math.max(0,1-Math.abs(t-Ot.OZONE_PEAK_ALTITUDE_M)/Ot.OZONE_HALF_WIDTH_M)}static rayleighPhase(t){return 3/(16*Math.PI)*(1+t*t)}static aerosolPhase(t,e=Ot.AEROSOL_ASYMMETRY){const i=e*e;return 3/(8*Math.PI)*(1-i)*(1+t*t)/((2+i)*Math.pow(Math.max(1+i-2*e*t,1e-6),1.5))}}class Vt{static TRANSMITTANCE_WIDTH=256;static TRANSMITTANCE_HEIGHT=64;static MULTIPLE_SIZE=64;static MULTIPLE_ROWS=16;static MULTIPLE_HEIGHT_POWER=2;static MULTIPLE_DIRECTIONS=16;static SKY_VIEW_WIDTH=192;static SKY_VIEW_HEIGHT=108;static STEPS=40;static MULTIPLE_STEPS=12;static GROUND_ALBEDO=.3;supported;renderer;transmittance;multiple;sunView;moonView;scene=new ys;camera=new In(-1,1,1,-1,0,1);quad;transmittanceMaterial;multipleMaterial;skyViewMaterial;transmittanceReady=!1;multipleRows=0;multipleColumn=0;mediumKey="";static MULTIPLE_BLOCK=16;static shared=new Map;building=!1;adopted;tableUniforms;constructor(t){this.renderer=t,this.supported=t.capabilities.isWebGL2&&t.extensions.has("EXT_color_buffer_float"),this.transmittance=new je(Vt.TRANSMITTANCE_WIDTH,Vt.TRANSMITTANCE_HEIGHT,{count:4,type:ze,minFilter:se,magFilter:se,depthBuffer:!1}),this.multiple=new je(Vt.MULTIPLE_SIZE,Vt.MULTIPLE_ROWS,{count:4,type:Di,minFilter:we,magFilter:we,depthBuffer:!1});const e=()=>new je(Vt.SKY_VIEW_WIDTH,Vt.SKY_VIEW_HEIGHT,{type:Di,minFilter:we,magFilter:we,depthBuffer:!1});this.sunView=e(),this.moonView=e();const i=Vt.mediumUniforms(),n=this.tableUniforms={uT0:{value:this.transmittance.textures[0]},uT1:{value:this.transmittance.textures[1]},uT2:{value:this.transmittance.textures[2]},uT3:{value:this.transmittance.textures[3]},uM0:{value:this.multiple.textures[0]},uM1:{value:this.multiple.textures[1]},uM2:{value:this.multiple.textures[2]},uM3:{value:this.multiple.textures[3]}},s=(r,o={})=>new Eg({glslVersion:rl,uniforms:{...i,...n,...o},vertexShader:Vt.VERTEX,fragmentShader:r,depthTest:!1,depthWrite:!1});this.transmittanceMaterial=s(Vt.TRANSMITTANCE_FRAGMENT),this.multipleMaterial=s(Vt.MULTIPLE_FRAGMENT),this.skyViewMaterial=s(Vt.SKY_VIEW_FRAGMENT,{uObserverRadius:{value:Ot.GROUND_RADIUS_M+2},uSourceMu:{value:1}}),this.quad=new Dt(new ki(2,2),this.transmittanceMaterial),this.quad.frustumCulled=!1,this.scene.add(this.quad)}get transmittanceTextures(){return this.transmittance.textures}get sunViewTexture(){return this.sunView.texture}get moonViewTexture(){return this.moonView.texture}get ready(){return this.supported&&(this.adopted!==void 0||this.transmittanceReady&&this.multipleRows>=Vt.MULTIPLE_ROWS)}setMedium(t){const e=[t.rayleighScattering,t.aerosolScattering,t.aerosolExtinction,t.ozoneAbsorption].map(n=>Array.from(n,s=>s.toPrecision(6)).join(",")).join("|");if(e===this.mediumKey)return;this.abandonBuilding(),this.releaseAdopted(),this.mediumKey=e;const i=(n,s)=>{const r=this.transmittanceMaterial.uniforms[n].value;for(let o=0;o<4;o++)r[o].set(s[o*4]??0,s[o*4+1]??0,s[o*4+2]??0,s[o*4+3]??0)};i("uRayleigh",t.rayleighScattering),i("uAerosolScattering",t.aerosolScattering),i("uAerosolExtinction",t.aerosolExtinction),i("uOzone",t.ozoneAbsorption),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0}invalidate(){this.adopted||(this.abandonBuilding(),this.transmittanceReady=!1,this.multipleRows=0,this.multipleColumn=0)}advance(t){if(!this.supported||!this.mediumKey)return!1;if(this.ready)return!0;const e=Vt.shared.get(this.mediumKey);if(e&&e!=="building")return this.adopt(e),!0;if(e==="building"&&!this.building)return!1;e||(Vt.shared.set(this.mediumKey,"building"),this.building=!0);const i=this.renderer.getRenderTarget();let n=Math.max(1,t);this.transmittanceReady||(this.draw(this.transmittanceMaterial,this.transmittance),this.transmittanceReady=!0,n--);const s=Vt.MULTIPLE_SIZE,r=Vt.MULTIPLE_BLOCK;for(;n>0&&this.multipleRows<Vt.MULTIPLE_ROWS;n--)this.multiple.scissor.set(this.multipleColumn,this.multipleRows,r,1),this.multiple.scissorTest=!0,this.draw(this.multipleMaterial,this.multiple),this.multipleColumn+=r,this.multipleColumn>=s&&(this.multipleColumn=0,this.multipleRows++);return this.multiple.scissorTest=!1,this.renderer.setRenderTarget(i),this.ready&&this.building&&this.share(this.mediumKey),this.ready}async share(t){this.building=!1;try{const e=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.transmittance,n,Uint16Array))),i=await Promise.all([0,1,2,3].map(n=>this.readRaw(this.multiple,n,Float32Array)));this.mediumKey===t?Vt.shared.set(t,{transmittance:e,multiple:i}):Vt.shared.delete(t)}catch{Vt.shared.delete(t)}}async readRaw(t,e,i){const n=new i(t.width*t.height*4);return await this.renderer.readRenderTargetPixelsAsync(t,0,0,t.width,t.height,n,void 0,e),n}adopt(t){const e=(s,r,o,c)=>{const l=new Js(s,r,o,_i,c?ze:Di);return l.minFilter=l.magFilter=c?se:we,l.needsUpdate=!0,l},i=t.transmittance.map(s=>e(s,Vt.TRANSMITTANCE_WIDTH,Vt.TRANSMITTANCE_HEIGHT,!0)),n=t.multiple.map(s=>e(s,Vt.MULTIPLE_SIZE,Vt.MULTIPLE_ROWS,!1));i.forEach((s,r)=>this.tableUniforms[`uT${r}`].value=s),n.forEach((s,r)=>this.tableUniforms[`uM${r}`].value=s),this.adopted=[...i,...n]}releaseAdopted(){if(this.adopted){for(const t of this.adopted)t.dispose();this.adopted=void 0;for(let t=0;t<4;t++)this.tableUniforms[`uT${t}`].value=this.transmittance.textures[t],this.tableUniforms[`uM${t}`].value=this.multiple.textures[t]}}abandonBuilding(){this.building&&(this.building=!1,Vt.shared.get(this.mediumKey)==="building"&&Vt.shared.delete(this.mediumKey))}renderSkyViews(t,e,i){if(!this.ready)return;const n=this.renderer.getRenderTarget(),s=this.skyViewMaterial.uniforms;s.uObserverRadius.value=Ot.GROUND_RADIUS_M+Math.max(t,2),s.uSourceMu.value=Math.sin(e*Math.PI/180),this.draw(this.skyViewMaterial,this.sunView),s.uSourceMu.value=Math.sin(i*Math.PI/180),this.draw(this.skyViewMaterial,this.moonView),this.renderer.setRenderTarget(n)}static skyViewUv(t,e,i){const n=Ot.GROUND_RADIUS_M+Math.max(t,2),s=Ot.GROUND_RADIUS_M,r=Math.acos(Math.min(Math.sqrt(Math.max(n*n-s*s,0))/n,1)),o=Math.PI-r,c=e<o?.5*(1-Math.sqrt(Math.max(1-e/o,0))):.5+.5*Math.sqrt(Math.min((e-o)/r,1));return{u:Math.min(Math.max(Math.abs(i)/Math.PI,0),1),v:c}}async readTable(t,e){if(t==="multiple"){const s=new Float32Array(this.multiple.width*this.multiple.height*4);return await this.renderer.readRenderTargetPixelsAsync(this.multiple,0,0,this.multiple.width,this.multiple.height,s,void 0,e),s}const i=this.transmittance,n=new Uint16Array(i.width*i.height*4);return await this.renderer.readRenderTargetPixelsAsync(i,0,0,i.width,i.height,n,void 0,e),Float32Array.from(n,s=>Cn.fromHalfFloat(s))}readSkyViewNow(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4),n=this.renderer.getContext();return n.bindBuffer(n.PIXEL_PACK_BUFFER,null),this.renderer.readRenderTargetPixels(e,0,0,e.width,e.height,i),i}async readSkyView(t){const e=t==="sun"?this.sunView:this.moonView,i=new Float32Array(e.width*e.height*4);return await this.renderer.readRenderTargetPixelsAsync(e,0,0,e.width,e.height,i),i}dispose(){this.abandonBuilding(),this.releaseAdopted(),this.transmittance.dispose(),this.multiple.dispose(),this.sunView.dispose(),this.moonView.dispose(),this.transmittanceMaterial.dispose(),this.multipleMaterial.dispose(),this.skyViewMaterial.dispose(),this.quad.geometry.dispose()}draw(t,e){this.quad.material=t,this.renderer.setRenderTarget(e),this.renderer.render(this.scene,this.camera)}static mediumUniforms(){const t=()=>[new ie,new ie,new ie,new ie],e=(i,n)=>{const s=t();return Ot.WAVELENGTHS_NM.forEach((r,o)=>{s[Math.floor(o/4)].setComponent(o%4,i(r)*n*Ot.WAVELENGTH_STEP_NM*Ot.SOLAR_IRRADIANCE[o])}),s};return{uRayleigh:{value:t()},uAerosolScattering:{value:t()},uAerosolExtinction:{value:t()},uOzone:{value:t()},uCieX:{value:e(i=>ci.colourMatching(i)[0],683)},uCieY:{value:e(i=>ci.colourMatching(i)[1],683)},uCieZ:{value:e(i=>ci.colourMatching(i)[2],683)},uScotopic:{value:e(i=>ci.scotopic(i),1700)}}}static VERTEX=`
|
|
6598
6602
|
in vec3 position;
|
|
6599
6603
|
void main() {
|
|
6600
6604
|
gl_Position = vec4(position.xy, 0.0, 1.0);
|
|
@@ -6612,12 +6616,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6612
6616
|
const float OZONE_PEAK = ${Ot.OZONE_PEAK_ALTITUDE_M.toFixed(1)};
|
|
6613
6617
|
const float OZONE_HALF_WIDTH = ${Ot.OZONE_HALF_WIDTH_M.toFixed(1)};
|
|
6614
6618
|
const float AEROSOL_G = ${Ot.AEROSOL_ASYMMETRY.toFixed(4)};
|
|
6615
|
-
const float GROUND_ALBEDO = ${
|
|
6616
|
-
const int STEPS = ${
|
|
6617
|
-
const int MULTIPLE_STEPS = ${
|
|
6618
|
-
const vec2 T_SIZE = vec2(${
|
|
6619
|
-
const vec2 M_SIZE = vec2(${
|
|
6620
|
-
const float M_HEIGHT_POWER = ${
|
|
6619
|
+
const float GROUND_ALBEDO = ${Vt.GROUND_ALBEDO.toFixed(4)};
|
|
6620
|
+
const int STEPS = ${Vt.STEPS};
|
|
6621
|
+
const int MULTIPLE_STEPS = ${Vt.MULTIPLE_STEPS};
|
|
6622
|
+
const vec2 T_SIZE = vec2(${Vt.TRANSMITTANCE_WIDTH}.0, ${Vt.TRANSMITTANCE_HEIGHT}.0);
|
|
6623
|
+
const vec2 M_SIZE = vec2(${Vt.MULTIPLE_SIZE}.0, ${Vt.MULTIPLE_ROWS}.0);
|
|
6624
|
+
const float M_HEIGHT_POWER = ${Vt.MULTIPLE_HEIGHT_POWER.toFixed(1)};
|
|
6621
6625
|
|
|
6622
6626
|
uniform vec4 uRayleigh[4];
|
|
6623
6627
|
uniform vec4 uAerosolScattering[4];
|
|
@@ -6760,7 +6764,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6760
6764
|
}
|
|
6761
6765
|
}
|
|
6762
6766
|
`;static TRANSMITTANCE_FRAGMENT=`
|
|
6763
|
-
${
|
|
6767
|
+
${Vt.COMMON}
|
|
6764
6768
|
layout(location = 0) out vec4 out0;
|
|
6765
6769
|
layout(location = 1) out vec4 out1;
|
|
6766
6770
|
layout(location = 2) out vec4 out2;
|
|
@@ -6794,12 +6798,12 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6794
6798
|
}
|
|
6795
6799
|
`;static MULTIPLE_FRAGMENT=`
|
|
6796
6800
|
#define BUILDING_MULTIPLE
|
|
6797
|
-
${
|
|
6801
|
+
${Vt.COMMON}
|
|
6798
6802
|
layout(location = 0) out vec4 out0;
|
|
6799
6803
|
layout(location = 1) out vec4 out1;
|
|
6800
6804
|
layout(location = 2) out vec4 out2;
|
|
6801
6805
|
layout(location = 3) out vec4 out3;
|
|
6802
|
-
const int DIRECTIONS = ${
|
|
6806
|
+
const int DIRECTIONS = ${Vt.MULTIPLE_DIRECTIONS};
|
|
6803
6807
|
|
|
6804
6808
|
void main() {
|
|
6805
6809
|
vec2 uv = gl_FragCoord.xy / M_SIZE;
|
|
@@ -6836,7 +6840,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6836
6840
|
out3 = result[3];
|
|
6837
6841
|
}
|
|
6838
6842
|
`;static SKY_VIEW_FRAGMENT=`
|
|
6839
|
-
${
|
|
6843
|
+
${Vt.COMMON}
|
|
6840
6844
|
uniform float uObserverRadius;
|
|
6841
6845
|
uniform float uSourceMu;
|
|
6842
6846
|
uniform vec4 uCieX[4];
|
|
@@ -6846,7 +6850,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6846
6850
|
out vec4 outColor;
|
|
6847
6851
|
|
|
6848
6852
|
void main() {
|
|
6849
|
-
vec2 uv = gl_FragCoord.xy / vec2(${
|
|
6853
|
+
vec2 uv = gl_FragCoord.xy / vec2(${Vt.SKY_VIEW_WIDTH}.0, ${Vt.SKY_VIEW_HEIGHT}.0);
|
|
6850
6854
|
float r = uObserverRadius;
|
|
6851
6855
|
float beta = acos(clamp(sqrt(max(r * r - GROUND * GROUND, 0.0)) / r, -1.0, 1.0));
|
|
6852
6856
|
float zenithHorizon = PI - beta;
|
|
@@ -6870,7 +6874,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6870
6874
|
}
|
|
6871
6875
|
outColor = xyzs;
|
|
6872
6876
|
}
|
|
6873
|
-
`}class ii{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;get adaptation(){return this.adaptingLuminance*this.exposureScale}ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(t,e){this.onChange=e,this.tables=new
|
|
6877
|
+
`}class ii{static AIRGLOW_LAYER_ALTITUDE_M=9e4;static SUN_MAGNITUDE=-26.74;tables;material;onChange;state;drawnKey="";hasViews=!1;adaptingLuminance=1;get adaptation(){return this.adaptingLuminance*this.exposureScale}ambientColours;reading=!1;exposureScale=1;seenByEye=!0;readAgain=!1;constructor(t,e){this.onChange=e,this.tables=new Vt(t),this.tables.setMedium(new Ot),this.material=new ae({glslVersion:rl,side:Ue,depthWrite:!1,uniforms:{uSunView:{value:this.tables.sunViewTexture},uMoonView:{value:this.tables.moonViewTexture},uSunAzimuth:{value:new Mt(0,-1)},uMoonAzimuth:{value:new Mt(0,-1)},uMoonScale:{value:0},uObserverRadius:{value:Ot.GROUND_RADIUS_M+2},uAirglow:{value:new ie(...ii.airglowXyzs())},uRodShare:{value:0},uInverseSemiSaturation:{value:1},uExposureScale:{value:1}},vertexShader:`
|
|
6874
6878
|
varying vec3 vDirection;
|
|
6875
6879
|
void main() {
|
|
6876
6880
|
vDirection = (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition;
|
|
@@ -6896,7 +6900,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6896
6900
|
const float GROUND = ${Ot.GROUND_RADIUS_M.toFixed(1)};
|
|
6897
6901
|
const float AIRGLOW_RATIO = ${(Ot.GROUND_RADIUS_M/(Ot.GROUND_RADIUS_M+ii.AIRGLOW_LAYER_ALTITUDE_M)).toFixed(6)};
|
|
6898
6902
|
const float EXTINCTION = ${Yt.EXTINCTION_PER_AIR_MASS.toFixed(4)};
|
|
6899
|
-
const vec2 VIEW_SIZE = vec2(${
|
|
6903
|
+
const vec2 VIEW_SIZE = vec2(${Vt.SKY_VIEW_WIDTH}.0, ${Vt.SKY_VIEW_HEIGHT}.0);
|
|
6900
6904
|
const vec3 SCOTOPIC_TINT = vec3(${Et.SCOTOPIC_TINT.map(i=>i.toFixed(4)).join(", ")});
|
|
6901
6905
|
|
|
6902
6906
|
/** AtmosphereTables.skyViewUv, for a source standing at \`sourceAzimuth\` (a unit vector in x, z). */
|
|
@@ -6950,7 +6954,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
6950
6954
|
gl_FragColor = vec4(relativeOf(light.xyz, light.w), 1.0);
|
|
6951
6955
|
#include <colorspace_fragment>
|
|
6952
6956
|
}
|
|
6953
|
-
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(t,e){const i=t?10**(.4*e):1;i===this.exposureScale&&this.seenByEye===!t||(this.exposureScale=i,this.seenByEye=!t,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(t){this.tables.setMedium(new Ot(t)),this.tables.ready||(this.drawnKey="")}advance(t){!this.supported||this.tables.ready||this.tables.advance(t)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(t){this.state=t,this.tables.ready?this.draw(t):this.hasViews||this.applyAdaptation(ii.predictedZenithLuminance(t))}dispose(){this.tables.dispose(),this.material.dispose()}draw(t){const e=[t.altitudeM.toFixed(0),t.sun.altitudeDeg.toFixed(3),t.moon.altitudeDeg.toFixed(3)].join(":"),i=this.material.uniforms;if(i.uSunAzimuth.value.copy(ii.azimuthVector(t.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ii.azimuthVector(t.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(t.moon.magnitude-ii.SUN_MAGNITUDE)),i.uObserverRadius.value=Ot.GROUND_RADIUS_M+Math.max(t.altitudeM,2),e!==this.drawnKey){this.tables.renderSkyViews(t.altitudeM,t.sun.altitudeDeg,t.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=e,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),t),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[t,e]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),i=this.state;i&&this.adaptFromViews(t,e,i)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptToSurroundings(t){if(!(t>0)||!(this.clearAdaptation>0))return!1;const e=t/this.clearAdaptation;return Math.abs(Math.log(e/this.surroundingsFactor))<.05?!1:(this.surroundingsFactor=e,this.views&&this.state?this.adaptFromViews(this.views.sun,this.views.moon,this.state):this.applyAdaptation(this.clearAdaptation*e),!0)}resetSurroundings(){this.surroundingsFactor=1}surroundingsFactor=1;clearAdaptation=0;views;adaptFromViews(t,e,i){this.views={sun:t,moon:e};const n=10**(-.4*(i.moon.magnitude-ii.SUN_MAGNITUDE)),s=ii.airglowXyzs(),r=(m,g,_=!0)=>{const w=(90-m)*Math.PI/180,M=
|
|
6957
|
+
`})}get supported(){return this.tables.supported}get ready(){return this.hasViews}get ambient(){return this.ready?this.ambientColours:void 0}setInstrument(t,e){const i=t?10**(.4*e):1;i===this.exposureScale&&this.seenByEye===!t||(this.exposureScale=i,this.seenByEye=!t,this.material.uniforms.uExposureScale.value=i,this.applyAdaptation(this.adaptingLuminance),this.onChange())}setConditions(t){this.tables.setMedium(new Ot(t)),this.tables.ready||(this.drawnKey="")}advance(t){!this.supported||this.tables.ready||this.tables.advance(t)&&this.state&&this.draw(this.state)}invalidate(){this.tables.invalidate(),this.drawnKey="",this.hasViews=!1}update(t){this.state=t,this.tables.ready?this.draw(t):this.hasViews||this.applyAdaptation(ii.predictedZenithLuminance(t))}dispose(){this.tables.dispose(),this.material.dispose()}draw(t){const e=[t.altitudeM.toFixed(0),t.sun.altitudeDeg.toFixed(3),t.moon.altitudeDeg.toFixed(3)].join(":"),i=this.material.uniforms;if(i.uSunAzimuth.value.copy(ii.azimuthVector(t.sun.azimuthDeg)),i.uMoonAzimuth.value.copy(ii.azimuthVector(t.moon.azimuthDeg)),i.uMoonScale.value=10**(-.4*(t.moon.magnitude-ii.SUN_MAGNITUDE)),i.uObserverRadius.value=Ot.GROUND_RADIUS_M+Math.max(t.altitudeM,2),e!==this.drawnKey){this.tables.renderSkyViews(t.altitudeM,t.sun.altitudeDeg,t.moon.altitudeDeg);const n=!this.hasViews;this.hasViews=!0,this.drawnKey=e,n&&!this.ambientColours&&this.adaptFromViews(this.tables.readSkyViewNow("sun"),this.tables.readSkyViewNow("moon"),t),this.readBack()}this.onChange()}async readBack(){if(this.reading){this.readAgain=!0;return}this.reading=!0;try{const[t,e]=await Promise.all([this.tables.readSkyView("sun"),this.tables.readSkyView("moon")]),i=this.state;i&&this.adaptFromViews(t,e,i)}finally{this.reading=!1}this.readAgain&&(this.readAgain=!1,this.readBack())}adaptToSurroundings(t){if(!(t>0)||!(this.clearAdaptation>0))return!1;const e=t/this.clearAdaptation;return Math.abs(Math.log(e/this.surroundingsFactor))<.05?!1:(this.surroundingsFactor=e,this.views&&this.state?this.adaptFromViews(this.views.sun,this.views.moon,this.state):this.applyAdaptation(this.clearAdaptation*e),!0)}resetSurroundings(){this.surroundingsFactor=1}surroundingsFactor=1;clearAdaptation=0;views;adaptFromViews(t,e,i){this.views={sun:t,moon:e};const n=10**(-.4*(i.moon.magnitude-ii.SUN_MAGNITUDE)),s=ii.airglowXyzs(),r=(m,g,_=!0)=>{const w=(90-m)*Math.PI/180,M=Vt.skyViewUv(i.altitudeM,w,ii.azimuthBetween(g,i.sun.azimuthDeg)),S=Vt.skyViewUv(i.altitudeM,w,ii.azimuthBetween(g,i.moon.azimuthDeg)),b=ii.bilinear(t,M.u,M.v),T=ii.bilinear(e,S.u,S.v),x=_&&m>0?ii.airglowFactor(m):0;return[0,1,2,3].map(A=>b[A]+n*T[A]+s[A]*x)};let o=0,c=0;for(let m=5;m<90;m+=10){const g=Math.cos(m*Math.PI/180);for(let _=0;_<360;_+=30)o+=g*Math.log(Math.max(r(m,_)[1],1e-9)),c+=g}this.clearAdaptation=Math.exp(o/c),this.applyAdaptation(this.clearAdaptation*this.surroundingsFactor);const l=([m,g,_,w])=>{const M=this.exposureScale,S=this.adaptingLuminance*M;return Et.relativeOf([m*M,g*M,_*M],w*M,S,0)},h=(m,g,_=!0)=>l(r(m,g,_)),u=[0,0,0,0],d=5*Math.PI/180,f=20*Math.PI/180;for(let m=2.5;m<90;m+=5){const g=m*Math.PI/180,_=Math.sin(g)*Math.cos(g)*d*f;for(let w=10;w<360;w+=20){const M=r(m,w);for(let S=0;S<4;S++)u[S]+=M[S]*_}}const p=[0,0,0],v=[0,0,0];for(let m=0;m<360;m+=20){const g=h(2,m),_=h(2,m,!1);for(let w=0;w<3;w++)p[w]+=g[w]/18,v[w]+=_[w]/18}this.ambientColours={zenith:h(90,0),horizon:p,airlight:v,skyIrradiance:l(u),scale:this.relativeScale},this.onChange()}relativeOfLuminance(t,e){const[i,n,s]=t,r=.2126*i+.7152*n+.0722*s,o=r>0?e/r:0,c=[o*(.4124*i+.3576*n+.1805*s),e,o*(.0193*i+.1192*n+.9505*s)],l=this.exposureScale,h=this.adaptingLuminance*l;return Et.relativeOf([c[0]*l,c[1]*l,c[2]*l],c[1]*l,h,0)}get rodShare(){const t=this.adaptingLuminance*this.exposureScale;return this.seenByEye?Et.rodShare(t):0}get relativeScale(){const t=this.adaptingLuminance*this.exposureScale;return this.exposureScale/Et.semiSaturation(t)}applyAdaptation(t){this.adaptingLuminance=t;const e=t*this.exposureScale;this.material.uniforms.uRodShare.value=0,this.material.uniforms.uInverseSemiSaturation.value=1/Et.semiSaturation(e)}static predictedZenithLuminance(t){const e=n=>90-n.altitudeDeg,i=Yt.magPerArcsec2({altitudeDeg:t.sun.altitudeDeg,separationDeg:e(t.sun)},{phaseAngleDeg:t.moon.phaseAngleDeg,altitudeDeg:t.moon.altitudeDeg,separationDeg:e(t.moon)},90);return Yt.toNanolamberts(i)*ii.CANDELAS_PER_NANOLAMBERT}static CANDELAS_PER_NANOLAMBERT=1e-5/Math.PI;static airglowXyzs(){const t=Yt.toNanolamberts(Yt.AIRGLOW_MAG_PER_ARCSEC2)*ii.CANDELAS_PER_NANOLAMBERT;return[t*.3127/.329,t,t*(1-.3127-.329)/.329,t]}static airglowFactor(t){const e=Math.cos(t*Math.PI/180)**2,i=Ot.GROUND_RADIUS_M/(Ot.GROUND_RADIUS_M+ii.AIRGLOW_LAYER_ALTITUDE_M),n=1/Math.sqrt(Math.max(1-i*i*e,1e-4)),s=1/Math.sqrt(Math.max(1-.96*e,.001));return n*10**(-.4*Yt.EXTINCTION_PER_AIR_MASS*(s-1))}static azimuthVector(t){const e=t*Math.PI/180;return new Mt(Math.sin(e),-Math.cos(e))}static azimuthBetween(t,e){const i=Math.abs(t-e)%360;return(i>180?360-i:i)*Math.PI/180}static bilinear(t,e,i){const n=Vt.SKY_VIEW_WIDTH,s=Vt.SKY_VIEW_HEIGHT,r=Math.min(Math.max(e*n-.5,0),n-1),o=Math.min(Math.max(i*s-.5,0),s-1),c=Math.floor(r),l=Math.floor(o),h=Math.min(c+1,n-1),u=Math.min(l+1,s-1),d=r-c,f=o-l,p=(v,m,g)=>t[(v*n+m)*4+g];return[0,1,2,3].map(v=>(p(l,c,v)*(1-d)+p(l,h,v)*d)*(1-f)+(p(u,c,v)*(1-d)+p(u,h,v)*d)*f)}}class Ws{static DRY_OPTICAL_DEPTH=.08;static GROWTH_EXPONENT=.3;static MAX_RELATIVE_HUMIDITY=.95;static OPTICAL_DEPTH_STEP=.02;static relativeHumidity(t,e){const i=n=>Math.exp(17.625*n/(243.04+n));return Math.min(Math.max(i(e)/i(t),0),1)}static opticalDepth(t){const e=Math.min(Math.max(t,0),Ws.MAX_RELATIVE_HUMIDITY);return Ws.DRY_OPTICAL_DEPTH*(1-e)**-.3}static steppedOpticalDepth(t){const e=Ws.OPTICAL_DEPTH_STEP;return Math.round(Ws.opticalDepth(t)/e)*e}}class fn{static CHANNEL_WAVELENGTHS_NM=[680,550,440];static KOSCHMIEDER=-Math.log(.02);static PRECIPITATION_EXTINCTION_PER_KM={rain:{a:.365,b:.63},snow:{a:1.023,b:.72},hail:{a:.365,b:.63}};static FULL_INTENSITY_MM_PER_H=8;rayleigh;aerosol;constructor(t=Ot.DEFAULT_AEROSOL_OPTICAL_DEPTH,e=0){const[i,n,s]=fn.CHANNEL_WAVELENGTHS_NM;this.rayleigh=[Ot.rayleighAt(i),Ot.rayleighAt(n),Ot.rayleighAt(s)];const r=o=>t/Ot.AEROSOL_SCALE_HEIGHT_M*(o/550)**-1.3;this.aerosol=[r(i)+e,r(n)+e,r(s)+e],this.precipitationPerM=e}precipitationPerM;static of(t){const e=t.relativeHumidity===void 0?void 0:Ws.opticalDepth(t.relativeHumidity);return new fn(e,fn.precipitationExtinction(t))}static precipitationExtinction(t){if(t.precipitationType==="none"||!(t.precipitationIntensity>0))return 0;const e=fn.PRECIPITATION_EXTINCTION_PER_KM[t.precipitationType],i=t.precipitationIntensity*fn.FULL_INTENSITY_MM_PER_H;return e.a*i**e.b/1e3}transmittance(t,e,i){const n=fn.meanDensity(t,e,Ot.RAYLEIGH_SCALE_HEIGHT_M),s=fn.meanDensity(t,e,Ot.AEROSOL_SCALE_HEIGHT_M);return[0,1,2].map(r=>Math.exp(-(this.rayleigh[r]*n+this.aerosol[r]*s)*i))}transmittanceFromSpace(t,e){const i=Math.max(e,0),n=1/(Math.sin(i*Math.PI/180)+.50572*(i+6.07995)**-1.6364),s=Ot.RAYLEIGH_SCALE_HEIGHT_M*Ot.rayleighDensity(t),r=Ot.AEROSOL_SCALE_HEIGHT_M*Ot.aerosolDensity(t);return[0,1,2].map(o=>Math.exp(-(this.rayleigh[o]*s+(this.aerosol[o]-this.precipitationPerM)*r)*n))}extinctionAt(t){return{rayleigh:this.rayleigh[1]*Ot.rayleighDensity(t),aerosol:this.aerosol[1]*Ot.aerosolDensity(t)}}visibilityM(t){const{rayleigh:e,aerosol:i}=this.extinctionAt(t);return fn.KOSCHMIEDER/(e+i)}get rayleighRatios(){return[this.rayleigh[0]/this.rayleigh[1],1,this.rayleigh[2]/this.rayleigh[1]]}static meanDensity(t,e,i){const n=Math.max(t,0),s=Math.max(e,0),r=s-n;return Math.abs(r)<.01?Math.exp(-n/i):i*(Math.exp(-n/i)-Math.exp(-s/i))/r}}class ya extends Yd{constructor(){super(new st(0,0,0),0,0),ya.install()}setAir(t,e,i){const{rayleigh:n,aerosol:s}=t.extinctionAt(e);this.near=n,this.far=s,this.color.setRGB(i[0],i[1],i[2])}static fadeRim(t,e,i,n){t.onBeforeCompile=s=>{s.uniforms.aerialHorizon={value:n},s.fragmentShader=s.fragmentShader.replace("#include <fog_pars_fragment>",`#include <fog_pars_fragment>
|
|
6954
6958
|
uniform vec3 aerialHorizon;`).replace("#include <fog_fragment>",`#include <fog_fragment>
|
|
6955
6959
|
#ifdef USE_FOG
|
|
6956
6960
|
float aerialRim = smoothstep(${e.toFixed(1)}, ${i.toFixed(1)}, length(vAerialWorld.xz - cameraPosition.xz));
|
|
@@ -7011,7 +7015,7 @@ cloudPoint = (modelMatrix * vec4(transformed, 1.0)).xyz - cameraPosition;`);let
|
|
|
7011
7015
|
vec3 light = texture2D(uMap, vec2((along * (uSteps - 1.0) + 0.5) / uSteps, 0.5)).rgb;
|
|
7012
7016
|
gl_FragColor = vec4(light, 1.0);
|
|
7013
7017
|
}
|
|
7014
|
-
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ue,fog:!1});this.object=new Dt(new Qe(M0.RADIUS,128,32,0,Math.PI*2,0,ce.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<ce.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Cn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Cn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class xl{constructor(t){this.generator=t}static SIZE=128;target=new To(xl.SIZE,{type:ze,generateMipmaps:!1,minFilter:se,magFilter:se});camera=new e0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;const r=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((o,c)=>{o.visible=r[c]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class Ji{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){Ji.install(),this.generator=new Ju(t),this.eye=new xl(this.generator)}static decor;refresh(t,e,i,n,s,r,o,c=[],l){for(const v of[...this.probes.keys()])n.some(m=>m.id===v&&m.shiny)||(this.probes.get(v).dispose(),this.probes.delete(v));const h=[{probe:this.eye}];for(const v of n){if(!v.shiny)continue;let m=this.probes.get(v.id);m||(m=new xl(this.generator),this.probes.set(v.id,m)),h.push({probe:m,reflector:v})}const u=performance.now(),d=()=>h.filter(({probe:v})=>v.capturedVersion!==o),f=d().filter(({probe:v})=>u-v.capturedAtMs>=Ji.REFRESH_MS);if(f.length>0){const v=f.reduce((m,g)=>g.probe.capturedAtMs<m.probe.capturedAtMs?g:m);if(v.reflector){const m=v.reflector.holder.getWorldPosition(this.scratch);v.probe.capture(t,e,m,[v.reflector.holder,...s]),Ji.reflectOn(v.reflector.holder,v.probe)}else{v.probe.capture(t,e,i,[...s,...c]),l?.(v.probe.sharp),Ji.decor=v.probe.filtered;for(const m of r)Ji.reflectOn(m,v.probe);for(const m of n)m.shiny||Ji.reflectOn(m.holder,v.probe)}v.probe.capturedVersion=o}const p=d();if(p.length!==0)return Math.max(16,Math.min(...p.map(({probe:v})=>Ji.REFRESH_MS-(u-v.capturedAtMs))))}scratch=new D;static reflectOn(t,e={filtered:Ji.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Do?e.sharp&&s.setSurroundings(e.sharp):s instanceof la&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(Ji.installed)return;Ji.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Wt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Wt.lights_fragment_maps=Wt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function cb(a,t){return JSON.stringify(a.cloudLayers)===JSON.stringify(t.cloudLayers)&&a.cloudCover===t.cloudCover&&a.cloudDarkness===t.cloudDarkness&&a.cloudBaseM===t.cloudBaseM&&a.highCloudCover===t.highCloudCover&&a.iceCrystalAlignment===t.iceCrystalAlignment&&a.lowerCloudCover===t.lowerCloudCover&&a.relativeHumidity===t.relativeHumidity&&a.precipitationType===t.precipitationType&&a.precipitationIntensity===t.precipitationIntensity&&a.windDirectionDeg===t.windDirectionDeg&&a.windSpeed===t.windSpeed&&a.storm===t.storm}const Cc=900,Bh=1,jp=4,Qp=5,tm=.5,so=900,lb=6371e3,hb=3e4;function em(a){const t=Math.sqrt(2*lb*Math.max(a,0));return Math.max(so,Math.min(t,hb))}const Hh=.5,Gh=850,im=.03,ln=850,Vh=300,ub=.04,$r=4,Wh=1.5,nm=-1,db=6,Dd=-4,fb=2,pb=20,Ic=2600,mb=.97,gb=.38,Pc=Dd,sm=1500,vb=400,Mb=[0,45,90,135,180,225,270,315],xb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},yb=["en","fr"],_b=2,Sb=16,am=2500,rm=880,Lc=40,om=60,wb=10,bb=1,Eb=150,Ab=55,Tb=.5,Rb=17,cm=.265,lm=[[0,0],...Array.from({length:8},(a,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*cm,Math.sin(e)*cm]})],Xh=700,qh=250/1e3,Db=12,hm=5,Yh=6,aa=[.92,.92,.95],Kh=[.15,.15,.19],um={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},er=0,$h=0,Cb=150,dm=3e3,Zr=20,Ib=15,fm=er,Pb=40,pm=1,Lb=9;function mm(a){return pm+(Lb-pm)*a}const gm=new st(.75,.82,.92),Nb=10,Ob=.5;function Ub(a){return or(a/Nb,Ob,1)}const ja=200,vm=.18,Mm=.32,Fb=.35,xm=new st(.85,.9,.98),ym=5,_m=.85,Sm=.01;function Zh(a,t){return Math.round(a*(Sm+(1-Sm)*t))}const wm=230,bm=.7,Em=.05,kb=.6,zb=.7,Bb=.15,Am=.35,Hb=3,Gb=1/12,Vb=.5,zn=new st(.82,.86,1),Wb=2500,Xb=1.6,Jh=15,qb={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class Fe{renderer;scene=new ys;phenomena=new bn(this.scene);references=new fa(this.scene,()=>this.render());camera;celestialGroup=new De;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new hn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=ab[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new oe(t=>this.loadBodyModel(t),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new Xf(16777215,0);celestialLightTarget=new Pe;skyLight=new PM(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 xh;weather=Om;observerElevationM=0;siteElevationM=0;air=new fn;groundRadius=so;terrainRadius=so;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new D;cloudFieldOffset=new D;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new D;rainLastVerticalFacing=-1;rainViewportSize=new Mt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new Xf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new xh;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new xh;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=L2()){this.renderer=new XS({canvas:t,antialias:!0}),this.resolution=new de(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ro,this.camera=new Vi(60,t.width/Math.max(t.height,1),.1,Cc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,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=ln-Vh,this.celestialLight.shadow.camera.far=ln+Vh,this.celestialLight.shadow.bias=-.03/(2*Vh),this.celestialLight.shadow.normalBias=ub,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(zn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new ii(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(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*qh,0,t.z*qh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*Bi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Bi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Bi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(em(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/so),this.camera.far=Math.max(Cc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=li(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.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.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=li(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Eb*(n/so))return}const s=this.terrainOrigin,r=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;yw(t,e,this.terrainProviders,n).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?li(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=r&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=bb,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>Fe.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}n.getRoads(h1(t,e,i)).then(r=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:r},this.drapeRoads(r,t,e,n.contemporary))}).catch(r=>{console.warn("Roads unavailable, drawing none:",r)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(r,o)=>this.groundYOfPatch(s,r,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=Ab*(this.sunArriving[1]/Rb);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Ui.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];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(),!cb(this.weather,t)&&(this.weather=t,this.air=fn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:Ws.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lastAstronomy&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=Vb,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(),vi.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=vi.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(r=>r.id),n=[],s){const{x:r,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:r,originZ:o,originGroundY:this.groundYUnder(r,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0);const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,r=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[r(t.r,i.r,n.r),r(t.g,i.g,n.g),r(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=t.url??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await Jp(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!vi.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,r=i.credit??n?.credit;if(!s||!r)return;const o=await Jp(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;Ji.reflectOn(o),vi.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,r),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?li(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.witnessSide!==void 0&&zm(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=li(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(s){const l=vi.occupantView(s),h=-(s.headingDeg??0)*Bi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;r.x=-(f+u),r.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Bi,-(l.headingDeg+this.indoorLookYawDeg)*Bi,0,"YXZ")}this.bodyOrigin={x:n.x+r.x,z:n.z+r.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Id(l,i),d=u.eastM+n.x+r.x,f=-u.northM+n.z+r.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=Cb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Bi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(_=>typeof _=="number"?_.toFixed(4):_).join(":");h.userData.cropGroundKey!==g&&(vi.fitCropToGround(h,(_,w)=>this.groundYUnder(_,w)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Cc*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 i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):$h}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return $h;const r=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=or((e-r)/(o-r)*(s-1),0,s-1),u=or((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return $h;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(S,b)=>n.getY(S*s+b),g=m(f,d),_=m(f,d+1),w=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(_-g)*p+(w-g)*v:M+(w-M)*(1-p)+(_-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return vi.groundUnderFootprint(t,e,i,n,(r,o)=>this.groundYUnder(r,o),s)}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 i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&vi.setLights(n,i.lights,t,n.position.distanceTo(this.camera.position),e,this.relativeScale),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const r=p2(i,t);vi.setLit(s,i.kind,r,this.relativeScale);const o=this.streetlightLights.get(i.id);o&&(o.visible=r)}}addStreetlightLight(t,e){const i=vi.bodyOf(e),n=i.children.find(r=>r.userData.emissive);if(!n)return;const s=new Cg(16764006,sm*this.relativeScale,vb);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+am,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),am+20)),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=qc(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=r=>{const o=Rn.luminanceOf(r);if(!(o>0))return[0,0,0];const c=Et.relativeOfResponse(o)/o;return[r[0]*c,r[1]*c,r[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,$r,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,qc(t.sun.altitudeDeg,this.instrumentMagnitudeGain)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??Fe.relativeSkyOf(rd(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=r=>n?[0,1,2].map(o=>r[o]*n.through+n.radiance[o]*(1-n.through)):[r[0],r[1],r[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),Oe.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const r of this.streetlightLights.values())r.intensity=sm*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ot.DEFAULT_AEROSOL_OPTICAL_DEPTH:Ws.opticalDepth(i))*Ot.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),r=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=ce.aureoleScale(n,ce.airMass(t.altitudeDeg))*s,c=ce.coronaScale(r),l=ce.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new M0,this.celestialGroup.add(this.lunarDiffraction.object));const u=ce.profile(ce.HAZE_COARSE_MODE),d=ce.profile(ce.CLOUD_DROPLETS),f=_p(t.altitudeDeg),p=new Float32Array(ce.STEPS*3);let v=0;for(let w=0;w<ce.STEPS;w++){const M=w*3,S=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),b=Rn.shown(S,Rn.luminanceOf(S),(T,x)=>e.relativeOfLuminance(T,x));p.set(b,M),v=Math.max(v,Rn.response(b))}const{x:m,y:g,z:_}=ni(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:_}:void 0,p)}applyAir(){this.scene.fog instanceof ya||(this.scene.fog=new ya),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight),this.horizonColour.setRGB(this.baseFogColor[0],this.baseFogColor[1],this.baseFogColor[2])}airlight=[0,0,0];horizonColour=new st(0,0,0);transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Yt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?Sb:_b),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new Ow(Gh),this.celestialGroup.add(this.satelliteField.object));const e=qc(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(im*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=Pc,s=!n&&t.moon.altitudeDeg>=Pc,r=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Bi)),l=n||s?this.cloudTransmission(r):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const _=ce.illuminanceOf(r.magnitude)*i,w=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,r.altitudeDeg);for(let T=0;T<3;T++)o[T]=_*w[T]*l,d[T]=_*w[T]*u*c,this.cloudBeam[T]=_*w[T];const{x:M,y:S,z:b}=ni(r.altitudeDeg,r.azimuthDeg,1);this.cloudBeamDirection.set(M,S,b)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const _=this.skyCloudTransmission(),w=e.skyIrradiance,M=[0,1,2].map(b=>w[b]*_+d[b]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const S=Gt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(S*(M[0]+o[0]*c),S*(M[1]+o[1]*c),S*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=ni(r.altitudeDeg,r.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new D(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),r=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=r.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,ln)}shadowUp=new D(0,1,0);shadowAxisX=new D;shadowAxisY=new D;shadowWorld=new D;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*Bi,s=Math.sin(n)*Math.cos(n)*2;for(let r=0;r<360;r+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:r}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new D(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/Et.semiSaturation(Et.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new pi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}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=ri.starPointsOf(t),i=ri.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.firstFrameReady()&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1)}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const 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,i=performance.now()+Fe.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const r of t){const o=e.get(r)?.currentProgram;(!o||o.isReady())&&t.delete(r)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(){this.reflections??=new Ji(this.renderer);const t=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(s=>s.mesh)],e=[...this.starTiers.map(s=>s.points),...[...this.bodyMeshes.values()].filter(s=>s instanceof ds),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(s=>s!==void 0)],i=this.relativeScale,n=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,t,[...this.decorGroups.values()],this.sceneVersion,e,s=>this.measureSurroundings(s,i));n===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},n))}measureSurroundings(t,e){const i=this.lastAstronomy;if(!i)return;this.probeIrradiance??=new uo;const n=[i.sun,i.moon].filter(s=>s.altitudeDeg>-2).map(s=>ni(s.altitudeDeg,s.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,n,s=>{const r=d=>d.map(f=>f/e),o=this.surroundings,c={up:r(s.up),down:r(s.down)},l=(d,f)=>d.some((p,v)=>Math.abs(p-f[v])>.03*Math.max(Math.abs(p),Math.abs(f[v]),1e-12)),h=!o||l(o.up,c.up)||l(o.down,c.down);h&&(this.surroundings=c);const u=this.scatteredSky?.adaptToSurroundings(Math.exp(s.logAverage)/e)??!1;!h&&!u||(this.skyColoursStale=!0,this.render())})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=Pc?t.sun:t.moon.altitudeDeg>=Pc?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,Gb);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),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.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===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,o,c)=>this.directionAtScreenPoint(r,o,c),r=>this.screenPointOf(r)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),pn.uRodShare.value=this.scatteredSky?.rodShare??0,pn.uRelativeScale.value=this.relativeScale;const n=this.references.any||this.phenomena.any||this.compassSprites.some(r=>r.visible);pn.uHasOverlay.value=n?1:0;const s=n?r=>this.renderOverlayPasses(r):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?r.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(Qp),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(_1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t){this.references.set(t)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new D)}referenceFailedToLoad(t){return this.references.failedToLoad(t)}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&Fe.markDecorDepth(s,n.kind!=="crop")}t.layers.set(Bh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(y1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new gn({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ci?i.layers.enable(Bh):i.layers.disable(Bh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new Mt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new QS(e,i)),this.exposureAccumulation.resize(e,i),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 i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+Fe.EXPOSURE_BUDGET_MS,s=Fe.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let r=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,i),this.exposureInstantsDone++,r++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&r<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(pn.uRodShare.value=this.scatteredSky?.rodShare??0,pn.uHasOverlay.value=1,pn.uRelativeScale.value=this.relativeScale,this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new ys,e=new In(-1,1,1,-1,0,2),i=Lc/(rm*Math.tan(om*Bi/2));for(const s of this.compassSprites){if(!s.visible)continue;const r=s.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(r);if(!o)continue;const c=new Fr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Mn,i=new D,n=this.decorObjects.filter(r=>r.track?.length||r.kind==="aircraft"||r.kind==="vehicle").map(r=>this.decorGroups.get(r.id)),s=this.bodySystem.reflectors.map(r=>r.holder);for(const r of[...n,...s]){if(!r?.visible||(e.setFromObject(r),e.isEmpty())||e.distanceToPoint(this.camera.position)<Fe.MAP_SUBJECT_NEAREST_M)continue;let o=1/0,c=-1/0,l=1/0,h=-1/0;for(const u of[e.min.x,e.max.x])for(const d of[e.min.y,e.max.y])for(const f of[e.min.z,e.max.z]){i.set(u,d,f).sub(this.camera.position).normalize();const p=this.screenPointOf(i);if(!p)continue;const v=(p.ndcX+1)/2,m=(1-p.ndcY)/2;o=Math.min(o,v),c=Math.max(c,v),l=Math.min(l,m),h=Math.max(h,m)}Number.isFinite(o)&&t.push({x:o,y:l,width:c-o,height:h-l})}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 Mt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new fo(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new Mt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new v0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Mt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new mi(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new Mt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.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 D)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return mi.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*Bi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new D;screenPointQuaternion=new sn;screenPointSize=new Mt;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 i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(jp),this.camera.layers.set(jp),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of lm)this.isSunOccluded(e[0],e[1])||t++;return t/lm.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const r=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return r!==void 0&&r.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,_=t.z+e.z*m-s.position.z;if(Math.hypot(g,_)<=this.groundRadius)return!0}}const r=this.terrainMesh;if(!r)return!1;const o=r.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[r.position.x+o.getX(0),r.position.x+o.getX(c-1)],h=[r.position.z+o.getZ(0),r.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,_]of[[t.x,e.x,l],[t.z,e.z,h]]){const w=Math.min(_[0],_[1]),M=Math.max(_[0],_[1]);if(Math.abs(g)<1e-12){if(m<w||m>M)return!1;continue}const S=(w-m)/g,b=(M-m)/g;d=Math.max(d,Math.min(S,b)),f=Math.min(f,Math.max(S,b))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,_=t.x+e.x*g,w=t.y+e.y*g,M=t.z+e.z*g;if(w<=this.groundYUnder(_,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=tm;let n,s;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(r.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(im*this.camera.fov*Math.PI/180);let s,r=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>r&&(r=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,tm)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,r])=>r===s);)s=s.parent;return i.find(([,r])=>r===s)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.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())vi.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 i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),!t&&this.renderer.getPixelRatio()!==this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new Qe(Cc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new _e(new Float32Array(i.count*3),3);for(let r=0;r<i.count;r++){const{altitudeDeg:o,azimuthDeg:c}=i5(i.getX(r),i.getY(r),i.getZ(r)),l=h5(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(r,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new gn({vertexColors:!0,side:Ue,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=em(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new Zd(this.groundRadius,48),i=new Er({color:new st(Hh,Hh,Hh),fog:!0});ya.fadeRim(i,this.groundRadius*.75,this.groundRadius,this.horizonColour),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${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,o])=>`${r}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=ni(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-he.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*mb);const r=e?0:this.weather.highCloudCover??0;return r>0&&(n*=1-he.iceAlphaAt(i,Ic,r,this.cloudFieldOffset)*gb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<Dd){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:c}=ni(e.altitudeDeg,e.azimuthDeg,ln),l=_p(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=Fe.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/ln)**2,v=[0,1,2].map(m=>Math.min(Fe.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new Qe(1,16,16),new gn({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof ds)){this.disposeMesh(f);const m=new ue;m.setAttribute("position",new te(new Float32Array(3),3)),m.setAttribute("color",new te(new Float32Array(3),3)),f=new ds(m,Oe.material(ho[ho.length-1].size)),Oe.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(r,o,c),this.setHitArea(t,r,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,r,o,c,u,i/ln*(180/Math.PI),Fe.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=Nw(),this.lensFlare.uniforms.uOpacity.value=Tb,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 i="moon";if(t.magnitude>e||t.altitudeDeg<Dd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:r}=ni(t.altitudeDeg,t.azimuthDeg,ln),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(or(t.phase.illuminatedFraction,0,1),.01)*Math.PI*($r/ln)**2,h=new st(...c.map(f=>Math.min(Fe.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(or(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Fr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Rm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Fr(new Wc({map:Rm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=$r*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,r),this.setHitArea(i,n,s,r,$r),this.setGlare(i,n,s,r,c,$r/ln*(180/Math.PI))}bentLight(t,e,i=fb){const[n,s,r]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,r/o]}}static litBySky(t,e){return Fe.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,Oe.CONE_SOLID_ANGLE/e)}pointScratch=new Mt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=ce.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=Rn.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let r=this.hitAreas.get(t);if(!r){const c=new Wc({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});r=new Fr(c),this.celestialGroup.add(r),this.hitAreas.set(t,r)}r.position.set(e,i,n);const o=s*db;r.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,i,n,s,r,o=0){if(Ui.radiusDeg(Ui.K*Math.max(...s))<=Math.max(r,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Ui(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,r,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=eo(t.magnitude,e),s=Rh(n);this.cometKey=i,this.setBodyMesh(i,t.position,Wh*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new Zi(ln),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ti,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Ic},0);return}const s=this.lowerCloudCover(),r=le.deckLitUntilDeg(le.DECK_HEIGHT_M),o=t.altitudeDeg>-r?t:e,c=this.bentLight(o,o===t?ii.SUN_MAGNITUDE:e.magnitude),l=le.strength(i,s,o.altitudeDeg,r)*c.scale,{x:h,y:u,z:d}=ni(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??Ic},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(t,e){this.rainbow||(this.rainbow=new ga,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=t.altitudeDeg>0,s=n?t:e,r=this.lowerCloudCover(),o=this.bentLight(s,n?ii.SUN_MAGNITUDE:e.magnitude,pb),c=$i.strength(i,r,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ni(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Us,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=wn.galactic(i,n),r=Fe.directionOf(s.centre),o=Fe.directionOf(s.rotation),c=Fe.directionOf(s.pole),l=new Xt().set(r.x,r.y,r.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Fe.directionOf(wn.eclipticPole(i,n)),u=Fe.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:Fe.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Yt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new D(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=ni(t.altitudeDeg,t.azimuthDeg,1);return new D(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const r=eo(n.magnitude,e),o=Rh(r);this.setBodyMesh(s,n.position,Wh*(.5+.5*r),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=eo(n.magnitude,e),r=Rh(s),o=qb[n.body]??new st(1,1,1),c=new st(o.r*r,o.g*r,o.b*r),l=Wh*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,r=new An(n,s),o=jh(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=r.position(i.ra[h],i.dec[h]);if(d<nm)continue;const{x:p,y:v,z:m}=ni(d,f,Gh);c.push({x:p,y:v,z:m,brightness:eo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*ce.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of mw){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=r.position(h.raHours,h.decDeg);if(u<nm)continue;const{x:f,y:p,z:v}=ni(u,d,Gh);this.namedStars.push({star:h,direction:new D(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=ho.map((h,u)=>{const d=c.filter(S=>Wg(S.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((S,b)=>{f[b*3]=S.x,f[b*3+1]=S.y,f[b*3+2]=S.z,p[b]=S.brightness,v.set(S.illuminance,b*3),m[b]=S.phase,g[b]=S.speedFactor});const _=new ue;_.setAttribute("position",new te(f,3));const w=new te(new Float32Array(d.length*3),3);_.setAttribute("color",w);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=_):(M=new ds(_,Oe.material(h.size)),Oe.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:w,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}twinkleSeconds=0;updateTwinkle(t){const e=this.relativeScale;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++){const r=m5(i.brightness[s],{phase:i.phase[s],speedFactor:i.speedFactor[s]},t),o=e*r;n[s*3]=i.illuminance[s*3]*o,n[s*3+1]=i.illuminance[s*3+1]*o,n[s*3+2]=i.illuminance[s*3+2]*o}i.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new fr(this.celestialGroup,Xh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(aa[0]+(Kh[0]-aa[0])*e,aa[1]+(Kh[1]-aa[1])*e,aa[2]+(Kh[2]-aa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=ed(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=id(Xh);this.cloudMesh=new Dt(r,n),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:i}=ed(new st(...aa),t,Ic,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(id(Xh*1.04),e),this.cirrusMesh.renderOrder=hm-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 i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?fr.deckOrder(!0,0,1):hm}cloudLayerOffset(){const e=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*qh;return Math.sign(e||1)*Math.max(Math.abs(e),Db)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,r,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*Jh*this.relativeScale/Math.PI,l=new st(e[0]+zn.r*c,e[1]+zn.g*c,e[2]+zn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,r,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,r*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=um[t],i=e.poolSize,n=jh(9001),s=new Float32Array(i*3),r=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let w=0;w<i;w++){const M=n()*Math.PI*2,S=n()*e.radiusM;s[w*3]=Math.cos(M)*S,s[w*3+1]=er+n()*(e.topYM-er),s[w*3+2]=Math.sin(M)*S,r[w]=n()*Math.PI*2,o[w]=.7+n()*.6,c[w]=.6+n()*.8,l[w]=.4+n()*1.2}const v=new ue;v.setAttribute("position",new te(s,3)),v.setDrawRange(0,Zh(i,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:Yb(t)},uNearFocusDistance:{value:ym},uHazeDistance:{value:e.radiusM*_m}},g=new ae({uniforms:m,vertexShader:Qb,fragmentShader:tE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const _=new ds(v,g);_.renderOrder=Yh,this.scene.add(_),this.precipitationPoints=_,this.precipitationPositions=s,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=um[i];if(this.precipitationUniforms?.uColor.value.copy(Fe.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*Bi,r=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,_=i==="snow"&&u&&d,w=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,S=0;M<c.length;M+=3,S++){if(w&&f[S]>0){if(f[S]-=e,f[S]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[S]=0}else{const x=1-f[S]/v[S];c[M+1]=er+Math.sin(Math.PI*x)*p[S],c[M]=Nc(c[M]+(r+m[S])*e,n.radiusM),c[M+2]=Nc(c[M+2]+(o+g[S])*e,n.radiusM)}continue}let b=0,T=0;if(_){const x=kb*u[S],A=zb*d[S];b=Math.sin(t*x*Math.PI*2+l[S])*A,T=Math.sin(t*x*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(r+b)*e,c[M+1]-=n.fallSpeedMPerS*h[S]*e,c[M+2]+=(o+T)*e,c[M]=Nc(c[M],n.radiusM),c[M+2]=Nc(c[M+2],n.radiusM),c[M+1]<er){if(w){p[S]=Am*(.2+Math.random()*1.6),v[S]=Bb*(.5+Math.random()),f[S]=v[S];const I=Math.random()*Math.PI*2,C=Hb*(p[S]/Am);m[S]=Math.cos(I)*C,g[S]=Math.sin(I)*C,c[M+1]=er;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=mm(this.weather.precipitationIntensity);this.rainSystem=Cw({count:dm,radiusM:Zr,heightM:Ib,bottomYM:fm,overallSpeed:Pb,color:gm.clone(),opacity:.85,visibleCount:Zh(dm,this.weather.precipitationIntensity),speedStreak:Ub(t),pixelSize:wm,seed:9001,nearFocusDistanceM:ym,hazeDistanceM:Zr*_m,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Yh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=jh(4242),e=new Float32Array(ja*3),i=new Float32Array(ja),n=new Float32Array(ja),s=new Float32Array(ja);for(let h=0;h<ja;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*Zr;e[h*3]=Math.cos(u)*d,e[h*3+1]=fm,e[h*3+2]=Math.sin(u)*d,n[h]=Tm(vm,Mm),i[h]=t()*n[h],s[h]=i[h]/n[h]}const r=new ue;r.setAttribute("position",new te(e,3));const o=new te(s,1);r.setAttribute("aLife",o),r.setDrawRange(0,Zh(ja,this.weather.precipitationIntensity));const c=new ae({uniforms:{uMaxSize:{value:Fb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:xm.clone()},uTexture:{value:Zb()}},vertexShader:Jb,fragmentShader:jb,transparent:!0,depthWrite:!1}),l=new ds(r,c);l.renderOrder=Yh,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*Bi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-mm(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(Fe.litBySky(gm,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(Fe.litBySky(xm,this.baseFogColor));const n=this.weather.windDirectionDeg*Bi,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,o=Zr,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+r*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=bm+(1-bm)*(1-l),u=Em+(1-Em)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=wm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:r}=e,o=r.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Zr;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Tm(vm,Mm),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=oi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(Wb/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*Jh*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+zn.r*l,this.airlight[1]+zn.g*l,this.airlight[2]+zn.b*l)}const r=this.skyMesh?.material?.color;if(r){const c=s*Xb;r.setRGB(1+c*zn.r,1+c*zn.g,1+c*zn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*Jh*this.relativeScale,e){const{x:c,y:l,z:h}=ni(25,e.azimuthDeg,ln);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Fs(ln*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){const t=jc(navigator.languages,yb),e=xb[t];this.compassSprites=Mb.map((i,n)=>{const s=e[n],r=new Wc({map:eE(s),depthTest:!1,fog:!1}),o=new Fr(r),{x:c,y:l,z:h}=ni(0,i,rm);return o.position.set(c,l,h),o.scale.set(Lc,Lc,1),o.renderOrder=wb,o.layers.set(Qp),o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=om*Math.PI/360,i=Lc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,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 i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const Bi=Math.PI/180;function or(a,t,e){return Math.max(t,Math.min(e,a))}function Tm(a,t){return a+Math.random()*(t-a)}function Nc(a,t){return(a%(t*2)+t*3)%(t*2)-t}let Oc,Uc;function Yb(a){switch(a){case"snow":return Kb();case"hail":return $b()}}function Kb(){if(Oc)return Oc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Oc=new ws(t),Oc}function $b(){if(Uc)return Uc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Uc=new ws(t),Uc}let Fc;function Zb(){if(Fc)return Fc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Fc=new ws(t),Fc}const Jb=`
|
|
7018
|
+
`,transparent:!0,blending:Ci,depthWrite:!1,side:Ue,fog:!1});this.object=new Dt(new Qe(M0.RADIUS,128,32,0,Math.PI*2,0,ce.MAX_ANGLE_RAD),e),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}show(t,e){if(!t||!e){this.object.visible=!1;return}this.towards.set(t.x,t.y,t.z).normalize(),this.object.quaternion.setFromUnitVectors(this.up,this.towards),this.object.material.uniforms.uSource.value.copy(this.towards);for(let i=0;i<ce.STEPS;i++){for(let n=0;n<3;n++)this.texels[i*4+n]=Cn.toHalfFloat(Math.min(e[i*3+n],6e4));this.texels[i*4+3]=Cn.toHalfFloat(1)}this.texture.needsUpdate=!0,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.object.material.dispose(),this.texture.dispose()}}class xl{constructor(t){this.generator=t}static SIZE=128;target=new To(xl.SIZE,{type:ze,generateMipmaps:!1,minFilter:se,magFilter:se});camera=new e0(.1,2e5,this.target);filteredTarget;capturedAtMs=-1/0;capturedVersion;get sharp(){return this.target.texture}get filtered(){return this.filteredTarget?.texture}capture(t,e,i,n=[]){const s=t.shadowMap.autoUpdate;t.shadowMap.autoUpdate=!1;const r=n.map(o=>o.visible);for(const o of n)o.visible=!1;this.camera.position.copy(i),this.camera.update(t,e),n.forEach((o,c)=>{o.visible=r[c]}),t.shadowMap.autoUpdate=s,this.filteredTarget=this.generator.fromCubemap(this.target.texture,this.filteredTarget),this.capturedAtMs=performance.now()}dispose(){this.target.dispose(),this.filteredTarget?.dispose()}}class Ji{static REFRESH_MS=250;generator;eye;probes=new Map;constructor(t){Ji.install(),this.generator=new Ju(t),this.eye=new xl(this.generator)}static decor;refresh(t,e,i,n,s,r,o,c=[],l){for(const v of[...this.probes.keys()])n.some(m=>m.id===v&&m.shiny)||(this.probes.get(v).dispose(),this.probes.delete(v));const h=[{probe:this.eye}];for(const v of n){if(!v.shiny)continue;let m=this.probes.get(v.id);m||(m=new xl(this.generator),this.probes.set(v.id,m)),h.push({probe:m,reflector:v})}const u=performance.now(),d=()=>h.filter(({probe:v})=>v.capturedVersion!==o),f=d().filter(({probe:v})=>u-v.capturedAtMs>=Ji.REFRESH_MS);if(f.length>0){const v=f.reduce((m,g)=>g.probe.capturedAtMs<m.probe.capturedAtMs?g:m);if(v.reflector){const m=v.reflector.holder.getWorldPosition(this.scratch);v.probe.capture(t,e,m,[v.reflector.holder,...s]),Ji.reflectOn(v.reflector.holder,v.probe)}else{v.probe.capture(t,e,i,[...s,...c]),l?.(v.probe.sharp),Ji.decor=v.probe.filtered;for(const m of r)Ji.reflectOn(m,v.probe);for(const m of n)m.shiny||Ji.reflectOn(m.holder,v.probe)}v.probe.capturedVersion=o}const p=d();if(p.length!==0)return Math.max(16,Math.min(...p.map(({probe:v})=>Ji.REFRESH_MS-(u-v.capturedAtMs))))}scratch=new D;static reflectOn(t,e={filtered:Ji.decor}){t.traverse(i=>{const n=i.material;for(const s of Array.isArray(n)?n:n?[n]:[])s instanceof Do?e.sharp&&s.setSurroundings(e.sharp):s instanceof la&&e.filtered&&s.envMap!==e.filtered&&(s.envMap=e.filtered,s.needsUpdate=!0)})}dispose(){this.eye.dispose();for(const t of this.probes.values())t.dispose();this.generator.dispose()}static installed=!1;static install(){if(Ji.installed)return;Ji.installed=!0;const t="iblIrradiance += getIBLIrradiance( geometryNormal );";if(!Wt.lights_fragment_maps.includes(t)){console.warn("Reflections: three's lights_fragment_maps changed; the environment will light diffusely too");return}Wt.lights_fragment_maps=Wt.lights_fragment_maps.replace(t,"// The sky's diffuse light is the hemisphere light's (see Reflections).")}}function cb(a,t){return JSON.stringify(a.cloudLayers)===JSON.stringify(t.cloudLayers)&&a.cloudCover===t.cloudCover&&a.cloudDarkness===t.cloudDarkness&&a.cloudBaseM===t.cloudBaseM&&a.highCloudCover===t.highCloudCover&&a.iceCrystalAlignment===t.iceCrystalAlignment&&a.lowerCloudCover===t.lowerCloudCover&&a.relativeHumidity===t.relativeHumidity&&a.precipitationType===t.precipitationType&&a.precipitationIntensity===t.precipitationIntensity&&a.windDirectionDeg===t.windDirectionDeg&&a.windSpeed===t.windSpeed&&a.storm===t.storm}const Cc=900,Bh=1,jp=4,Qp=5,tm=.5,so=900,lb=6371e3,hb=3e4;function em(a){const t=Math.sqrt(2*lb*Math.max(a,0));return Math.max(so,Math.min(t,hb))}const Hh=.5,Gh=850,im=.03,ln=850,Vh=300,ub=.04,$r=4,Wh=1.5,nm=-1,db=6,Dd=-4,fb=2,pb=20,Ic=2600,mb=.97,gb=.38,Pc=Dd,sm=1500,vb=400,Mb=[0,45,90,135,180,225,270,315],xb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},yb=["en","fr"],_b=2,Sb=16,am=2500,rm=880,Lc=40,om=60,wb=10,bb=1,Eb=150,Ab=55,Tb=.5,Rb=17,cm=.265,lm=[[0,0],...Array.from({length:8},(a,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*cm,Math.sin(e)*cm]})],Xh=700,qh=250/1e3,Db=12,hm=5,Yh=6,aa=[.92,.92,.95],Kh=[.15,.15,.19],um={snow:{fallSpeedMPerS:2,size:.3,color:new st(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new st(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},er=0,$h=0,Cb=150,dm=3e3,Zr=20,Ib=15,fm=er,Pb=40,pm=1,Lb=9;function mm(a){return pm+(Lb-pm)*a}const gm=new st(.75,.82,.92),Nb=10,Ob=.5;function Ub(a){return or(a/Nb,Ob,1)}const ja=200,vm=.18,Mm=.32,Fb=.35,xm=new st(.85,.9,.98),ym=5,_m=.85,Sm=.01;function Zh(a,t){return Math.round(a*(Sm+(1-Sm)*t))}const wm=230,bm=.7,Em=.05,kb=.6,zb=.7,Bb=.15,Am=.35,Hb=3,Gb=1/12,Vb=.5,zn=new st(.82,.86,1),Wb=2500,Xb=1.6,Jh=15,qb={Venus:new st(1,.96,.85),Mars:new st(1,.55,.4),Jupiter:new st(.95,.87,.72),Saturn:new st(.92,.86,.68)};class Fe{renderer;scene=new ys;phenomena=new bn(this.scene);references=new fa(this.scene,()=>this.render());camera;celestialGroup=new De;skyMesh;skyGradientMaterial;scatteredSky;lastAstronomy;skyColoursStale=!1;scatteredSkyFrameId=null;skyHoldUntilMs=void 0;onFirstFrameHold;firstFrameReady(){return(!this.scatteredSky||this.scatteredSky.ambient!==void 0)&&!this.iceHalos?.awaitingFirstDisplay}groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;roadSystem=new hn;roadAttribution;roadWays;statedRoads=[];decorModelProvider=ab[0].create();decorModelToken=0;decorModelCredits=new Map;bodySystem=new oe(t=>this.loadBodyModel(t),()=>this.render(),()=>this.relativeScale);bodyOrigin={x:0,z:0};starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;decorReferencePose;decorCurrentPose;decorTime=0;celestialLight=new Xf(16777215,0);celestialLightTarget=new Pe;skyLight=new PM(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 xh;weather=Om;observerElevationM=0;siteElevationM=0;air=new fn;groundRadius=so;terrainRadius=so;cloudRendering="volume";layeredClouds;cloudLayerOffsetsM={};cloudOffsetM=new D;cloudFieldOffset=new D;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new D;rainLastVerticalFacing=-1;rainViewportSize=new Mt;lightningArmed=!1;lightningFlashes=[];lightningLevel=0;lightningBolt;lightningLight=new Xf(16777215,0);baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new D;sunVisible=!1;lensFlareScratch=new D;sunOcclusionRaycaster=new xh;sunOcclusionDirectionScratch=new D;sunOcclusionRightScratch=new D;sunOcclusionUpScratch=new D;ufoOcclusionRaycaster=new xh;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;finishPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;static exposureInstantsPerFrame(t){return Math.max(3,Math.round(6e6/Math.max(1,t)))}exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;satelliteField;iceHalos;lunarDiffraction;lunarDiffractionKey="";rainbow;skyGlow;cometKey;novaKeys=new Set;constructor(t,e=L2()){this.renderer=new XS({canvas:t,antialias:!0}),this.resolution=new de(Math.min(window.devicePixelRatio||1,2),this.renderer.getContext()),this.renderer.setPixelRatio(this.resolution.pixelRatio),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ro,this.camera=new Vi(60,t.width/Math.max(t.height,1),.1,Cc*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,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=ln-Vh,this.celestialLight.shadow.camera.far=ln+Vh,this.celestialLight.shadow.bias=-.03/(2*Vh),this.celestialLight.shadow.normalBias=ub,this.celestialLight.target=this.celestialLightTarget,this.lightningLight.color.copy(zn),this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight,this.lightningLight),this.scene.add(this.celestialGroup),this.scene.add(this.bodySystem.group),this.scene.add(this.roadSystem.group);const i=new ii(this.renderer,()=>{this.skyColoursStale=!0,this.render()});i.supported?this.scatteredSky=i:i.dispose()}get currentTerrainAttribution(){return this.terrainAttribution}get currentRoadAttribution(){return this.roadAttribution}resize(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*qh,0,t.z*qh);for(const i of[this.cloudUniforms,this.cirrusUniforms])i?.fieldOffset.value.copy(this.cloudFieldOffset);this.iceHalos?.setCloudOffset(this.layeredClouds?.cirrusMask?.offset??this.cloudFieldOffset)}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*Bi,i=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*Bi;if(t.headingDeg!==void 0?this.camera.rotation.set(i,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*Bi,e,"YXZ"):this.camera.rotation.set(i,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(em(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/so),this.camera.far=Math.max(Cc*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const n=li(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=n.x,this.terrainMesh.position.z=n.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.roadSystem.clear(),this.roadAttribution=void 0,this.roadWays=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,i){if(t===void 0||e===void 0)return;const n=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-n)<n*.1){const{x:c,z:l}=li(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Eb*(n/so))return}const s=this.terrainOrigin,r=this.terrainRadius;(!s||s.lat!==t||s.lng!==e)&&(this.roadSystem.clear(),this.roadAttribution=void 0),this.terrainOrigin={lat:t,lng:e},this.terrainRadius=n;const o=++this.terrainBuildToken;yw(t,e,this.terrainProviders,n).then(({mesh:c,attribution:l,originElevationM:h})=>{if(o!==this.terrainBuildToken)return;this.setSiteElevation(h??0);const u=this.terrainMesh,d=s?li(t,e,s.lat,s.lng):void 0;u&&d&&Math.hypot(d.x,d.z)<=r&&(c.position.y=u.position.y+this.groundYOfPatch(u,d.x,d.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=bb,this.terrainMesh=c,this.compileNextFrameOffThread(),this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.decorCurrentPose&&(this.setObserverPose(this.decorCurrentPose),this.updateDecorAnchoring(this.decorReferencePose,this.decorCurrentPose,this.decorTime)),this.buildRoads(t,e,n),this.drapeStatedRoads(),this.render(),i?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),i?.()})}static ROADS_MAX_RADIUS_M=5e3;buildRoads(t,e,i){const n=this.terrainProviders.roads;if(!n||i>Fe.ROADS_MAX_RADIUS_M){this.roadSystem.clear(),this.roadAttribution=void 0;return}const s=this.roadWays;if(s&&s.lat===t&&s.lng===e&&s.radiusM===i){this.drapeRoads(s.ways,t,e,n.contemporary);return}n.getRoads(h1(t,e,i)).then(r=>{this.terrainOrigin?.lat!==t||this.terrainOrigin?.lng!==e||(this.roadWays={lat:t,lng:e,radiusM:i,ways:r},this.drapeRoads(r,t,e,n.contemporary))}).catch(r=>{console.warn("Roads unavailable, drawing none:",r)})}setStatedRoads(t){t!==this.statedRoads&&(this.statedRoads=t,this.drapeStatedRoads(),this.render())}drapeStatedRoads(){const t=this.terrainMesh;t&&(this.roadSystem.group.position.copy(t.position),this.roadSystem.setStated(this.statedRoads,(e,i)=>this.groundYOfPatch(t,e,i)))}drapeRoads(t,e,i,n){const s=this.terrainMesh;s&&(this.roadSystem.group.position.copy(s.position),this.roadSystem.set(t,e,i,(r,o)=>this.groundYOfPatch(s,r,o),n),this.roadAttribution=t.length>0?this.terrainProviders.roads?.attribution:void 0,this.compileNextFrameOffThread(),this.render())}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=Ab*(this.sunArriving[1]/Rb);this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const[t,e,i]=this.sunArriving,n=Math.max(e,1e-30);this.lensFlare.uniforms.uDazzleColour.value.setRGB(t/n,1,i/n),this.lensFlare.uniforms.uVeilStrength.value=Ui.K*e*this.sunUnhiddenFraction}sunArriving=[0,0,0];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(),!cb(this.weather,t)&&(this.weather=t,this.air=fn.of(t),this.applyAir(),this.scatteredSky?.setConditions({aerosolOpticalDepth:t.relativeHumidity===void 0?void 0:Ws.steppedOpticalDepth(t.relativeHumidity)}),this.pumpScatteredSky(),this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lastAstronomy&&(this.buildIceHalos(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildRainbow(this.lastAstronomy.sun,this.lastAstronomy.moon),this.buildLunarDiffraction(this.lastAstronomy.moon)),this.lightningArmed=t.storm&&t.cloudDarkness>=Vb,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(),vi.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const i=vi.build(e,e.lit??!1);this.scene.add(i),this.decorGroups.set(e.id,i),e.kind==="streetlight"&&this.addStreetlightLight(e.id,i),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values(),...this.bodySystem.modelCredits]}get bodyGround(){const{x:t,z:e}=this.bodyOrigin,i=this.groundYUnder(t,e);return{heightAt:(n,s)=>this.groundYUnder(t+n,e-s)-i}}setBodies(t,e=0,i=t.map(r=>r.id),n=[],s){const{x:r,z:o}=this.bodyOrigin,c=this.scatteredSky;this.bodySystem.set(t,{originX:r,originZ:o,originGroundY:this.groundYUnder(r,o),eye:this.camera.position,groundYAt:(h,u)=>this.groundYUnder(h,u),wind:s,light:this.plumeLight(),transmittance:(h,u,d)=>this.transmittanceTo(h,u,d)},e,c?(h,u)=>c.relativeOfLuminance(h,u):void 0,i),this.bodySystem.setSmoke(n,e),this.bodySystem.any&&(this.celestialLight.castShadow=!0);const l=this.bodySystem.furthestFrom(this.camera.position)*1.2;l>this.camera.far&&(this.camera.far=l,this.camera.updateProjectionMatrix())}plumeLight(){const t=this.celestialLight.color,e=this.celestialLight.intensity*.5,i=this.skyLight.color,n=this.skyLight.groundColor,s=this.skyLight.intensity,r=(o,c,l)=>(o*e+(c+l)/2*s)/Math.PI;return[r(t.r,i.r,n.r),r(t.g,i.g,n.g),r(t.b,i.b,n.b)]}bodyOutline(t,e){return this.bodySystem.outlineOf(t,e)}async loadBodyModel(t){const e=t.url?void 0:t.id?await this.decorModelProvider.entry(t.id):void 0,i=t.url??e?.url,n=t.credit??e?.credit;if(!(!i||!n))return{scene:await Jp(i),credit:n,headingOffsetDeg:t.headingOffsetDeg??e?.headingOffsetDeg}}async loadDecorModel(t,e){const i=t.model;if(!(!i||!vi.usesModel(t)))try{const n=i.url?void 0:i.id?await this.decorModelProvider.entry(i.id):void 0,s=i.url??n?.url,r=i.credit??n?.credit;if(!s||!r)return;const o=await Jp(s);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;Ji.reflectOn(o),vi.applyModel(c,t,o,{headingOffsetDeg:i.headingOffsetDeg??n?.headingOffsetDeg,depictedSizeM:n?.sizeM}),this.decorModelCredits.set(t.id,r),this.render()}catch(n){console.warn(`Keeping the built-in shape for decor "${t.id}":`,n)}}updateDecorAnchoring(t,e,i=0){this.decorReferencePose=t,this.decorCurrentPose=e,this.decorTime=i;const n=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?li(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},s=this.decorObjects.find(l=>l.witnessSide!==void 0&&zm(l.kind));if(this.terrainMesh&&this.terrainOrigin&&e?.lat!==void 0&&e.lng!==void 0){const l=li(this.terrainOrigin.lat,this.terrainOrigin.lng,e.lat,e.lng);this.terrainMesh.position.x=l.x-(s?0:this.gaitOffset.eastM),this.terrainMesh.position.z=l.z+(s?0:this.gaitOffset.northM),this.roadSystem.group.position.copy(this.terrainMesh.position)}s||(n.x-=this.gaitOffset.eastM,n.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const r={x:0,z:0};let o=0;if(s){const l=vi.occupantView(s),h=-(s.headingDeg??0)*Bi,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=s.eastM+n.x,p=-s.northM+n.z;r.x=-(f+u),r.z=-(p+d),this.camera.position.y=this.groundYUnder(f,p)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*Bi,-(l.headingDeg+this.indoorLookYawDeg)*Bi,0,"YXZ")}this.bodyOrigin={x:n.x+r.x,z:n.z+r.z},this.placeShadowFrustum();for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=Id(l,i),d=u.eastM+n.x+r.x,f=-u.northM+n.z+r.z,p=this.terrainMesh,v=`${p?.geometry.uuid}:${(d-(p?.position.x??0)).toFixed(3)}:${(f-(p?.position.z??0)).toFixed(3)}:${(p?.position.y??0).toFixed(3)}:${u.headingDeg}:${u.altitudeM}`;if(h.userData.footprintKey!==v&&(h.userData.footprintGroundY=this.groundUnderFootprint(l,d,f,u.headingDeg,u.altitudeM),h.userData.footprintKey=v),h.position.set(d,h.userData.footprintGroundY+u.altitudeM,f),l.kind==="crop"){const m=Math.hypot(d,f);h.visible=m<=Cb}if(u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*Bi),l.kind==="crop"&&h.visible){const m=this.terrainMesh,g=[m?.geometry.uuid,d-(m?.position.x??0),f-(m?.position.z??0),h.position.y-(m?.position.y??0),u.headingDeg,u.altitudeM].map(_=>typeof _=="number"?_.toFixed(4):_).join(":");h.userData.cropGroundKey!==g&&(vi.fitCropToGround(h,(_,w)=>this.groundYUnder(_,w)+u.altitudeM),h.userData.cropGroundKey=g)}o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(Cc*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 i=this.terrainMesh;return i?i.position.y+this.groundYOfPatch(i,t-i.position.x,e-i.position.z):$h}groundYOfPatch(t,e,i){const n=t.geometry.getAttribute("position"),s=Math.round(Math.sqrt(n.count));if(s<2||s*s!==n.count)return $h;const r=n.getX(0),o=n.getX(s-1),c=n.getZ(0),l=n.getZ((s-1)*s),h=or((e-r)/(o-r)*(s-1),0,s-1),u=or((i-c)/(l-c)*(s-1),0,s-1);if(!Number.isFinite(h)||!Number.isFinite(u))return $h;const d=Math.min(Math.floor(h),s-2),f=Math.min(Math.floor(u),s-2),p=h-d,v=u-f,m=(S,b)=>n.getY(S*s+b),g=m(f,d),_=m(f,d+1),w=m(f+1,d),M=m(f+1,d+1);return p+v<=1?g+(_-g)*p+(w-g)*v:M+(w-M)*(1-p)+(_-M)*(1-v)}groundUnderFootprint(t,e,i,n,s=0){return vi.groundUnderFootprint(t,e,i,n,(r,o)=>this.groundYUnder(r,o),s)}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 i of this.decorObjects){const n=this.decorGroups.get(i.id);if(n&&i.lights?.length&&vi.setLights(n,i.lights,t,n.position.distanceTo(this.camera.position),e,this.relativeScale),i.kind!=="streetlight"&&i.kind!=="vehicle")continue;const s=this.decorGroups.get(i.id);if(!s)continue;const r=p2(i,t);vi.setLit(s,i.kind,r,this.relativeScale);const o=this.streetlightLights.get(i.id);o&&(o.visible=r)}}addStreetlightLight(t,e){const i=vi.bodyOf(e),n=i.children.find(r=>r.userData.emissive);if(!n)return;const s=new Cg(16764006,sm*this.relativeScale,vb);s.position.copy(n.position).multiply(i.scale),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){(!this.lastAstronomy||Math.abs(this.lastAstronomy.sun.altitudeDeg-t.sun.altitudeDeg)>2)&&(this.surroundings=void 0,this.scatteredSky?.resetSurroundings()),this.lastAstronomy=t,this.scatteredSky?.update(this.scatteredSkyState(t)),this.skyHoldUntilMs===void 0&&(this.skyHoldUntilMs=performance.now()+am,this.onFirstFrameHold?.(!0),setTimeout(()=>this.render(),am+20)),this.pumpScatteredSky(),this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround();const e=qc(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,e),this.placeBodies(t,e),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.applySkyColours(t),this.syncAnimationLoop(),this.render()}static relativeSkyOf(t,e){const i=r=>{const o=Rn.luminanceOf(r);if(!(o>0))return[0,0,0];const c=Et.relativeOfResponse(o)/o;return[r[0]*c,r[1]*c,r[2]*c]},n=i(t.zenith),s=i(t.horizon);return{zenith:n,horizon:s,airlight:s,skyIrradiance:[n[0]*Math.PI,n[1]*Math.PI,n[2]*Math.PI],scale:e}}placeBodies(t,e){this.bodiesScale=this.relativeScale,this.setBodyMesh("sun",t.sun,$r,new st(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,e),this.buildPlanets(t.planets,e),this.buildComet(t.comet,e),this.buildNovae(t.novae??[],e)}bodiesScale=0;applySkyColours(t){this.skyColoursStale=!1,this.bodiesScale!==this.relativeScale&&(this.placeBodies(t,qc(t.sun.altitudeDeg,this.instrumentMagnitudeGain)),this.applyDazzleStrength(),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon));const e=this.scatteredSky?.ambient??Fe.relativeSkyOf(rd(t.sun.altitudeDeg),this.relativeScale),i=e,n=this.lightUnderClouds(t),s=r=>n?[0,1,2].map(o=>r[o]*n.through+n.radiance[o]*(1-n.through)):[r[0],r[1],r[2]];this.baseFogColor=[i.horizon[0],i.horizon[1],i.horizon[2]],this.airlight=s(i.airlight),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.scatteredSky?.ready?this.scatteredSky.material:this.skyGradientMaterial),this.updateCelestialLight(t,e),this.updateCloudLighting(t.sun,this.baseFogColor),Oe.setEye(this.scatteredSky?.rodShare??0,this.relativeScale),this.updateTwinkle(this.twinkleSeconds);for(const r of this.streetlightLights.values())r.intensity=sm*this.relativeScale;this.buildSkyGlow(t,i.zenith),this.applyAir(),this.buildLunarDiffraction(t.moon)}reflections;sceneVersion=0;reflectionTimer;buildLunarDiffraction(t){const e=this.scatteredSky?.ready?this.scatteredSky:void 0;if(t.altitudeDeg<-.5||!e){this.lunarDiffraction?.show(void 0),this.lunarDiffractionKey="";return}const i=this.weather.relativeHumidity,n=(i===void 0?Ot.DEFAULT_AEROSOL_OPTICAL_DEPTH:Ws.opticalDepth(i))*Ot.aerosolDensity(this.siteElevationM+this.observerElevationM),s=this.cloudTransmission(t),r=-Math.log(Math.max(this.cloudTransmission(t,!0),1e-4)),o=ce.aureoleScale(n,ce.airMass(t.altitudeDeg))*s,c=ce.coronaScale(r),l=ce.illuminanceOf(t.magnitude),h=[t.altitudeDeg.toFixed(1),t.azimuthDeg.toFixed(1),t.magnitude.toFixed(2),o.toExponential(2),c.toExponential(2),Math.log10(Math.max(e.adaptation,1e-12)).toFixed(2)].join(":");if(h===this.lunarDiffractionKey)return;this.lunarDiffractionKey=h,this.lunarDiffraction||(this.lunarDiffraction=new M0,this.celestialGroup.add(this.lunarDiffraction.object));const u=ce.profile(ce.HAZE_COARSE_MODE),d=ce.profile(ce.CLOUD_DROPLETS),f=_p(t.altitudeDeg),p=new Float32Array(ce.STEPS*3);let v=0;for(let w=0;w<ce.STEPS;w++){const M=w*3,S=[0,1,2].map(T=>l*f[T]*(o*u[M+T]+c*d[M+T])),b=Rn.shown(S,Rn.luminanceOf(S),(T,x)=>e.relativeOfLuminance(T,x));p.set(b,M),v=Math.max(v,Rn.response(b))}const{x:m,y:g,z:_}=ni(t.altitudeDeg,t.azimuthDeg,1);this.lunarDiffraction.show(v>1/200?{x:m,y:g,z:_}:void 0,p)}applyAir(){this.scene.fog instanceof ya||(this.scene.fog=new ya),this.scene.fog.setAir(this.air,this.siteElevationM,this.airlight),this.horizonColour.setRGB(this.baseFogColor[0],this.baseFogColor[1],this.baseFogColor[2])}airlight=[0,0,0];horizonColour=new st(0,0,0);transmittanceTo(t,e,i){const n=this.camera.position;return this.air.transmittance(this.siteElevationM+n.y,this.siteElevationM+e,Math.hypot(t-n.x,e-n.y,i-n.z))}setSiteElevation(t){Math.abs(t-this.siteElevationM)<1||(this.siteElevationM=t,this.applyAir(),this.lastAstronomy&&this.scatteredSky?.update(this.scatteredSkyState(this.lastAstronomy)))}scatteredSkyState(t){return{altitudeM:this.siteElevationM+this.observerElevationM+1.6,sun:{altitudeDeg:t.sun.altitudeDeg,azimuthDeg:t.sun.azimuthDeg,magnitude:t.sun.magnitude},moon:{altitudeDeg:t.moon.altitudeDeg,azimuthDeg:t.moon.azimuthDeg,magnitude:t.moon.magnitude,phaseAngleDeg:Yt.phaseAngleOf(t.moon.phase.illuminatedFraction)}}}pumpScatteredSky(){const t=this.scatteredSky;!t||t.tables.ready||this.scatteredSkyFrameId!==null||this.contextReleased||(this.scatteredSkyFrameId=requestAnimationFrame(()=>{this.scatteredSkyFrameId=null,!this.contextReleased&&(t.advance(this.skyHoldUntilMs?Sb:_b),this.pumpScatteredSky())}))}cancelScatteredSkyPump(){this.scatteredSkyFrameId!==null&&(cancelAnimationFrame(this.scatteredSkyFrameId),this.scatteredSkyFrameId=null)}setSatellites(t){if(t.length===0&&!this.satelliteField?.count)return;this.satelliteField||(this.satelliteField=new Ow(Gh),this.celestialGroup.add(this.satelliteField.object));const e=qc(this.lastSunPosition?.altitudeDeg??-90,this.instrumentMagnitudeGain);this.satelliteField.set(t,e,i=>this.cloudTransmission(i),(i,n)=>this.arrivingIlluminance(i,n,1)),this.render()}pickSatelliteAt(t,e){if(!this.satelliteField?.count)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=Math.cos(im*this.camera.fov*Math.PI/180),n=this.satelliteField.nearest(this.raycaster.ray.direction,i);return n&&this.groundHides(t,e)?void 0:n}updateCelestialLight(t,e){const i=this.relativeScale,n=t.sun.altitudeDeg>=Pc,s=!n&&t.moon.altitudeDeg>=Pc,r=n?t.sun:t.moon,o=[0,0,0],c=Math.max(0,Math.sin(Math.max(r.altitudeDeg,0)*Bi)),l=n||s?this.cloudTransmission(r):1,h=-Math.log(Math.max(l,1e-6)),u=Math.max(0,1/(1+.1125*h)-l),d=[0,0,0];if(n||s){const _=ce.illuminanceOf(r.magnitude)*i,w=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,r.altitudeDeg);for(let T=0;T<3;T++)o[T]=_*w[T]*l,d[T]=_*w[T]*u*c,this.cloudBeam[T]=_*w[T];const{x:M,y:S,z:b}=ni(r.altitudeDeg,r.azimuthDeg,1);this.cloudBeamDirection.set(M,S,b)}else this.cloudBeam.fill(0);const f=this.surroundings;if(f)this.skyLight.color.setRGB(f.up[0]*i,f.up[1]*i,f.up[2]*i),this.skyLight.groundColor.setRGB(f.down[0]*i,f.down[1]*i,f.down[2]*i);else{const _=this.skyCloudTransmission(),w=e.skyIrradiance,M=[0,1,2].map(b=>w[b]*_+d[b]);this.skyLight.color.setRGB(M[0],M[1],M[2]);const S=Vt.GROUND_ALBEDO;this.skyLight.groundColor.setRGB(S*(M[0]+o[0]*c),S*(M[1]+o[1]*c),S*(M[2]+o[2]*c))}if(this.skyLight.intensity=1,!n&&!s){this.celestialLight.intensity=0;return}const{x:p,y:v,z:m}=ni(r.altitudeDeg,r.azimuthDeg,1);this.lightDirection.set(p,v,m),this.placeShadowFrustum();const g=Math.max(o[0],o[1],o[2],1e-30);this.celestialLight.color.setRGB(o[0]/g,o[1]/g,o[2]/g),this.celestialLight.intensity=g,this.celestialLight.castShadow=this.decorGroups.size>0||this.bodySystem.any}lightDirection=new D(0,1,0);placeShadowFrustum(){const t=this.lightDirection,e=this.celestialLight.shadow.camera,i=(e.right-e.left)/this.celestialLight.shadow.mapSize.x,n=this.shadowAxisX.crossVectors(this.shadowUp,t);n.lengthSq()<1e-8&&n.set(1,0,0),n.normalize();const s=this.shadowAxisY.crossVectors(t,n).normalize(),r=this.shadowWorld.set(this.bodyOrigin.x,0,this.bodyOrigin.z),o=l=>{const h=r.dot(l)/i;return(h-Math.round(h))*i},c=this.celestialLightTarget.position.set(0,0,0).addScaledVector(n,o(n)).addScaledVector(s,o(s));this.celestialLightTarget.updateMatrixWorld(),this.celestialLight.position.copy(c).addScaledVector(t,ln)}shadowUp=new D(0,1,0);shadowAxisX=new D;shadowAxisY=new D;shadowWorld=new D;skyCloudTransmission(){let t=this.cloudTransmission({altitudeDeg:90,azimuthDeg:0}),e=1;for(const i of[20,45,70]){const n=i*Bi,s=Math.sin(n)*Math.cos(n)*2;for(let r=0;r<360;r+=60)t+=s*this.cloudTransmission({altitudeDeg:i,azimuthDeg:r}),e+=s}return t/e}cloudBeam=[0,0,0];cloudBeamDirection=new D(0,1,0);get relativeScale(){return this.scatteredSky?.relativeScale??1/Et.semiSaturation(Et.DAYLIGHT_ANCHOR_CD_M2)}setMeteorShower(t,e,i){this.meteorSystem||(this.meteorSystem=new pi,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,i)}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=ri.starPointsOf(t),i=ri.flareArtifactsOf(t);e===this.starPoints&&i===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=i,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=i),this.render())}setInstrumentGain(t,e=!1){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0,this.scatteredSky?.setInstrument(e,this.instrumentMagnitudeGain)}render(){this.restatingExposure||(this.sceneVersion++,this.frameDirty=!0,this.resolution.noteChange(performance.now()),!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()})))}drawIfDirty(){if(!(!this.frameDirty||this.contextReleased)){if(this.skyHoldUntilMs){if(!this.firstFrameReady()&&performance.now()<this.skyHoldUntilMs)return;this.skyHoldUntilMs=null,this.iceHalos?.setUrgent(!1),this.onFirstFrameHold?.(!1)}if(this.skyColoursStale&&this.lastAstronomy&&this.applySkyColours(this.lastAstronomy),this.compileBeforeNextDraw){this.compileBeforeNextDraw=!1;const t=this.compileOffThread().then(()=>{this.compiling===t&&(this.compiling=void 0,this.render())});this.compiling=t;return}if(!this.compiling){this.frameDirty=!1,this.refreshReflections(),this.resolution.beginDrawing();try{this.renderOnce()}finally{this.resolution.endDrawing()}this.developingExposure&&this.startExposure()}}}compileBeforeNextDraw=!1;compiling;static COMPILE_WAIT_MS=1500;compileOffThread(){const 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,i=performance.now()+Fe.COMPILE_WAIT_MS;return new Promise(n=>{const s=()=>{if(this.contextReleased)return n();for(const r of t){const o=e.get(r)?.currentProgram;(!o||o.isReady())&&t.delete(r)}t.size===0||performance.now()>i?n():setTimeout(s,10)};s()})}compileNextFrameOffThread(){this.compileBeforeNextDraw=!0}contextReleased=!1;releaseContext(){this.contextReleased||(this.contextReleased=!0,this.stopTwinkle(),this.cancelFlush(),this.cancelExposure(),this.compiling=void 0,this.cancelScatteredSkyPump(),this.renderer.forceContextLoss())}restoreContext(){this.contextReleased&&(this.contextReleased=!1,this.renderer.forceContextRestore(),this.scatteredSky?.invalidate(),this.pumpScatteredSky(),this.compileNextFrameOffThread(),this.syncAnimationLoop(),this.render())}cancelFlush(){this.flushFrameId!==null&&(cancelAnimationFrame(this.flushFrameId),this.flushFrameId=null)}frame(t){if(this.animationsRunning){const e=this.lastFrameTimeMs===void 0?0:t-this.lastFrameTimeMs;this.lastFrameTimeMs=t,this.hasAnimations()&&this.animate(t,e);const i=this.resolution.ratioFor(t,e);i!==this.renderer.getPixelRatio()&&this.applyPixelRatio(i)}this.drawIfDirty()}refreshReflections(){this.reflections??=new Ji(this.renderer);const t=[...this.compassSprites,...this.lensFlare?[this.lensFlare.mesh]:[],...[...this.glareSprites.values()].map(s=>s.mesh)],e=[...this.starTiers.map(s=>s.points),...[...this.bodyMeshes.values()].filter(s=>s instanceof ds),...[this.rainSystem?.points,this.precipitationPoints,this.rainSplashSystem?.points].filter(s=>s!==void 0)],i=this.relativeScale,n=this.reflections.refresh(this.renderer,this.scene,this.camera.position,this.bodySystem.reflectors,t,[...this.decorGroups.values()],this.sceneVersion,e,s=>this.measureSurroundings(s,i));n===void 0||this.reflectionTimer||(this.reflectionTimer=setTimeout(()=>{this.reflectionTimer=void 0,this.frameDirty=!0,!(this.animationFrameId!==null||this.framesDriven||this.flushFrameId!==null)&&(this.flushFrameId=requestAnimationFrame(()=>{this.flushFrameId=null,this.drawIfDirty()}))},n))}measureSurroundings(t,e){const i=this.lastAstronomy;if(!i)return;this.probeIrradiance??=new uo;const n=[i.sun,i.moon].filter(s=>s.altitudeDeg>-2).map(s=>ni(s.altitudeDeg,s.azimuthDeg,1));this.probeIrradiance.measure(this.renderer,t,n,s=>{const r=d=>d.map(f=>f/e),o=this.surroundings,c={up:r(s.up),down:r(s.down)},l=(d,f)=>d.some((p,v)=>Math.abs(p-f[v])>.03*Math.max(Math.abs(p),Math.abs(f[v]),1e-12)),h=!o||l(o.up,c.up)||l(o.down,c.down);h&&(this.surroundings=c);const u=this.scatteredSky?.adaptToSurroundings(Math.exp(s.logAverage)/e)??!1;!h&&!u||(this.skyColoursStale=!0,this.render())})}lightUnderClouds(t){const e=this.surroundings;if(!e)return;const i=t.sun.altitudeDeg>=Pc?t.sun:t.moon.altitudeDeg>=Pc?t.moon:void 0;if(!i)return;const n=this.relativeScale/Math.PI;return{through:this.cloudTransmission(i),radiance:[e.up[0]*n,e.up[1]*n,e.up[2]*n]}}probeIrradiance;surroundings;animate(t,e){const i=Math.min(e/1e3,Gb);this.twinkleSeconds=t/1e3,this.updateTwinkle(this.twinkleSeconds),this.updatePrecipitation(t/1e3,i),this.updateRain(i),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.maximum&&this.applyPixelRatio(this.resolution.maximum)}applyPixelRatio(t){this.renderer.setPixelRatio(t),this.renderer.setSize(this.cssSize.width,this.cssSize.height,!1),this.frameDirty=!0}setExposure(t,e){const i=e?Math.max(1,Math.round(t)):1;if(i===this.exposureInstants&&(i===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=i,this.exposureInstantAt=e,i===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,o,c)=>this.directionAtScreenPoint(r,o,c),r=>this.screenPointOf(r)),this.references.place(this.camera);const i=Math.max(this.phenomena.furthestM,this.references.furthestM)*1.2;i>this.camera.far&&(this.camera.far=i,this.camera.updateProjectionMatrix()),pn.uRodShare.value=this.scatteredSky?.rodShare??0,pn.uRelativeScale.value=this.relativeScale;const n=this.references.any||this.phenomena.any||this.compassSprites.some(r=>r.visible);pn.uHasOverlay.value=n?1:0;const s=n?r=>this.renderOverlayPasses(r):void 0;if(this.skyGlow?.setDestinationEncoded(!1),!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?r.render(this.renderer,this.scene,this.camera,s,t):this.usableFinishPass().render(this.renderer,this.scene,this.camera,s,void 0,t);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),s,r=>{this.lensFlare&&(this.lensFlare.mesh.visible=r?!1:this.sunVisible)},()=>this.renderDazzleOnResample(),t)}renderOverlayPasses(t=this.camera){this.renderReferencesPass(t),this.renderPhenomenaPass(t),this.renderHudPass(t)}renderHudPass(t){if(!this.compassSprites.some(n=>n.visible))return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(Qp),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}renderReferencesPass(t){if(!this.references.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,t.layers.set(_1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}setReferences(t){this.references.set(t)}referenceAspect(t){return this.references.aspectOf(t)}directionAt(t,e){return this.directionAtScreenPoint(t,e,new D)}referenceFailedToLoad(t){return this.references.failedToLoad(t)}setReferencesShown(t){this.references.setShown(t),this.render()}setReferenceView(t,e){this.references.setView(t,e),this.render()}renderPhenomenaPass(t){if(!this.phenomena.any)return;const e=this.renderer.autoClear,i=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const s=this.decorGroups.get(n.id);s&&Fe.markDecorDepth(s,n.kind!=="crop")}t.layers.set(Bh),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,t),this.scene.overrideMaterial=null,t.layers.set(y1),this.renderer.render(this.scene,t),t.layers.set(0),this.renderer.autoClear=e,this.renderer.shadowMap.autoUpdate=i}decorDepthMaterial=new gn({colorWrite:!1});static markDecorDepth(t,e){t.traverse(i=>{if(!(i instanceof Dt))return;const n=Array.isArray(i.material)?i.material[0]:i.material;e&&n.depthWrite!==!1&&n.blending!==Ci?i.layers.enable(Bh):i.layers.disable(Bh)})}startExposure(){this.cancelExposure(),this.exposureSubjectBounds=[];const t=this.renderer.getDrawingBufferSize(new Mt),e=Math.max(1,Math.round(t.x)),i=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new QS(e,i)),this.exposureAccumulation.resize(e,i),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 i=1/this.exposureInstants;this.resolution.beginDrawing();const n=performance.now()+Fe.EXPOSURE_BUDGET_MS,s=Fe.exposureInstantsPerFrame(e.instantTarget.scene.width*e.instantTarget.scene.height);let r=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,i),this.exposureInstantsDone++,r++}while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<n&&r<s);this.restateAt(t,0),this.presentExposure(),this.resolution.endDrawing(),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}presentExposure(){if(pn.uRodShare.value=this.scatteredSky?.rodShare??0,pn.uHasOverlay.value=1,pn.uRelativeScale.value=this.relativeScale,this.exposureAccumulation?.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.onMapSubjectBounds?.(this.exposureSubjectBounds),!this.compassSprites.some(s=>s.visible))return;const t=new ys,e=new In(-1,1,1,-1,0,2),i=Lc/(rm*Math.tan(om*Bi/2));for(const s of this.compassSprites){if(!s.visible)continue;const r=s.getWorldPosition(new D).sub(this.camera.position).normalize(),o=this.screenPointOf(r);if(!o)continue;const c=new Fr(s.material);c.position.set(o.ndcX,o.ndcY,-1),c.scale.set(i/this.camera.aspect,i,1),t.add(c)}const n=this.renderer.autoClear;this.renderer.autoClear=!1;try{this.renderer.render(t,e)}finally{this.renderer.autoClear=n}}onMapSubjectBounds;exposureSubjectBounds=[];static MAP_SUBJECT_NEAREST_M=8;mapSubjectBounds(){const t=[],e=new Mn,i=new D,n=this.decorObjects.filter(r=>r.track?.length||r.kind==="aircraft"||r.kind==="vehicle").map(r=>this.decorGroups.get(r.id)),s=this.bodySystem.reflectors.map(r=>r.holder);for(const r of[...n,...s]){if(!r?.visible||(e.setFromObject(r),e.isEmpty())||e.distanceToPoint(this.camera.position)<Fe.MAP_SUBJECT_NEAREST_M)continue;let o=1/0,c=-1/0,l=1/0,h=-1/0;for(const u of[e.min.x,e.max.x])for(const d of[e.min.y,e.max.y])for(const f of[e.min.z,e.max.z]){i.set(u,d,f).sub(this.camera.position).normalize();const p=this.screenPointOf(i);if(!p)continue;const v=(p.ndcX+1)/2,m=(1-p.ndcY)/2;o=Math.min(o,v),c=Math.max(c,v),l=Math.min(l,m),h=Math.max(h,m)}Number.isFinite(o)&&t.push({x:o,y:l,width:c-o,height:h-l})}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 Mt),i=Math.max(1,Math.round(e.x)),n=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new fo(i,n)),this.depthOfFieldPass.resize(i,n),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableFinishPass(){const t=this.renderer.getDrawingBufferSize(new Mt);return this.finishPass?this.finishPass.resize(t.x,t.y):this.finishPass=new v0(t.x,t.y),this.finishPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Mt);return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new mi(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,i){const n=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!n){t.setFromCamera(new Mt(e,i),this.camera);return}const s=n.directionFor(e,i,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(s.x,s.y,s.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 D)}directionAtScreenPoint(t,e,i){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),i.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert()),i=this.renderer.getDrawingBufferSize(this.screenPointSize),n=i.x/Math.max(i.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return mi.ndcFor(e,this.camera.fov,n);if(e.z>=0)return;const s=Math.tan(this.camera.fov/2*Bi);return{ndcX:e.x/-e.z/(n*s),ndcY:e.y/-e.z/s}}screenPointScratch=new D;screenPointQuaternion=new sn;screenPointSize=new Mt;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 i=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(i.x,i.y);const n=this.renderer.domElement.width,s=this.renderer.domElement.height;t.uniforms.uResolution.value.set(n,s),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}renderDazzleOnResample(){const t=this.lensFlare;if(!t||!this.sunVisible)return;const e=this.sunVisibleFraction();if(e<=0)return;this.sunUnhiddenFraction=e,this.applyDazzleStrength();const i=this.screenPointOf(this.lensFlareScratch.copy(this.sunWorldPosition).sub(this.camera.position).normalize());if(!i)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize);t.uniforms.uLensPosition.value.set(i.ndcX,i.ndcY),t.uniforms.uResolution.value.set(n.x,n.y),t.uniforms.uEquidistant.value=1,t.uniforms.uHalfFovRad.value=this.camera.fov*Math.PI/360;const s=this.renderer.autoClear;this.renderer.autoClear=!1,t.mesh.visible=!0,t.mesh.layers.enable(jp),this.camera.layers.set(jp),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),t.mesh.visible=!1,t.uniforms.uEquidistant.value=0,this.renderer.autoClear=s}sunVisibleFraction(){this.raycastableDecor().length>0&&this.scene.updateMatrixWorld();let t=0;for(const e of lm)this.isSunOccluded(e[0],e[1])||t++;return t/lm.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const i=this.decorGroups.get(e.id);i&&t.push(i)}return t}isSunOccluded(t=0,e=0){const i=this.raycastableDecor();if(!this.groundMesh&&!this.terrainMesh&&i.length===0)return!1;const n=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),s=n.length();if(n.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(n.z,0,-n.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,n).normalize();n.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}if(this.groundBlocks(this.camera.position,n,s))return!0;if(i.length===0)return!1;this.sunOcclusionRaycaster.set(this.camera.position,n);const r=this.sunOcclusionRaycaster.intersectObjects(i,!0)[0];return r!==void 0&&r.distance<s}groundBlocks(t,e,i,n=0){const s=this.groundMesh;if(s&&e.y<0){const m=(s.position.y-t.y)/e.y;if(m>n&&m<i){const g=t.x+e.x*m-s.position.x,_=t.z+e.z*m-s.position.z;if(Math.hypot(g,_)<=this.groundRadius)return!0}}const r=this.terrainMesh;if(!r)return!1;const o=r.geometry.getAttribute("position"),c=Math.round(Math.sqrt(o.count));if(c<2||c*c!==o.count)return!1;const l=[r.position.x+o.getX(0),r.position.x+o.getX(c-1)],h=[r.position.z+o.getZ(0),r.position.z+o.getZ((c-1)*c)],u=Math.min(Math.abs(l[1]-l[0]),Math.abs(h[1]-h[0]))/(c-1);if(!(u>0))return!1;let d=n,f=i;for(const[m,g,_]of[[t.x,e.x,l],[t.z,e.z,h]]){const w=Math.min(_[0],_[1]),M=Math.max(_[0],_[1]);if(Math.abs(g)<1e-12){if(m<w||m>M)return!1;continue}const S=(w-m)/g,b=(M-m)/g;d=Math.max(d,Math.min(S,b)),f=Math.min(f,Math.max(S,b))}if(!(f>d))return!1;const p=Math.hypot(e.x,e.z),v=Math.min(4096,Math.max(8,Math.ceil((f-d)*p/(u/2))));for(let m=0;m<=v;m++){const g=d+(f-d)*m/v,_=t.x+e.x*g,w=t.y+e.y*g,M=t.z+e.z*g;if(w<=this.groundYUnder(_,M))return!0}return!1}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,i){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=tm;let n,s;for(const r of this.decorObjects){if(r.kind==="crop")continue;const o=this.decorGroups.get(r.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(r.occludesSourceIds?.includes(i)?n=n===void 0?c.distance:Math.max(n,c.distance):s=s===void 0?c.distance:Math.min(s,c.distance))}return{behindM:n,inFrontM:s}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.hitAreas.entries()],n=this.raycaster.intersectObjects(i.map(([,s])=>s))[0];if(n&&!this.groundHides(t,e))return i.find(([,s])=>s===n.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const i=this.raycaster.ray.direction,n=Math.cos(im*this.camera.fov*Math.PI/180);let s,r=n;for(const o of this.namedStars){const c=o.direction.dot(i);c>r&&(r=c,s={star:o.star,altitudeDeg:o.altitudeDeg})}return s&&this.groundHides(t,e)?void 0:s}groundHides(t,e){if(!this.terrainMesh&&!this.groundMesh)return!1;this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e);const i=this.ufoOcclusionRaycaster.ray;return this.groundBlocks(i.origin,i.direction,1/0,tm)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const i=[...this.decorGroups.entries()],n=this.raycaster.intersectObjects(i.map(([,r])=>r),!0)[0];if(!n)return;let s=n.object;for(;s&&!i.some(([,r])=>r===s);)s=s.parent;return i.find(([,r])=>r===s)?.[0]}dispose(){this.stopTwinkle(),this.cancelFlush(),this.phenomena.clear(),this.references.disposeAll(),this.terrainBuildToken++,this.cancelScatteredSkyPump(),this.skyMesh&&this.skyGradientMaterial&&(this.skyMesh.material=this.skyGradientMaterial),this.scatteredSky?.dispose(),this.scatteredSky=void 0,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.roadSystem.dispose(),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.finishPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0,this.satelliteField?.dispose(),this.satelliteField=void 0,this.lightningBolt?.dispose(),this.lightningBolt=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear(),this.novaKeys.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())vi.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 i=t&&e;if(t===this.animationsRunning&&i===this.framesDriven)return;const n=this.animationsRunning;this.animationsRunning=t,this.framesDriven=i,t&&!n&&(this.lastFrameTimeMs=void 0,this.resolution.reset()),!t&&this.renderer.getPixelRatio()!==this.resolution.maximum&&this.applyPixelRatio(this.resolution.maximum),this.syncAnimationLoop(),(!t||this.frameDirty)&&this.render()}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}needsAnimationLoop(){return this.animationsRunning&&!this.framesDriven&&this.hasAnimations()}hasAnimations(){return this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lensFlare!==void 0&&this.sunVisible}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){const e=this.skyMesh?.geometry??new Qe(Cc,32,16),i=e.attributes.position,n=e.getAttribute("color")??new _e(new Float32Array(i.count*3),3);for(let r=0;r<i.count;r++){const{altitudeDeg:o,azimuthDeg:c}=i5(i.getX(r),i.getY(r),i.getZ(r)),l=h5(o,c,t.azimuthDeg,t.altitudeDeg);n.setXYZ(r,l[0],l[1],l[2])}if(n.needsUpdate=!0,this.skyMesh)return;e.setAttribute("color",n);const s=new gn({vertexColors:!0,side:Ue,fog:!1,depthWrite:!1});this.skyGradientMaterial=s,this.skyMesh=new Dt(e,s),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){const t=em(this.observerElevationM);if(this.groundMesh&&t===this.groundRadius)return;this.disposeMesh(this.groundMesh),this.groundRadius=t;const e=new Zd(this.groundRadius,48),i=new Er({color:new st(Hh,Hh,Hh),fog:!0});ya.fadeRim(i,this.groundRadius*.75,this.groundRadius,this.horizonColour),this.groundMesh=new Dt(e,i),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t,e=!1){const i=`${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,o])=>`${r}=${Math.round(o.x/10)},${Math.round(o.z/10)}`).join(";")+(e?":water":""),n=this.cloudTransmissionMemo.get(i);if(n!==void 0)return n;this.cloudTransmissionMemo.size>256&&this.cloudTransmissionMemo.clear();const s=this.computeCloudTransmission(t,e);return this.cloudTransmissionMemo.set(i,s),s}cloudTransmissionMemo=new Map;computeCloudTransmission(t,e=!1){const i=ni(t.altitudeDeg,t.azimuthDeg,1);if(this.layeredClouds)return this.layeredClouds.transmissionAt(i,e);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-he.alphaAt(i,Math.abs(this.cloudLayerOffset()),s,this.cloudFieldOffset)*mb);const r=e?0:this.weather.highCloudCover??0;return r>0&&(n*=1-he.iceAlphaAt(i,Ic,r,this.cloudFieldOffset)*gb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,i,n,s){if(e.altitudeDeg<Dd){this.disposeMesh(this.bodyMeshes.get(t)),this.bodyMeshes.delete(t),this.disposeHitArea(t),this.disposeGlare(t),t==="sun"&&(this.sunVisible=!1);return}const{x:r,y:o,z:c}=ni(e.altitudeDeg,e.azimuthDeg,ln),l=_p(e.altitudeDeg),h=this.cloudTransmission(e),u=this.arrivingIlluminance(e,s,h),d=Fe.unitLuminance(n);let f=this.bodyMeshes.get(t);if(t==="sun"){const p=Math.PI*(i/ln)**2,v=[0,1,2].map(m=>Math.min(Fe.BRIGHTEST_RELATIVE,d[m]*u[m]/p));f instanceof Dt||(this.disposeMesh(f),f=new Dt(new Qe(1,16,16),new gn({fog:!1})),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)),f.material.color.setRGB(v[0],v[1],v[2]),f.scale.setScalar(i)}else{if(!(f instanceof ds)){this.disposeMesh(f);const m=new ue;m.setAttribute("position",new te(new Float32Array(3),3)),m.setAttribute("color",new te(new Float32Array(3),3)),f=new ds(m,Oe.material(ho[ho.length-1].size)),Oe.track(f),this.celestialGroup.add(f),this.bodyMeshes.set(t,f)}const p=f.geometry.getAttribute("color"),v=t.startsWith("comet:")?this.pointToPixel():1;p.setXYZ(0,d[0]*u[0]*v,d[1]*u[1]*v,d[2]*u[2]*v),p.needsUpdate=!0}if(f.position.set(r,o,c),this.setHitArea(t,r,o,c,i),t==="sun"&&(this.sunArriving=u),t.startsWith("comet:")?this.disposeGlare(t):t!=="sun"&&this.setGlare(t,r,o,c,u,i/ln*(180/Math.PI),Fe.POINT_VEIL_HOLD_DEG),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(r*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=Nw(),this.lensFlare.uniforms.uOpacity.value=Tb,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 i="moon";if(t.magnitude>e||t.altitudeDeg<Dd){this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i);return}const{x:n,y:s,z:r}=ni(t.altitudeDeg,t.azimuthDeg,ln),o=this.cloudTransmission(t),c=this.arrivingIlluminance(t,t.magnitude,o),l=Math.max(or(t.phase.illuminatedFraction,0,1),.01)*Math.PI*($r/ln)**2,h=new st(...c.map(f=>Math.min(Fe.BRIGHTEST_RELATIVE,f/l))),u=`${t.phase.phaseFraction<.5}:${Math.round(or(t.phase.illuminatedFraction,0,1)*500)}`;let d=this.bodyMeshes.get(i);if(d instanceof Fr)d.userData.phaseKey!==u&&(d.material.map?.dispose(),d.material.map=Rm(t.phase),d.userData.phaseKey=u),d.material.color.copy(h);else{this.disposeMesh(d),d=new Fr(new Wc({map:Rm(t.phase),color:h,fog:!1})),d.userData.phaseKey=u;const f=$r*2;d.scale.set(f,f,1),this.celestialGroup.add(d),this.bodyMeshes.set(i,d)}d.position.set(n,s,r),this.setHitArea(i,n,s,r,$r),this.setGlare(i,n,s,r,c,$r/ln*(180/Math.PI))}bentLight(t,e,i=fb){const[n,s,r]=this.arrivingIlluminance(t,e,1),o=Math.max(s,1e-30);return{scale:s/i,tint:[n/o,1,r/o]}}static litBySky(t,e){return Fe.litScratch.setRGB(t.r*e[0],t.g*e[1],t.b*e[2])}static litScratch=new st;pointToPixel(){const t=Math.max(1,this.renderer.getDrawingBufferSize(this.pointScratch).y),e=(this.camera.fov*Math.PI/180/t)**2;return Math.min(1,Oe.CONE_SOLID_ANGLE/e)}pointScratch=new Mt;static POINT_VEIL_HOLD_DEG=.25;static BRIGHTEST_RELATIVE=6e4;arrivingIlluminance(t,e,i){const n=this.air.transmittanceFromSpace(this.siteElevationM+this.observerElevationM,t.altitudeDeg),s=ce.illuminanceOf(e)*i*this.relativeScale;return[n[0]*s,n[1]*s,n[2]*s]}static unitLuminance(t){const e=Rn.luminanceOf([t.r,t.g,t.b]);return e>0?[t.r/e,t.g/e,t.b/e]:[1,1,1]}setHitArea(t,e,i,n,s){let r=this.hitAreas.get(t);if(!r){const c=new Wc({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1});r=new Fr(c),this.celestialGroup.add(r),this.hitAreas.set(t,r)}r.position.set(e,i,n);const o=s*db;r.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,i,n,s,r,o=0){if(Ui.radiusDeg(Ui.K*Math.max(...s))<=Math.max(r,o)){this.disposeGlare(t);return}let c=this.glareSprites.get(t);c||(c=new Ui(`veil:${t}`),this.celestialGroup.add(c.mesh),this.glareSprites.set(t,c)),c.shine({x:e,y:i,z:n},s,r,o)}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.mesh.removeFromParent(),e.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const i=t&&`comet:${t.id}`;if(!t||!i||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==i&&this.disposeComet();const n=eo(t.magnitude,e),s=Rh(n);this.cometKey=i,this.setBodyMesh(i,t.position,Wh*(.5+.5*n),new st(s,s,s),t.magnitude),this.cometTail||(this.cometTail=new Zi(ln),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,n)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Ti,this.iceHalos.setCloudOffset(this.cloudFieldOffset),this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object)),this.iceHalos.setUrgent(!!this.skyHoldUntilMs);const i=this.highCloudCover(),n=this.layeredClouds?.cirrusMask;if(this.iceHalos.setCloudOffset(n?.offset??this.cloudFieldOffset),this.layeredClouds?.hostHalo(this.iceHalos),i===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:Ic},0);return}const s=this.lowerCloudCover(),r=le.deckLitUntilDeg(le.DECK_HEIGHT_M),o=t.altitudeDeg>-r?t:e,c=this.bentLight(o,o===t?ii.SUN_MAGNITUDE:e.magnitude),l=le.strength(i,s,o.altitudeDeg,r)*c.scale,{x:h,y:u,z:d}=ni(o.altitudeDeg,o.azimuthDeg,1);this.iceHalos.update({x:h,y:u,z:d},o.altitudeDeg,l,c.tint,{cover:n?.cover??i,layerHeight:n?.layerHeight??Ic},n?.iceCrystalAlignment??this.weather.iceCrystalAlignment??.65)}buildRainbow(t,e){this.rainbow||(this.rainbow=new ga,this.celestialGroup.add(this.rainbow.object));const i=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,n=t.altitudeDeg>0,s=n?t:e,r=this.lowerCloudCover(),o=this.bentLight(s,n?ii.SUN_MAGNITUDE:e.magnitude,pb),c=$i.strength(i,r,s.altitudeDeg)*o.scale;if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=ni(s.altitudeDeg,s.azimuthDeg,1);this.rainbow.update({x:l,y:h,z:u},c,o.tint,n)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Us,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:i,observer:n}=t.frame,s=wn.galactic(i,n),r=Fe.directionOf(s.centre),o=Fe.directionOf(s.rotation),c=Fe.directionOf(s.pole),l=new Xt().set(r.x,r.y,r.z,o.x,o.y,o.z,c.x,c.y,c.z),h=Fe.directionOf(wn.eclipticPole(i,n)),u=Fe.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:Fe.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Yt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new D(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:i,z:n}=ni(t.altitudeDeg,t.azimuthDeg,1);return new D(e,i,n).normalize()}buildNovae(t,e){const i=new Set;for(const n of t){if(n.magnitude>e)continue;const s=`nova:${n.id}`;i.add(s);const r=eo(n.magnitude,e),o=Rh(r);this.setBodyMesh(s,n.position,Wh*(.5+.5*r),new st(o,o,o),n.magnitude)}for(const n of this.novaKeys)i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n));this.novaKeys=i}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const i=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[],...this.novaKeys]);for(const n of t){if(n.magnitude>e)continue;i.add(n.body);const s=eo(n.magnitude,e),r=Rh(s),o=qb[n.body]??new st(1,1,1),c=new st(o.r*r,o.g*r,o.b*r),l=Wh*(.5+.5*s);this.setBodyMesh(n.body,n.position,l,c,n.magnitude)}for(const n of[...this.bodyMeshes.keys()])i.has(n)||(this.disposeMesh(this.bodyMeshes.get(n)),this.bodyMeshes.delete(n),this.disposeHitArea(n),this.disposeGlare(n))}buildStars(t,e){if(this.namedStars=[],!t||t.catalog.count===0){this.disposeStarTiers(),this.syncAnimationLoop();return}const{catalog:i,date:n,observer:s}=t,r=new An(n,s),o=jh(1337),c=[],l=this.siteElevationM+this.observerElevationM;for(let h=0;h<i.count;h++){const u=i.mag[h];if(u>e)break;const{altitudeDeg:d,azimuthDeg:f}=r.position(i.ra[h],i.dec[h]);if(d<nm)continue;const{x:p,y:v,z:m}=ni(d,f,Gh);c.push({x:p,y:v,z:m,brightness:eo(u,e),illuminance:this.air.transmittanceFromSpace(l,d).map(g=>g*ce.illuminanceOf(u)),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}for(const h of mw){if(h.mag>e)continue;const{altitudeDeg:u,azimuthDeg:d}=r.position(h.raHours,h.decDeg);if(u<nm)continue;const{x:f,y:p,z:v}=ni(u,d,Gh);this.namedStars.push({star:h,direction:new D(f,p,v).normalize(),altitudeDeg:u})}this.starTiers=ho.map((h,u)=>{const d=c.filter(S=>Wg(S.brightness)===u),f=new Float32Array(d.length*3),p=new Float32Array(d.length),v=new Float32Array(d.length*3),m=new Float32Array(d.length),g=new Float32Array(d.length);d.forEach((S,b)=>{f[b*3]=S.x,f[b*3+1]=S.y,f[b*3+2]=S.z,p[b]=S.brightness,v.set(S.illuminance,b*3),m[b]=S.phase,g[b]=S.speedFactor});const _=new ue;_.setAttribute("position",new te(f,3));const w=new te(new Float32Array(d.length*3),3);_.setAttribute("color",w);let M=this.starTiers[u]?.points;return M?(M.geometry.dispose(),M.geometry=_):(M=new ds(_,Oe.material(h.size)),Oe.track(M),this.celestialGroup.add(M)),{points:M,colorAttribute:w,brightness:p,illuminance:v,phase:m,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}twinkleSeconds=0;updateTwinkle(t){const e=this.relativeScale;for(const i of this.starTiers){const n=i.colorAttribute.array;for(let s=0;s<i.brightness.length;s++){const r=m5(i.brightness[s],{phase:i.phase[s],speedFactor:i.speedFactor[s]},t),o=e*r;n[s*3]=i.illuminance[s*3]*o,n[s*3+1]=i.illuminance[s*3+1]*o,n[s*3+2]=i.illuminance[s*3+2]*o}i.colorAttribute.needsUpdate=!0}}buildClouds(){if(this.cloudRendering==="volume"||this.weather.cloudLayers!==void 0){this.layeredClouds||(this.disposeCloudSystem(),this.layeredClouds=new fr(this.celestialGroup,Xh,this.cloudRendering)),this.disposeCirrus(),this.layeredClouds.hostHalo(this.iceHalos),this.layeredClouds.update(this.weather,this.observerElevationM+1.6),this.layeredClouds.setOffsets(this.cloudOffsetM,this.cloudLayerOffsetsM),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}const t=this.lowerCloudCover();if(t<=0){this.disposeCloudSystem();return}const e=this.weather.cloudDarkness,i=new st(aa[0]+(Kh[0]-aa[0])*e,aa[1]+(Kh[1]-aa[1])*e,aa[2]+(Kh[2]-aa[2])*e);if(this.cloudMesh&&this.cloudUniforms){this.cloudUniforms.coverage.value=t,this.cloudUniforms.baseColor.value.copy(i),this.syncCloudLayer(),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);return}this.disposeCloudSystem();const{material:n,uniforms:s}=ed(i,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=n,this.cloudUniforms=s,s.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const r=id(Xh);this.cloudMesh=new Dt(r,n),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:i}=ed(new st(...aa),t,Ic,1);this.cirrusMaterial=e,this.cirrusUniforms=i,i.fieldOffset.value.copy(this.cloudFieldOffset),this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new Dt(id(Xh*1.04),e),this.cirrusMesh.renderOrder=hm-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 i=e<0;t.scale.y=i?-1:1,t.renderOrder=i?fr.deckOrder(!0,0,1):hm}cloudLayerOffset(){const e=((this.weather.cloudBaseM??1e3)-this.observerElevationM)*qh;return Math.sign(e||1)*Math.max(Math.abs(e),Db)}updateCloudLighting(t,e){const i=[this.cloudUniforms,this.cirrusUniforms].filter(u=>u!==void 0);if(i.length===0&&!this.layeredClouds)return;const n=this.cloudBeamDirection,[s,r,o]=this.cloudBeam.map(u=>u/Math.PI),c=this.lightningLevel*Jh*this.relativeScale/Math.PI,l=new st(e[0]+zn.r*c,e[1]+zn.g*c,e[2]+zn.b*c);this.layeredClouds?.setLighting(n.clone(),new st(s,r,o),l,l);const h=Math.max(0,n.y);for(const u of i)u.sunDir.value.copy(n),u.sunColor.value.setRGB(s*h,r*h,o*h),u.ambientColor.value.copy(l)}disposeCloudSystem(){this.layeredClouds?.dispose(),this.layeredClouds=void 0,this.cloudMesh&&(this.cloudMesh.removeFromParent(),this.cloudMesh.geometry.dispose()),this.cloudMaterial?.dispose(),this.cloudMesh=void 0,this.cloudMaterial=void 0,this.cloudUniforms=void 0}disposePrecipitationPoints(){this.precipitationPoints&&(this.precipitationPoints.removeFromParent(),this.precipitationPoints.geometry.dispose(),this.precipitationPoints.material.dispose()),this.precipitationPoints=void 0,this.precipitationPositions=void 0,this.precipitationPhase=void 0,this.precipitationSpeedJitter=void 0,this.precipitationWobbleFreqJitter=void 0,this.precipitationWobbleAmpJitter=void 0,this.precipitationBounceRemaining=void 0,this.precipitationBounceHeight=void 0,this.precipitationBounceDuration=void 0,this.precipitationBounceVelX=void 0,this.precipitationBounceVelZ=void 0,this.precipitationUniforms=void 0}buildPrecipitation(){this.disposePrecipitationPoints(),this.disposeRain();const t=this.weather.precipitationType;if(t==="none")return;if(t==="rain"){this.buildRain();return}const e=um[t],i=e.poolSize,n=jh(9001),s=new Float32Array(i*3),r=new Float32Array(i),o=new Float32Array(i),c=new Float32Array(i),l=new Float32Array(i),h=new Float32Array(i),u=new Float32Array(i),d=new Float32Array(i),f=new Float32Array(i),p=new Float32Array(i);for(let w=0;w<i;w++){const M=n()*Math.PI*2,S=n()*e.radiusM;s[w*3]=Math.cos(M)*S,s[w*3+1]=er+n()*(e.topYM-er),s[w*3+2]=Math.sin(M)*S,r[w]=n()*Math.PI*2,o[w]=.7+n()*.6,c[w]=.6+n()*.8,l[w]=.4+n()*1.2}const v=new ue;v.setAttribute("position",new te(s,3)),v.setDrawRange(0,Zh(i,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color.clone()},uHazeColor:{value:new st(...this.baseFogColor)},uTexture:{value:Yb(t)},uNearFocusDistance:{value:ym},uHazeDistance:{value:e.radiusM*_m}},g=new ae({uniforms:m,vertexShader:Qb,fragmentShader:tE,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const _=new ds(v,g);_.renderOrder=Yh,this.scene.add(_),this.precipitationPoints=_,this.precipitationPositions=s,this.precipitationPhase=r,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=p}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter)return;this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor);const i=this.weather.precipitationType;if(i==="none"||i==="rain")return;const n=um[i];if(this.precipitationUniforms?.uColor.value.copy(Fe.litBySky(n.color,this.baseFogColor)),e<=0)return;const s=this.weather.windDirectionDeg*Bi,r=Math.sin(s)*this.weather.windSpeed*n.driftSensitivity,o=-Math.cos(s)*this.weather.windSpeed*n.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,p=this.precipitationBounceHeight,v=this.precipitationBounceDuration,m=this.precipitationBounceVelX,g=this.precipitationBounceVelZ,_=i==="snow"&&u&&d,w=i==="hail"&&f&&p&&v&&m&&g;for(let M=0,S=0;M<c.length;M+=3,S++){if(w&&f[S]>0){if(f[S]-=e,f[S]<=0){const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A,f[S]=0}else{const x=1-f[S]/v[S];c[M+1]=er+Math.sin(Math.PI*x)*p[S],c[M]=Nc(c[M]+(r+m[S])*e,n.radiusM),c[M+2]=Nc(c[M+2]+(o+g[S])*e,n.radiusM)}continue}let b=0,T=0;if(_){const x=kb*u[S],A=zb*d[S];b=Math.sin(t*x*Math.PI*2+l[S])*A,T=Math.sin(t*x*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(r+b)*e,c[M+1]-=n.fallSpeedMPerS*h[S]*e,c[M+2]+=(o+T)*e,c[M]=Nc(c[M],n.radiusM),c[M+2]=Nc(c[M+2],n.radiusM),c[M+1]<er){if(w){p[S]=Am*(.2+Math.random()*1.6),v[S]=Bb*(.5+Math.random()),f[S]=v[S];const I=Math.random()*Math.PI*2,C=Hb*(p[S]/Am);m[S]=Math.cos(I)*C,g[S]=Math.sin(I)*C,c[M+1]=er;continue}const x=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*n.radiusM;c[M]=Math.cos(x)*A,c[M+1]=n.topYM,c[M+2]=Math.sin(x)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=mm(this.weather.precipitationIntensity);this.rainSystem=Cw({count:dm,radiusM:Zr,heightM:Ib,bottomYM:fm,overallSpeed:Pb,color:gm.clone(),opacity:.85,visibleCount:Zh(dm,this.weather.precipitationIntensity),speedStreak:Ub(t),pixelSize:wm,seed:9001,nearFocusDistanceM:ym,hazeDistanceM:Zr*_m,hazeColor:new st(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=Yh,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=jh(4242),e=new Float32Array(ja*3),i=new Float32Array(ja),n=new Float32Array(ja),s=new Float32Array(ja);for(let h=0;h<ja;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*Zr;e[h*3]=Math.cos(u)*d,e[h*3+1]=fm,e[h*3+2]=Math.sin(u)*d,n[h]=Tm(vm,Mm),i[h]=t()*n[h],s[h]=i[h]/n[h]}const r=new ue;r.setAttribute("position",new te(e,3));const o=new te(s,1);r.setAttribute("aLife",o),r.setDrawRange(0,Zh(ja,this.weather.precipitationIntensity));const c=new ae({uniforms:{uMaxSize:{value:Fb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:xm.clone()},uTexture:{value:Zb()}},vertexShader:Jb,fragmentShader:jb,transparent:!0,depthWrite:!1}),l=new ds(r,c);l.renderOrder=Yh,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:i,duration:n,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*Bi;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-mm(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const i=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=i.x/Math.max(i.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor),e.uniforms.uColor.value.copy(Fe.litBySky(gm,this.baseFogColor));const i=this.rainSplashSystem?.points.material?.uniforms?.uColor;i&&i.value.copy(Fe.litBySky(xm,this.baseFogColor));const n=this.weather.windDirectionDeg*Bi,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,o=Zr,c=h=>(h%(o*2)+o*3)%(o*2)-o;e.uniforms.uWindOffset.value.set(c(e.uniforms.uWindOffset.value.x+s*t),c(e.uniforms.uWindOffset.value.y+r*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const h=bm+(1-bm)*(1-l),u=Em+(1-Em)*(1-l);e.uniforms.uUvSquash.value=u,e.uniforms.uPixelSize.value=wm*h*(.5+.5*u)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:i,life:n,duration:s,lifeAttribute:r}=e,o=r.array;for(let c=0,l=0;c<i.length;c+=3,l++){if(n[l]+=t,n[l]>=s[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Zr;i[c]=Math.cos(h)*u,i[c+2]=Math.sin(h)*u,s[l]=Tm(vm,Mm),n[l]=0}o[l]=n[l]/s[l]}e.points.geometry.attributes.position.needsUpdate=!0,r.needsUpdate=!0}setLightning(t){this.lightningFlashes=t}updateLightning(t){let e,i=0;if(this.lightningArmed)for(const c of this.lightningFlashes){if(c.t>t)break;const l=oi.brightnessAt(c,t);l>i&&(e=c,i=l)}const n=e?Math.min(1,Math.max(.1,(Wb/e.distanceM)**2)):0,s=i*n*(e?.cloudToGround?1:.6);if(s===this.lightningLevel&&!e?.cloudToGround)return;if(this.lightningLevel=s,this.scene.fog){const c=this.scene.fog,l=s*Jh*this.relativeScale/Math.PI;c.color.setRGB(this.airlight[0]+zn.r*l,this.airlight[1]+zn.g*l,this.airlight[2]+zn.b*l)}const r=this.skyMesh?.material?.color;if(r){const c=s*Xb;r.setRGB(1+c*zn.r,1+c*zn.g,1+c*zn.b)}if(this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.lightningLight.intensity=s*Jh*this.relativeScale,e){const{x:c,y:l,z:h}=ni(25,e.azimuthDeg,ln);this.lightningLight.position.set(c,l,h)}this.lightningBolt||(this.lightningBolt=new Fs(ln*.95),this.celestialGroup.add(this.lightningBolt.object));const o=this.weather.cloudBaseM??1500;this.lightningBolt.set(e,i,o),this.render()}buildCompassLabels(){const t=jc(navigator.languages,yb),e=xb[t];this.compassSprites=Mb.map((i,n)=>{const s=e[n],r=new Wc({map:eE(s),depthTest:!1,fog:!1}),o=new Fr(r),{x:c,y:l,z:h}=ni(0,i,rm);return o.position.set(c,l,h),o.scale.set(Lc,Lc,1),o.renderOrder=wb,o.layers.set(Qp),o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=om*Math.PI/360,i=Lc*Math.tan(t)/Math.tan(e);for(const n of this.compassSprites)n.scale.set(i,i,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 i of Array.isArray(e)?e:[e]){const n=i.map;n&&n.dispose(),i.dispose()}}}const Bi=Math.PI/180;function or(a,t,e){return Math.max(t,Math.min(e,a))}function Tm(a,t){return a+Math.random()*(t-a)}function Nc(a,t){return(a%(t*2)+t*3)%(t*2)-t}let Oc,Uc;function Yb(a){switch(a){case"snow":return Kb();case"hail":return $b()}}function Kb(){if(Oc)return Oc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0.95)"),i.addColorStop(.5,"rgba(255,255,255,0.55)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Oc=new ws(t),Oc}function $b(){if(Uc)return Uc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,1)"),i.addColorStop(.55,"rgba(255,255,255,0.95)"),i.addColorStop(.8,"rgba(255,255,255,0.4)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Uc=new ws(t),Uc}let Fc;function Zb(){if(Fc)return Fc;const a=64,t=document.createElement("canvas");t.width=a,t.height=a;const e=t.getContext("2d"),i=e.createRadialGradient(a/2,a/2,0,a/2,a/2,a/2);return i.addColorStop(0,"rgba(255,255,255,0)"),i.addColorStop(.4,"rgba(255,255,255,0)"),i.addColorStop(.6,"rgba(255,255,255,0.9)"),i.addColorStop(.8,"rgba(255,255,255,0.25)"),i.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=i,e.fillRect(0,0,a,a),Fc=new ws(t),Fc}const Jb=`
|
|
7015
7019
|
uniform float uMaxSize;
|
|
7016
7020
|
uniform float uScale;
|
|
7017
7021
|
attribute float aLife;
|