@rr0/ufoathome 0.55.3 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Um=`
|
|
2
2
|
<div class="stage" id="stage">
|
|
3
3
|
<div class="frame" id="frame">
|
|
4
4
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -6,7 +6,7 @@ const Nm=`
|
|
|
6
6
|
<div id="ufo-slot"></div>
|
|
7
7
|
<div id="hover-tooltip" class="hover-tooltip" hidden></div>
|
|
8
8
|
</div>
|
|
9
|
-
`,
|
|
9
|
+
`,Fm=`
|
|
10
10
|
:host {
|
|
11
11
|
display: block;
|
|
12
12
|
}
|
|
@@ -104,7 +104,7 @@ const Nm=`
|
|
|
104
104
|
pointer-events: none;
|
|
105
105
|
white-space: nowrap;
|
|
106
106
|
}
|
|
107
|
-
`;class Fs extends Error{constructor(t,e,n){super(`${t}: ${e}${n===void 0?"":` (HTTP ${n})`}`),this.kind=t,this.url=e,this.status=n,this.name="SightingFetchError"}}class qf{static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new Fs("mixed-content",t);let n;try{n=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!n.ok)throw new Fs("status",t,n.status);try{return await n.json()}catch{throw new Fs("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new Fs("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new Fs("cors",t)}catch{return new Fs("unreachable",t)}}}const
|
|
107
|
+
`;class Fs extends Error{constructor(t,e,n){super(`${t}: ${e}${n===void 0?"":` (HTTP ${n})`}`),this.kind=t,this.url=e,this.status=n,this.name="SightingFetchError"}}class qf{static async json(t){const e=new URL(t,location.href);if(location.protocol==="https:"&&e.protocol==="http:")throw new Fs("mixed-content",t);let n;try{n=await fetch(t)}catch{throw await this.diagnose(t,e)}if(!n.ok)throw new Fs("status",t,n.status);try{return await n.json()}catch{throw new Fs("malformed",t)}}static async diagnose(t,e){if(e.origin===location.origin)return new Fs("unreachable",t);try{return await fetch(t,{mode:"no-cors"}),new Fs("cors",t)}catch{return new Fs("unreachable",t)}}}const zm=`
|
|
108
108
|
<div class="stage" id="stage">
|
|
109
109
|
<div class="frame" id="frame">
|
|
110
110
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -150,7 +150,7 @@ const Nm=`
|
|
|
150
150
|
</div>
|
|
151
151
|
</div>
|
|
152
152
|
</div>
|
|
153
|
-
`,
|
|
153
|
+
`,Bm=`
|
|
154
154
|
:host {
|
|
155
155
|
display: block;
|
|
156
156
|
font-family: sans-serif;
|
|
@@ -507,21 +507,21 @@ input[type=range] {
|
|
|
507
507
|
pointer-events: none;
|
|
508
508
|
white-space: nowrap;
|
|
509
509
|
}
|
|
510
|
-
`,Ca=[{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 ze{static get default(){return Ca[0]}static byId(t){return Ca.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:ze.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:ze.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*ze.aspectOf(t))}static availableAt(t){return t===void 0?Ca:Ca.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const n=t.frame;if(!(!n||e<=0))return 2*Math.atan(n.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const n=t.frame;if(!(!n||e<=0||e>=180))return n.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const n=e??t.fNumber;if(n===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??ze.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}const Yf=Math.PI/180,Ho=111320;function un(s,t,e,n){const i=Ho*Math.cos(e*Yf),r=(s-e)*Ho;return{x:(t-n)*i,z:-r}}function Pi(s,t,e,n){const i=Ho*Math.cos(e*Yf),r=-t,a=s;return{lat:e+r/Ho,lng:n+a/i}}class da{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const n of t.witnessTrack.allKeyframes){const{lat:i,lng:r,headingDeg:a}=n.pose;i===void 0||r===void 0||e.push({t:n.t,lat:i,lng:r,headingDeg:a})}if(e.length===0){const n=t.event.place?.[0];if(!n)return;e.push({t:0,lat:n.lat,lng:n.lng})}return new da(e)}get moved(){return this.spanM>da.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,n=(t.west+t.east)/2;return Math.max(Math.abs(un(e,t.east,e,t.west).x),Math.abs(un(t.north,n,t.south,n).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:n,lng:i}=this.center,r=Math.max(this.spanM*(1+e),t)/2;return{north:Pi(0,-r,n,i).lat,south:Pi(0,r,n,i).lat,east:Pi(r,0,n,i).lng,west:Pi(-r,0,n,i).lng}}get box(){const t=this.points.map(n=>n.lat),e=this.points.map(n=>n.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class Fe{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=da.of(t);if(!e||e.points.length<2)return;const n=[];let i=0;for(let r=1;r<e.points.length;r++){const a=e.points[r-1],o=e.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=un(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,g=Fe.stepHzFor(f);n.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:g,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=g*c}for(let r=0;r<n.length;r++){const a=n[r-1],o=n[r+1];n[r].rampsIn=a===void 0||a.stepHz===0,n[r].rampsOut=o===void 0||o.stepHz===0}if(n.some(r=>r.stepHz>0))return new Fe(n,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<Fe.SLOWEST_WALK_M_PER_S||t>Fe.FASTEST_WALK_M_PER_S?0:Fe.REFERENCE_STEP_HZ*Math.pow(t/Fe.REFERENCE_SPEED_M_PER_S,Fe.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return Fe.STILL;const n=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,i=2*Math.PI*n,r=this.amplitudeAt(e,t),a=Fe.SWAY_M*r*Math.cos(i/2),o=r*this.rotationPassed*e.speedMPerS/Fe.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:Fe.RISE_M_PER_M_PER_S*e.speedMPerS*r*Math.cos(i),rollDeg:Fe.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Fe.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(t,e){const n=1e3/t.stepHz,i=Math.min(n,(t.endMs-t.startMs)/2);if(i<=0)return 1;const r=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?r/i:1,t.rampsOut?a/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class me{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/me.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function zm(s,t,e){if(!s||!t)return e<1?s:t;const n=((t.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*e)%360+360)%360,altitudeDeg:s.altitudeDeg+(t.altitudeDeg-s.altitudeDeg)*e}}function Bm(s,t,e){const{bounds:n}=s;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function _n(s,t,e){return s+(t-s)*e}function Vu(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function km(s){return`#${s.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function Hm(s,t,e){const n=Vu(s),i=Vu(t);return!n||!i?e<1?s:t:km([_n(n[0],i[0],e),_n(n[1],i[1],e),_n(n[2],i[2],e)])}function Gm(s,t,e){const n={x:_n(s.bounds.x,t.bounds.x,e),y:_n(s.bounds.y,t.bounds.y,e),width:_n(s.bounds.width,t.bounds.width,e),height:_n(s.bounds.height,t.bounds.height,e)},i=_n(s.angle,t.angle,e),r=_n(s.transparency,t.transparency,e),a=_n(s.haloScale,t.haloScale,e),o=_n(s.blur??0,t.blur??0,e),c=_n(s.brightness??0,t.brightness??0,e),l=Hm(s.color,t.color,e),h=me.lerpAngular(s.angular,t.angular,e),u=zm(s.aim,t.aim,e);return s.kind==="polygon"&&t.kind==="polygon"&&s.points.length===t.points.length?{...s,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,behindCloud:e<1?s.behindCloud:t.behindCloud,points:s.points.map((d,f)=>({x:_n(d.x,t.points[f].x,e),y:_n(d.y,t.points[f].y,e)}))}:{...e<1?s:t,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class cc{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const i=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!i.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const i=this.findShapeAtOrAfter(t,e);return n?i?Gm(n.shape,i.shape,(t-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(t,e,n,i){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(i?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&Bm(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const n=this.groups[e].filter(i=>i!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new cc;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(i=>e.order.includes(i))).filter(n=>n.length>=2)),e}}function Vm(s,t,e){return Math.max(t,Math.min(e,s))}function Wm(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function zs(s,t,e){return s+(t-s)*e}function Xm(s,t,e){return{lat:s.lat===void 0||t.lat===void 0?void 0:zs(s.lat,t.lat,e),lng:s.lng===void 0||t.lng===void 0?void 0:zs(s.lng,t.lng,e),elevationM:zs(s.elevationM,t.elevationM,e),headingDeg:s.headingDeg===void 0||t.headingDeg===void 0?void 0:Wm(s.headingDeg,t.headingDeg,e),pitchDeg:zs(s.pitchDeg,t.pitchDeg,e),rollDeg:zs(s.rollDeg??0,t.rollDeg??0,e),fovDeg:zs(s.fovDeg,t.fovDeg,e),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class fa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?Xm(n.pose,i.pose,Vm((t-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new fa;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function Xi(s,t,e){return s+(t-s)*e}function qm(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function Ym(s,t,e){return Math.max(t,Math.min(e,s))}function Km(s,t,e){return{cloudCover:Xi(s.cloudCover,t.cloudCover,e),cloudDarkness:Xi(s.cloudDarkness,t.cloudDarkness,e),highCloudCover:s.highCloudCover===void 0||t.highCloudCover===void 0?void 0:Xi(s.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:s.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:Xi(s.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:s.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:Xi(s.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:s.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:Xi(s.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?s.precipitationType:t.precipitationType,precipitationIntensity:Xi(s.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:qm(s.windDirectionDeg,t.windDirectionDeg,e),windSpeed:Xi(s.windSpeed,t.windSpeed,e),storm:e<1?s.storm:t.storm}}class pa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?Km(n.weather,i.weather,Ym((t-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new pa;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class ma{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return i?.sound;if(!i)return n.sound;const r=(t-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ma;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}}const Kf=1e3,$m=.65,$f={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Zm=100,Jm={kind:"none",volume:0,pitchHz:Zm};class On{constructor(t){this.entries=t}static empty(){return new On(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 On(new Map);return{recording:On.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const n=structuredClone(t);for(const i of e.paths()){const r=e.at(i),a=i.split("."),o=On.holderOf(n,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(l)||(o[c]={value:l,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale}}))}return n}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,n){return On.isWrapper(t)?(n.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),On.stripValue(t.value,e,n)):Array.isArray(t)?t.map((i,r)=>On.stripValue(i,[...e,String(r)],n)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,On.stripValue(r,[...e,i],n)])):t}static holderOf(t,e){let n=t;for(const i of e.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}function Ll(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Wu(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const Qm=["year","month","day","hour","minute"],jm=["day","hour","minute"];function Xu(s,t){return t.filter(e=>s[e]!==void 0).join(",")}function tg(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const t=s.time.year!==void 0&&s.endTime.year!==void 0,e=t?Qm:jm,n=Xu(s.time,e);if(!(n===""||n!==Xu(s.endTime,e)))return t?Ll(s.endTime)-Ll(s.time):Wu(s.endTime)-Wu(s.time)}class lc{constructor(t,e,n,i,r,a,o,c,l=[],h,u,d,f=[]){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=i,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f}provenance=On.empty();testimony;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ze.byId(this.instrumentId)}static create(t,e,n){return new lc({eventType:"sighting",time:t,place:e},new cc,new fa,new pa,new ma,n)}}const eg=0,ng=0;function tn(s,t){const e=s.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:eg,headingDeg:void 0,pitchDeg:ng,fovDeg:ze.fieldOfViewDeg(s.instrument)}}function qu(s,t){return s.weatherTrack.getInterpolatedWeatherAt(t)??s.weather??$f}function ig(s,t){return s.soundTrack.getInterpolatedSoundAt(t)??Jm}class sg{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}this.onFrame(t,e)}}const Zf=["nw","n","ne","e","se","s","sw","w"],rg=24,Pa=8,ag=3,og=8;function Ia(s,t,e){const n=s.x-t.x,i=s.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-i*a,y:t.y+n*a+i*r}}function Nr(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const cg={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 Tn{static handlePointsFor(t){const{x:e,y:n,width:i,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+i/2,y:n},ne:{x:e+i,y:n},e:{x:e+i,y:n+r/2},se:{x:e+i,y:n+r},s:{x:e+i/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+i/2,y:n-rg}},o=Nr(t.bounds),c={};for(const l of Object.keys(a))c[l]=Ia(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,i=[...Zf,"rotate"]){const r=Tn.handlePointsFor(t);for(const a of i)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((Tn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(i)%r.length]}static resizeBounds(t,e,n,i){const r=Nr(t),a=Ia(i,r,-e),{x:o,y:c,width:l,height:h}=t,u=cg[n];let d=o,f=c,g=o+l,v=c+h;return u.left&&(d=Math.min(a.x,g-Pa)),u.right&&(g=Math.max(a.x,d+Pa)),u.top&&(f=Math.min(a.y,v-Pa)),u.bottom&&(v=Math.max(a.y,f+Pa)),{x:d,y:f,width:g-d,height:v-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:r}=t.bounds,a=Tn.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=i===0?1:a.width/i,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Nr(t.bounds),i=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),i=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:i-e,height:r-n}}static vertexPointsFor(t){const e=Nr(t.bounds);return t.points.map(n=>Ia({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=og){const i=Tn.vertexPointsFor(t);let r,a=n;return i.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Nr(t.bounds),i=Ia(e,n,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,n){const i=t.points.map((u,d)=>d===e?Tn.toLocalPoint(t,n):u),r=Math.min(...i.map(u=>u.x)),a=Math.min(...i.map(u=>u.y)),o=Math.max(...i.map(u=>u.x)),c=Math.max(...i.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=i.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=Tn.toLocalPoint(t,e),{points:i}=t;let r=i.length-1,a=1/0;for(let c=0;c<i.length;c++){const l=i[c],h=i[(c+1)%i.length],u=Tn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...i.slice(0,r+1),n,...i.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const i=n.x-e.x,r=n.y-e.y,a=i*i+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*r)/a)),c=e.x+o*i,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=ag?t:{...t,points:t.points.filter((n,i)=>i!==e)}}}const Nl=6,La=Nl/2,Yu=20,Ku=24,$u=9,Zu=6,Ju=7,Qu=6,ju=4;class Ol{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:n,width:i,height:r}=t.bounds,a=e+i/2,o=n+r/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(i,r)/2,h=c?l:i/2,u=c?l:r/2,d=Math.max(i,r)/2,f=t.brightness??0,g=f>0?Math.max(d*(1+$u*f),Qu*f)-d:0,v=f>0?d*(1+Ju*f)-d:0,p=3*Ku*(t.blur??0)+1.5*Yu*t.haloScale,m=Math.max(g,v,0)+p+2;return{x:a-h-m,y:o-u-m,width:2*(h+m),height:2*(u+m)}}paintInto(t,e,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-e.x,-e.y),this.paintShape(t.selected?{...t,selected:!1}:t),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(Ku*e).toFixed(2)}px)`);const n=t.brightness??0;n>0&&this.paintDazzle(t,n),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:n,y:i,width:r,height:a}=t.bounds,o=n+r/2,c=i+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+$u*e),Qu*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<=Zu;d++){const f=d/Zu,g=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,g*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+Ju*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(g)*d,p=c+Math.sin(g)*d,m=this.ctx.createLinearGradient(o,c,v,p);m.addColorStop(0,this.withAlpha(t.color,e*.55)),m.addColorStop(.35,this.withAlpha(t.color,e*.22)),m.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,p),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const n=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!n)return t.color;const i=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*e);return`rgb(${r(i>>16&255)}, ${r(i>>8&255)}, ${r(i&255)})`}withAlpha(t,e){const n=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const r=Number.parseInt(i[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:i,height:r}=t.bounds,a=i/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:i,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=Yu*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(Tn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of Tn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,ju,ju,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(Tn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintGroupHandles(t){this.paintHandleFrame(Tn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of Zf){const i=t[n];this.ctx.fillRect(i.x-La,i.y-La,Nl,Nl)}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,La+1,La+1,0,0,2*Math.PI),this.ctx.fill())}}const td=.05,ed=.08,nd=2,id=3,lg=14,hg=.02;class ug{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const i=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,td);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),i,td)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),i.connect(r),r.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,i.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(i).connect(r).connect(t.destination),n.start(),{key:e,nodes:[i,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(i).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[i,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const i=this.context;if(!i)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=i.createBufferSource();a.buffer=r,a.loop=!0;const o=i.createGain();o.gain.value=0,a.connect(o).connect(i.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*nd),t.sampleRate),n=e.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*nd),t.sampleRate),n=e.getChannelData(0);let i=0,r=0;for(let a=0;a<n.length;a++)i=(i+.02*(Math.random()*2-1))/1.02,n[a]=i,r=Math.max(r,Math.abs(i));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*id),t.sampleRate),n=e.getChannelData(0),i=Math.max(1,Math.floor(hg*t.sampleRate)),r=Math.round(id*lg);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<i&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,ed/3);const i=n+ed;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(i)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}function Go(s){return[...s].sort((t,e)=>t.t-e.t)}function sd(s,t){let e;for(const n of Go(s)){if(n.t>t)break;e=n}return e}const Mc=Math.PI/180,Na=180/Math.PI;class Ii{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const i=n*Mc/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,n){return new Ii(t.projection,e,n)}degToPx(t){const e=t*Mc;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Na:2*Math.atan(t/(2*this.focalPx))*Na}angleDegToRadiusPx(t){const e=t*Mc;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*Na:Math.atan(t/this.focalPx)*Na}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(me.angularWidthDeg(t))}}class Un{static fovOf(t,e){return tn(t,e)?.fovDeg??ze.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:i,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:i,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:i/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,n,i)=>{const r=this.aimFrom(t,n,i,e.bounds);return r?{...e,aim:r}:e})}static aimOf(t,e,n){const i=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,i,tn(t,e),n)}static aimFrom(t,e,n,i){if(n?.headingDeg===void 0)return;const r=this.frameCentre(t),a=e.radiusPxToAngleDeg(i.x+i.width/2-r.x),o=e.radiusPxToAngleDeg(r.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+a)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,n,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,c=r.x+this.offAxisPx(n,a)-e.bounds.width/2,l=r.y-this.offAxisPx(n,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:c,y:l}}})}static frameCentre(t){return{x:ze.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,y:me.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Un.OFF_CANVAS_DEG?Math.sign(e)*Un.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,n){const i=ze.frameWidthPx(e,me.CANVAS_HEIGHT_PX)/2,r=ze.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,a=me.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=n?.get(o.t)??c,h=Ii.of(e,me.CANVAS_HEIGHT_PX,l),u=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,g=f.x+f.width/2-i,v=f.y+f.height/2-a,p=Math.hypot(g,v),m=p===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(p))/p,b={...f,x:r+g*m-f.width/2,y:a+v*m-f.height/2};return{...d,shape:{...d.shape,bounds:b}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const i of[...n.allKeyframes]){const r=tn(t,i.t),a=this.fovOf(t,i.t),o=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,a);n.addKeyframe(i.t,i.shapes.map(c=>({...c,shape:e(c.shape,o,r)})))}}}function dg(s){return On.restore(fg(s),s.provenance)}function fg(s){return Un.toAngular(s),Un.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function pg(s){const{recording:t,provenance:e}=On.strip(s),n=mg(t);return n.provenance=e,n}function mg(s){const t=new lc({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},cc.fromJSON(s.timeline),s.witnessTrack?fa.fromJSON(s.witnessTrack):new fa,s.weatherTrack?pa.fromJSON(s.weatherTrack):new pa,s.soundTrack?ma.fromJSON(s.soundTrack):new ma,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),Go(s.milestones??[]));return t.testimony=s.testimony,Un.toBounds(t),Un.toPosition(t),t}function eu(s,t){for(const e of s){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}class Vo{static preferencesFor(t){const e=navigator.languages??[],n=this.declaredFor(t);return n?[n,...e]:e}static declaredFor(t){for(let e=t;e;){const n=e.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class ns{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const n of this.preferences){const i=t[n]??t[ns.base(n)];if(i)return i}const e=new Set(this.preferences.map(n=>ns.base(n)));for(const[n,i]of Object.entries(t))if(i&&e.has(ns.base(n)))return i;return Object.values(t).find(n=>n)??void 0}write(t,e,n){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const r={...t},a=Object.keys(r).find(o=>o===n)??Object.keys(r).find(o=>ns.base(o)===ns.base(n))??n;return i===void 0?delete r[a]:r[a]=i,Object.keys(r).length===0?void 0:r}static base(t){return t.toLowerCase().split("-")[0]}}const gg="modulepreload",vg=function(s,t){return new URL(s,t).href},rd={},Ul=function(t,e,n){let i=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");i=a(e.map(h=>{if(h=vg(h,n),h in rd)return;rd[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const p=o[v];if(p.href===h&&(!u||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":gg,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((v,p)=>{g.addEventListener("load",v),g.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},xg=["en","fr"],_g={en:()=>Ul(()=>Promise.resolve().then(()=>yg),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>Ul(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function Mg(s){return _g[s]()}const Jf={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},yg=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Jf},Symbol.toStringTag,{value:"Module"})),ad=2;function Qf(s){return s==="building"||s==="vehicle"}function Sg(s,t){const e=s.litKeyframes;if(!e||e.length===0)return s.lit??!1;let n=e[0];for(const i of e){if(i.t>t)break;n=i}return n.lit}function bg(s,t){return s.pattern.kind==="steady"?!0:jf(s,t,t+1)>.5}function jf(s,t,e){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:r=0}=s.pattern,a=Math.min(Math.max(i,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function nu(s,t){const e=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return od(e[0],s);const i=e[e.length-1];if(t>=i.t)return od(i,s);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return n}function od(s,t){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??t.headingDeg}}const tp=Math.PI/180,Eg=180/Math.PI,wg=256,Ag=19;function Tg(s,t){return 156543.03392*Math.cos(s*tp)/2**t}function Rg(s,t){return Tg(s,t)*wg}function ep(s,t){let e=0;for(;e<Ag&&Rg(s,e+1)>=t;)e++;return e}function Io(s){const t=s*tp;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function np(s,t,e){const n=2**e;return{x:(s+180)/360*n,y:Io(t)*n}}function ip(s,t,e){const n=Io(s.north),i=Io(s.south);return{x:(t-s.west)/(s.east-s.west),y:(Io(e)-n)/(i-n)}}function Dg(s,t,e){const{x:n,y:i}=np(s,t,e);return{x:Math.floor(n),y:Math.floor(i),z:e}}function Cg(s){const t=2**s.z,e=s.x/t*360-180,n=(s.x+1)/t*360-180,i=cd(s.y,t);return{south:cd(s.y+1,t),north:i,west:e,east:n}}function cd(s,t){const e=s/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Eg}function sp(s,t,e,n){const i=Dg(s,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:i.x+h,y:i.y+l,z:e});const o=a.map(Cg),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Ms{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let n,i=1/0;for(const r of this.targets){const a=Math.hypot(r.x-t,r.y-e);a>r.radius||a>i||(n=r,i=a)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,n){const i=ip(t,n,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const n=t.imagery;if(!n)return;const i=this.toCanvas(t.bounds,n.bounds.north,n.bounds.west),r=this.toCanvas(t.bounds,n.bounds.south,n.bounds.east);e.drawImage(n.source,i.x,i.y,r.x-i.x,r.y-i.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const n of t.decor){const i=this.toCanvas(t.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),n.headingDeg===void 0)continue;const r=(n.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(r)*10,i.y+Math.sin(r)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,n=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:n,coneHalfAngleDeg:i}=t;if(n===void 0||i===void 0)return;const{ctx:r}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(n-90)*Math.PI/180,l=i*Math.PI/180;r.save(),r.beginPath(),r.moveTo(a.x,a.y),r.arc(a.x,a.y,o,c-l,c+l),r.closePath();const h=r.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),r.fillStyle=h,r.fill(),r.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const n of[...t.markers].sort((i,r)=>Number(i.current)-Number(r.current))){const i=this.toCanvas(t.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:Ms.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,Ms.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=n.current?"#1d2321":"#fff",e.fillText(n.label,i.x,i.y)}}paintWitness(t,e){const{ctx:n}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const r=t.markers.some(a=>{if(!a.current)return!1;const o=un(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=Ms.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,r?Ms.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=r?3:2.5,n.strokeStyle=r?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,n=16;t.beginPath(),t.moveTo(e,n-9),t.lineTo(e-4.5,n+5),t.lineTo(e,n+2),t.lineTo(e+4.5,n+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,n+6),t.fillText("N",e,n+6)}paintFooter(t,e){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let r=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(t.south+t.north)/2,c=Math.abs(un(a,t.east,a,t.west).x)/this.width,l=Ms.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(u,d),n.lineTo(u+h,d),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,n),i.fillStyle="#fff",i.fillText(t,e,n)}wrap(t,e){const n=[];let i="";for(const r of t.split(" ")){const a=i?`${i} ${r}`:r;i&&this.ctx.measureText(a).width>e?(n.push(i),i=r):i=a}return i&&n.push(i),n}}const Pn=256,ld=3,Pg=32768;class Ig{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,i=(t.west+t.east)/2,r=Math.abs(un(n,t.east,n,t.west).x),a=Math.abs(un(t.north,i,t.south,i).z),o=ep(n,Math.max(r,a)),{tiles:c}=sp(i,n,o,ld),l=ld*Pn,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 g=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const p=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(g,p,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,i){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Pn,c.height=Pn;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,Pn,Pn),u=(t.x-e.x)*Pn,d=(t.y-e.y)*Pn;for(let f=0;f<Pn;f++)for(let g=0;g<Pn;g++){const v=(f*Pn+g)*4,p=h[v]*256+h[v+1]+h[v+2]/256-Pg,m=u+g,b=d+f;n[b*i+m]=p}}sampleAt(t,e,n,i,r,a){const{x:o,y:c}=np(e,t,n),l=(o-i.x)*Pn,h=(c-i.y)*Pn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),g=Math.min(a-1,d+1),v=l-u,p=h-d,m=r[d*a+u],b=r[d*a+f],E=r[g*a+u],M=r[g*a+f],S=m+(b-m)*v,w=E+(M-E)*v;return S+(w-S)*p}}const yc=256,hd=3;async function Lg(s,t,e,n){const i=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(un(i,s.east,i,s.west).x),o=Math.abs(un(s.north,r,s.south,r).z),c=ep(i,Math.max(a,o)/2),{tiles:l,bounds:h}=sp(r,i,c,hd),u=hd*yc,d=document.createElement("canvas");d.width=u,d.height=u;const f=d.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const g=l[0];await Promise.all(l.map(async m=>{const b=e(m),E=await n(b);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${b}`);const M=await createImageBitmap(await E.blob());f.drawImage(M,(m.x-g.x)*yc,(m.y-g.y)*yc)}));const v=document.createElement("canvas");v.width=t.width,v.height=t.height;const p=v.getContext("2d");if(!p)throw new Error("2D canvas context unavailable");return p.drawImage(d,0,0,u,u,0,0,t.width,t.height),{source:v,width:t.width,height:t.height,bounds:h}}class Ng{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 Lg(t,e,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function Og(){return{elevation:new Ig,imagery:rp()}}function rp(){return new Ng}const Ug=new Set,fr="show-witness-map",pr="hide-milestones";class Ln extends HTMLElement{static get observedAttributes(){return["src",fr,pr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=lc.create();sightingAudio=new ug;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=Jf;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.shapeAt(e.x,e.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-r.left+12}px`,this.tooltip.style.top=`${t.clientY-r.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-n.left+12}px`,this.tooltip.style.top=`${t.clientY-n.top+12}px`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Fm}</style>${Um}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ol(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new Ms(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t===fr&&this.applyWitnessMapDefault(),t===pr&&this.setMilestonesShown(!this.hasAttribute(pr))}async loadFromSrc(t){this.sightingData=await qf.json(t)}get sightingData(){return dg(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=pg(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Go(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`;const r=this.said.read(n.label)??"",a=this.said.read(n.note),o=a?`${r} — ${a}`:r;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?sd(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const n=document.createElement("b");n.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),r=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(r))}exposureInstants(t){const e=this.exposureTimes(t),n=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(t=this.currentTime){const e=(this.currentSighting.exposure??0)*1e3;if(e<Ln.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const n=Math.min(Ln.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e/Ln.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(t,e)/Ln.EXPOSURE_STEP_PX),r=Math.min(Ln.MAX_TRAVEL_STEPS,Math.max(n,i)),a=[];for(let o=0;o<r;o++)a.push(t+e*o/r);return a}travelPxOver(t,e){const n=this.shapesAt(t),i=this.shapesAt(t+e);let r=0;for(const[a,o]of n){const c=i.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(t,e,n){for(const i of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(i,t,e,n);if(r)return r}}shapesAt(t){const e=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=ze.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:Ug;this.canvasRenderer.setStarPoints(ze.starPointsOf(this.sighting.instrument));const i=(tn(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const r=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of r)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of r[0].shapes)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(n.size>1){const o=Tn.groupBoundsFor([...e].filter(([c])=>n.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.keepWitnessMapClear(r[0].shapes),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(ig(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 sg(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(fr)&&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=da.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(Ln.WITNESS_MAP_MIN_SPAN_M,Ln.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const n=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<n&&Math.abs(t.south-e.south)<n&&Math.abs(t.west-e.west)<n&&Math.abs(t.east-e.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=rp(),e=this.witnessMapBounds;try{const n=await t.getImageryTexture(e,{width:Ln.WITNESS_MAP_IMAGERY_PX,height:Ln.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=t.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(t){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const n=(o,c,l)=>{for(const h of t.values())if(!(h.transparency>=1)&&!(h.bounds.x+h.bounds.width<o-l||h.bounds.x>c+l)&&!(h.bounds.y>e.bottom+l||h.bounds.y+h.bounds.height<e.top-l))return!0;return!1},i=[this.canvas.width-e.width,this.canvas.width],r=[0,e.width],a=Ln.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){n(i[0],i[1],a)||this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(r[0],r[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*n,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=tn(this.currentSighting,t),n=this.currentSighting.instrument,i=[],r=this.currentSighting.milestones.length>0?sd(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?Go(this.currentSighting.milestones):[]){const o=tn(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===r})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ii.of(n,this.canvas.height,e.fovDeg).halfWidthAngleDeg(ze.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=tn(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=nu(n,t),{lat:r,lng:a}=Pi(i.eastM,-i.northM,e.lat,e.lng);return{lat:r,lng:a,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,n=this.lookPitchDeg+t.pitchDeg;if(e===0&&n===0)return{x:0,y:0};const i=tn(this.currentSighting,this.currentTime),r=Ii.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-r.angleDegToRadiusPx(e),y:r.angleDegToRadiusPx(n)}}gaitAt(t){return Fe.of(this.currentSighting)?.offsetAt(t)??Fe.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 ns(Vo.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=eu(Vo.preferencesFor(this),xg);t!=="en"&&this.applyMessages(await Mg(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=tg(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Ll(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Oa(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?dd(ud(this.realStartMs+n)):Oa(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Oa(this.currentSighting.timeline.duration):this.canShowClockTime?dd(ud(this.realStartMs+this.realDurationMs)):Oa(this.realDurationMs)}}function ud(s){const t=new Date(s);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function dd(s){if(s.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return s.second?`${t(s.hour)}:${t(s.minute??0)}:${t(s.second)}`:`${t(s.hour)}:${t(s.minute??0)}`}function Oa(s){const t=Math.round(s/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const Fl="rr0-ufo";function ap(){customElements.get(Fl)||customElements.define(Fl,Ln)}/**
|
|
510
|
+
`,Ca=[{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 ze{static get default(){return Ca[0]}static byId(t){return Ca.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:ze.UNAIDED_FIELD_DEG}static aspectOf(t){const e=t.frame;return e?e.widthMm/e.heightMm:ze.UNAIDED_ASPECT}static frameWidthPx(t,e){return Math.round(e*ze.aspectOf(t))}static availableAt(t){return t===void 0?Ca:Ca.filter(e=>!e.years||t>=e.years.from&&(e.years.to===void 0||t<=e.years.to))}static fieldOfViewDegAt(t,e){const n=t.frame;if(!(!n||e<=0))return 2*Math.atan(n.heightMm/(2*e))*180/Math.PI}static focalLengthMmFor(t,e){const n=t.frame;if(!(!n||e<=0||e>=180))return n.heightMm/(2*Math.tan(e*Math.PI/360))}static bladesShowing(t,e){const n=e??t.fNumber;if(n===void 0||t.apertureBlades===void 0)return 0;const i=t.fNumberRange;return!i||i.max<=i.min?1:Math.max(0,Math.min(1,(n-i.min)/(i.max-i.min)))}static LENS_FLARE_ARTIFACTS=1;static flareArtifactsOf(t){return t.flare??ze.LENS_FLARE_ARTIFACTS}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}const Yf=Math.PI/180,Ho=111320;function un(s,t,e,n){const i=Ho*Math.cos(e*Yf),r=(s-e)*Ho;return{x:(t-n)*i,z:-r}}function Pi(s,t,e,n){const i=Ho*Math.cos(e*Yf),r=-t,a=s;return{lat:e+r/Ho,lng:n+a/i}}class da{constructor(t){this.points=t}static STATIONARY_M=5;static of(t){const e=[];for(const n of t.witnessTrack.allKeyframes){const{lat:i,lng:r,headingDeg:a}=n.pose;i===void 0||r===void 0||e.push({t:n.t,lat:i,lng:r,headingDeg:a})}if(e.length===0){const n=t.event.place?.[0];if(!n)return;e.push({t:0,lat:n.lat,lng:n.lng})}return new da(e)}get moved(){return this.spanM>da.STATIONARY_M}get spanM(){const t=this.box,e=(t.south+t.north)/2,n=(t.west+t.east)/2;return Math.max(Math.abs(un(e,t.east,e,t.west).x),Math.abs(un(t.north,n,t.south,n).z))}get center(){const t=this.box;return{lat:(t.south+t.north)/2,lng:(t.west+t.east)/2}}boundsAround(t,e){const{lat:n,lng:i}=this.center,r=Math.max(this.spanM*(1+e),t)/2;return{north:Pi(0,-r,n,i).lat,south:Pi(0,r,n,i).lat,east:Pi(r,0,n,i).lng,west:Pi(-r,0,n,i).lng}}get box(){const t=this.points.map(n=>n.lat),e=this.points.map(n=>n.lng);return{south:Math.min(...t),north:Math.max(...t),west:Math.min(...e),east:Math.max(...e)}}}class Fe{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=da.of(t);if(!e||e.points.length<2)return;const n=[];let i=0;for(let r=1;r<e.points.length;r++){const a=e.points[r-1],o=e.points[r],c=(o.t-a.t)/1e3;if(c<=0)continue;const l=un(o.lat,o.lng,a.lat,a.lng),h=l.x,u=-l.z,d=Math.hypot(h,u),f=d/c,g=Fe.stepHzFor(f);n.push({startMs:a.t,endMs:o.t,speedMPerS:f,eastUnit:d>0?h/d:0,northUnit:d>0?u/d:0,stepHz:g,stepsBefore:i,rampsIn:!0,rampsOut:!0}),i+=g*c}for(let r=0;r<n.length;r++){const a=n[r-1],o=n[r+1];n[r].rampsIn=a===void 0||a.stepHz===0,n[r].rampsOut=o===void 0||o.stepHz===0}if(n.some(r=>r.stepHz>0))return new Fe(n,1-(t.instrument.stabilization??0))}static stepHzFor(t){return t<Fe.SLOWEST_WALK_M_PER_S||t>Fe.FASTEST_WALK_M_PER_S?0:Fe.REFERENCE_STEP_HZ*Math.pow(t/Fe.REFERENCE_SPEED_M_PER_S,Fe.CADENCE_EXPONENT)}offsetAt(t){const e=this.stretches.find(c=>t>=c.startMs&&t<=c.endMs);if(!e||e.stepHz===0)return Fe.STILL;const n=e.stepsBefore+e.stepHz*(t-e.startMs)/1e3,i=2*Math.PI*n,r=this.amplitudeAt(e,t),a=Fe.SWAY_M*r*Math.cos(i/2),o=r*this.rotationPassed*e.speedMPerS/Fe.REFERENCE_SPEED_M_PER_S;return{eastM:a*e.northUnit,northM:-a*e.eastUnit,upM:Fe.RISE_M_PER_M_PER_S*e.speedMPerS*r*Math.cos(i),rollDeg:Fe.HEAD_ROLL_DEG*o*Math.cos(i/2),pitchDeg:-1.25*o*Math.cos(i),yawDeg:Fe.HEAD_YAW_DEG*o*Math.cos(i/2)}}amplitudeAt(t,e){const n=1e3/t.stepHz,i=Math.min(n,(t.endMs-t.startMs)/2);if(i<=0)return 1;const r=e-t.startMs,a=t.endMs-e,o=Math.min(t.rampsIn?r/i:1,t.rampsOut?a/i:1,1);return(1-Math.cos(Math.PI*Math.max(o,0)))/2}}class me{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(t){return 2*Math.atan(t.sizeM/(2*t.distanceM))*180/Math.PI}static inMoons(t){return t/me.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(t,e,n){if(!(!t||!e))return{widthDeg:t.widthDeg+(e.widthDeg-t.widthDeg)*n,heightDeg:t.heightDeg+(e.heightDeg-t.heightDeg)*n}}static sizeMAt(t,e){return 2*t*Math.tan(e*Math.PI/360)}static distanceMAt(t,e){return t/(2*Math.tan(e*Math.PI/360))}}function km(s,t,e){if(!s||!t)return e<1?s:t;const n=((t.azimuthDeg-s.azimuthDeg)%360+540)%360-180;return{azimuthDeg:((s.azimuthDeg+n*e)%360+360)%360,altitudeDeg:s.altitudeDeg+(t.altitudeDeg-s.altitudeDeg)*e}}function Hm(s,t,e){const{bounds:n}=s;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function _n(s,t,e){return s+(t-s)*e}function Vu(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Gm(s){return`#${s.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function Vm(s,t,e){const n=Vu(s),i=Vu(t);return!n||!i?e<1?s:t:Gm([_n(n[0],i[0],e),_n(n[1],i[1],e),_n(n[2],i[2],e)])}function Wm(s,t,e){const n={x:_n(s.bounds.x,t.bounds.x,e),y:_n(s.bounds.y,t.bounds.y,e),width:_n(s.bounds.width,t.bounds.width,e),height:_n(s.bounds.height,t.bounds.height,e)},i=_n(s.angle,t.angle,e),r=_n(s.transparency,t.transparency,e),a=_n(s.haloScale,t.haloScale,e),o=_n(s.blur??0,t.blur??0,e),c=_n(s.brightness??0,t.brightness??0,e),l=Vm(s.color,t.color,e),h=me.lerpAngular(s.angular,t.angular,e),u=km(s.aim,t.aim,e);return s.kind==="polygon"&&t.kind==="polygon"&&s.points.length===t.points.length?{...s,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u,behindCloud:e<1?s.behindCloud:t.behindCloud,points:s.points.map((d,f)=>({x:_n(d.x,t.points[f].x,e),y:_n(d.y,t.points[f].y,e)}))}:{...e<1?s:t,bounds:n,angle:i,transparency:r,haloScale:a,blur:o,brightness:c,color:l,angular:h,aim:u}}class cc{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const i=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!i.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const i of e)this.order.includes(i.sourceId)||this.order.push(i.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getKeyframeAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e];return n?.t===t?n:void 0}getShapeAt(t,e){return this.getKeyframeAt(t)?.shapes.find(n=>n.sourceId===e)?.shape}getLatestShapeAt(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return i.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const i=this.findShapeAtOrAfter(t,e);return n?i?Wm(n.shape,i.shape,(t-n.t)/(i.t-n.t)):n.shape:i?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const i=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(i)return{t:this.keyframes[n].t,shape:i.shape}}}hitTest(t,e,n,i){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(i?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&Hm(o,e,n))return{sourceId:r[a],shape:o}}}removeSource(t){for(let e=this.keyframes.length-1;e>=0;e--){const n=this.keyframes[e].shapes.filter(i=>i.sourceId!==t);n.length===0?this.keyframes.splice(e,1):n.length!==this.keyframes[e].shapes.length&&(this.keyframes[e]={t:this.keyframes[e].t,shapes:n})}this.order=this.order.filter(e=>e!==t),this.removeFromGroup(t)}group(t){if(!(t.length<2)){for(const e of t)this.removeFromGroup(e);this.groups.push([...t])}}ungroup(t){const e=this.groups.findIndex(n=>n.includes(t));e!==-1&&this.groups.splice(e,1)}groupMembers(t){return this.groups.find(e=>e.includes(t))}removeFromGroup(t){const e=this.groups.findIndex(i=>i.includes(t));if(e===-1)return;const n=this.groups[e].filter(i=>i!==t);n.length<2?this.groups.splice(e,1):this.groups[e]=n}bringToFront(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.push(t))}sendToBack(t){const e=this.order.indexOf(t);e!==-1&&(this.order.splice(e,1),this.order.unshift(t))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(t){const e=new cc;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(i=>!t.order.includes(i));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(i=>e.order.includes(i))).filter(n=>n.length>=2)),e}}function Xm(s,t,e){return Math.max(t,Math.min(e,s))}function qm(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function zs(s,t,e){return s+(t-s)*e}function Ym(s,t,e){return{lat:s.lat===void 0||t.lat===void 0?void 0:zs(s.lat,t.lat,e),lng:s.lng===void 0||t.lng===void 0?void 0:zs(s.lng,t.lng,e),elevationM:zs(s.elevationM,t.elevationM,e),headingDeg:s.headingDeg===void 0||t.headingDeg===void 0?void 0:qm(s.headingDeg,t.headingDeg,e),pitchDeg:zs(s.pitchDeg,t.pitchDeg,e),rollDeg:zs(s.rollDeg??0,t.rollDeg??0,e),fovDeg:zs(s.fovDeg,t.fovDeg,e),fNumber:s.fNumber,focusDistanceM:s.focusDistanceM}}class fa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,pose:e}:this.keyframes.splice(n,0,{t,pose:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestPoseAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].pose:void 0}getInterpolatedPoseAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.pose;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?Ym(n.pose,i.pose,Xm((t-n.t)/(i.t-n.t),0,1)):n.pose:i?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new fa;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function Xi(s,t,e){return s+(t-s)*e}function Km(s,t,e){const n=((t-s)%360+540)%360-180;return((s+n*e)%360+360)%360}function $m(s,t,e){return Math.max(t,Math.min(e,s))}function Zm(s,t,e){return{cloudCover:Xi(s.cloudCover,t.cloudCover,e),cloudDarkness:Xi(s.cloudDarkness,t.cloudDarkness,e),highCloudCover:s.highCloudCover===void 0||t.highCloudCover===void 0?void 0:Xi(s.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:s.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:Xi(s.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:s.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:Xi(s.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:s.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:Xi(s.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?s.precipitationType:t.precipitationType,precipitationIntensity:Xi(s.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Km(s.windDirectionDeg,t.windDirectionDeg,e),windSpeed:Xi(s.windSpeed,t.windSpeed,e),storm:e<1?s.storm:t.storm}}class pa{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,weather:e}:this.keyframes.splice(n,0,{t,weather:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}getLatestWeatherAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].weather:void 0}getInterpolatedWeatherAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.weather;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?i?Zm(n.weather,i.weather,$m((t-n.t)/(i.t-n.t),0,1)):n.weather:i?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new pa;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class ma{keyframes=[];addKeyframe(t,e){const n=this.findInsertIndex(t);this.keyframes[n]?.t===t?this.keyframes[n]={t,sound:e}:this.keyframes.splice(n,0,{t,sound:e})}clear(){this.keyframes.length=0}removeKeyframeAt(t){const e=this.findInsertIndex(t);this.keyframes[e]?.t===t&&this.keyframes.splice(e,1)}getLatestSoundAt(t){let e=this.findInsertIndex(t);return this.keyframes[e]?.t!==t&&(e-=1),e>=0?this.keyframes[e].sound:void 0}getInterpolatedSoundAt(t){const e=this.findInsertIndex(t),n=this.keyframes[e]?.t===t?this.keyframes[e]:this.keyframes[e-1];if(n?.t===t)return n.sound;const i=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return i?.sound;if(!i)return n.sound;const r=(t-n.t)/(i.t-n.t);return this.lerp(n.sound,i.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(t){const e=new ma;for(const n of t.keyframes)e.addKeyframe(n.t,n.sound);return e}lerp(t,e,n){return{kind:n<1?t.kind:e.kind,volume:t.volume+(e.volume-t.volume)*n,pitchHz:t.pitchHz+(e.pitchHz-t.pitchHz)*n,src:n<1?t.src:e.src}}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const i=e+n>>>1;this.keyframes[i].t<t?e=i+1:n=i}return e}}const Kf=1e3,Jm=.65,$f={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Qm=100,jm={kind:"none",volume:0,pitchHz:Qm};class On{constructor(t){this.entries=t}static empty(){return new On(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 On(new Map);return{recording:On.stripValue(t,[],e),provenance:e}}static restore(t,e){if(e.size===0)return t;const n=structuredClone(t);for(const i of e.paths()){const r=e.at(i),a=i.split("."),o=On.holderOf(n,a);if(!o)continue;const c=a[a.length-1],l=o[c];l!==void 0&&(r.of!==void 0&&JSON.stringify(r.of)!==JSON.stringify(l)||(o[c]={value:l,...r.basis==="stated"?{}:{basis:r.basis},...r.rationale===void 0?{}:{rationale:r.rationale}}))}return n}static isWrapper(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&"value"in t}static stripValue(t,e,n){return On.isWrapper(t)?(n.set(e.join("."),{basis:t.basis??"stated",...t.rationale===void 0?{}:{rationale:t.rationale},of:t.value}),On.stripValue(t.value,e,n)):Array.isArray(t)?t.map((i,r)=>On.stripValue(i,[...e,String(r)],n)):typeof t=="object"&&t!==null?Object.fromEntries(Object.entries(t).map(([i,r])=>[i,On.stripValue(r,[...e,i],n)])):t}static holderOf(t,e){let n=t;for(const i of e.slice(0,-1)){if(typeof n!="object"||n===null)return;n=n[i]}return typeof n=="object"&&n!==null?n:void 0}}function Ll(s){if(s.year!==void 0)return Date.UTC(s.year,(s.month??1)-1,s.day??1,s.hour??0,s.minute??0,s.second??0)}function Wu(s){return(((s.day??0)*24+(s.hour??0))*60+(s.minute??0))*6e4+(s.second??0)*1e3}const tg=["year","month","day","hour","minute"],eg=["day","hour","minute"];function Xu(s,t){return t.filter(e=>s[e]!==void 0).join(",")}function ng(s){if(s.durationSeconds!==void 0)return s.durationSeconds*1e3;if(!s.time||!s.endTime)return;const t=s.time.year!==void 0&&s.endTime.year!==void 0,e=t?tg:eg,n=Xu(s.time,e);if(!(n===""||n!==Xu(s.endTime,e)))return t?Ll(s.endTime)-Ll(s.time):Wu(s.endTime)-Wu(s.time)}class lc{constructor(t,e,n,i,r,a,o,c,l=[],h,u,d,f=[]){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=i,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u,this.exposureSeconds=d,this.milestones=f}provenance=On.empty();testimony;get witnessCount(){return 1+this.decor.filter(t=>t.kind==="witness").length}get exposure(){return this.exposureSeconds??this.instrument.exposureSeconds}get instrument(){return ze.byId(this.instrumentId)}static create(t,e,n){return new lc({eventType:"sighting",time:t,place:e},new cc,new fa,new pa,new ma,n)}}const ig=0,sg=0;function tn(s,t){const e=s.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=s.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:ig,headingDeg:void 0,pitchDeg:sg,fovDeg:ze.fieldOfViewDeg(s.instrument)}}function qu(s,t){return s.weatherTrack.getInterpolatedWeatherAt(t)??s.weather??$f}function rg(s,t){return s.soundTrack.getInterpolatedSoundAt(t)??jm}class ag{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;onEnded;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const t=()=>{if(this.state!=="playing")return;const e=performance.now();if(this.currentT+=(e-this.lastWallTime)*this.playbackRate,this.lastWallTime=e,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT),this.onEnded?.();return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(t)};this.rafId=requestAnimationFrame(t)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(t){this.currentT=Math.max(0,Math.min(t,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(t){const e=new Map;for(const n of this.timeline.sourceIds){const i=this.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}this.onFrame(t,e)}}const Zf=["nw","n","ne","e","se","s","sw","w"],og=24,Pa=8,cg=3,lg=8;function Ia(s,t,e){const n=s.x-t.x,i=s.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-i*a,y:t.y+n*a+i*r}}function Nr(s){return{x:s.x+s.width/2,y:s.y+s.height/2}}const hg={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 Tn{static handlePointsFor(t){const{x:e,y:n,width:i,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+i/2,y:n},ne:{x:e+i,y:n},e:{x:e+i,y:n+r/2},se:{x:e+i,y:n+r},s:{x:e+i/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+i/2,y:n-og}},o=Nr(t.bounds),c={};for(const l of Object.keys(a))c[l]=Ia(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,i=[...Zf,"rotate"]){const r=Tn.handlePointsFor(t);for(const a of i)if(Math.hypot(e.x-r[a].x,e.y-r[a].y)<=n)return a}static HANDLE_DIRECTION_DEG={e:0,se:45,s:90,sw:135,w:180,nw:225,n:270,ne:315};static resizeAxisFor(t,e){const i=((Tn.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(i)%r.length]}static resizeBounds(t,e,n,i){const r=Nr(t),a=Ia(i,r,-e),{x:o,y:c,width:l,height:h}=t,u=hg[n];let d=o,f=c,g=o+l,v=c+h;return u.left&&(d=Math.min(a.x,g-Pa)),u.right&&(g=Math.max(a.x,d+Pa)),u.top&&(f=Math.min(a.y,v-Pa)),u.bottom&&(v=Math.max(a.y,f+Pa)),{x:d,y:f,width:g-d,height:v-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:i,height:r}=t.bounds,a=Tn.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=i===0?1:a.width/i,c=r===0?1:a.height/r;return{...t,bounds:a,points:t.points.map(l=>({x:l.x*o,y:l.y*c}))}}static rotateShape(t,e){const n=Nr(t.bounds),i=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:i}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),i=Math.max(...t.map(a=>a.x+a.width)),r=Math.max(...t.map(a=>a.y+a.height));return{x:e,y:n,width:i-e,height:r-n}}static vertexPointsFor(t){const e=Nr(t.bounds);return t.points.map(n=>Ia({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=lg){const i=Tn.vertexPointsFor(t);let r,a=n;return i.forEach((o,c)=>{const l=Math.hypot(e.x-o.x,e.y-o.y);l<=a&&(a=l,r=c)}),r}static toLocalPoint(t,e){const n=Nr(t.bounds),i=Ia(e,n,-t.angle);return{x:i.x-t.bounds.x,y:i.y-t.bounds.y}}static moveVertex(t,e,n){const i=t.points.map((u,d)=>d===e?Tn.toLocalPoint(t,n):u),r=Math.min(...i.map(u=>u.x)),a=Math.min(...i.map(u=>u.y)),o=Math.max(...i.map(u=>u.x)),c=Math.max(...i.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=i.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=Tn.toLocalPoint(t,e),{points:i}=t;let r=i.length-1,a=1/0;for(let c=0;c<i.length;c++){const l=i[c],h=i[(c+1)%i.length],u=Tn.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...i.slice(0,r+1),n,...i.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const i=n.x-e.x,r=n.y-e.y,a=i*i+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*i+(t.y-e.y)*r)/a)),c=e.x+o*i,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=cg?t:{...t,points:t.points.filter((n,i)=>i!==e)}}}const Nl=6,La=Nl/2,Yu=20,Ku=24,$u=9,Zu=6,Ju=7,Qu=6,ju=4;class Ol{constructor(t){this.ctx=t}starPoints=0;roll=0;clear(t,e){this.ctx.clearRect(0,0,t,e)}static paintExtent(t){const{x:e,y:n,width:i,height:r}=t.bounds,a=e+i/2,o=n+r/2,c=t.angle%(2*Math.PI)!==0,l=Math.hypot(i,r)/2,h=c?l:i/2,u=c?l:r/2,d=Math.max(i,r)/2,f=t.brightness??0,g=f>0?Math.max(d*(1+$u*f),Qu*f)-d:0,v=f>0?d*(1+Ju*f)-d:0,p=3*Ku*(t.blur??0)+1.5*Yu*t.haloScale,m=Math.max(g,v,0)+p+2;return{x:a-h-m,y:o-u-m,width:2*(h+m),height:2*(u+m)}}paintInto(t,e,n){this.ctx.save(),this.ctx.scale(n,n),this.ctx.translate(-e.x,-e.y),this.paintShape(t.selected?{...t,selected:!1}:t),this.ctx.restore()}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency;const e=t.blur??0;e>0&&(this.ctx.filter=`blur(${(Ku*e).toFixed(2)}px)`);const n=t.brightness??0;n>0&&this.paintDazzle(t,n),t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}setStarPoints(t){this.starPoints=Math.max(0,Math.floor(t))}setRoll(t){this.roll=t}paintDazzle(t,e){const{x:n,y:i,width:r,height:a}=t.bounds,o=n+r/2,c=i+a/2,l=Math.max(r,a)/2,h=Math.max(l*(1+$u*e),Qu*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<=Zu;d++){const f=d/Zu,g=1/(1+24*f*f);this.ctx.globalAlpha=1,u.addColorStop(f,this.withAlpha(t.color,g*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+Ju*e);this.ctx.lineWidth=Math.max(1,l*.12),this.ctx.lineCap="round";for(let f=0;f<this.starPoints;f++){const g=f/this.starPoints*Math.PI*2+this.roll,v=o+Math.cos(g)*d,p=c+Math.sin(g)*d,m=this.ctx.createLinearGradient(o,c,v,p);m.addColorStop(0,this.withAlpha(t.color,e*.55)),m.addColorStop(.35,this.withAlpha(t.color,e*.22)),m.addColorStop(1,this.withAlpha(t.color,0)),this.ctx.strokeStyle=m,this.ctx.beginPath(),this.ctx.moveTo(o,c),this.ctx.lineTo(v,p),this.ctx.stroke()}}this.ctx.restore()}dazzledFill(t,e){if(e<=0)return t.color;const n=/^#([0-9a-f]{6})$/i.exec(t.color.trim());if(!n)return t.color;const i=Number.parseInt(n[1],16),r=a=>Math.round(a+(255-a)*e);return`rgb(${r(i>>16&255)}, ${r(i>>8&255)}, ${r(i&255)})`}withAlpha(t,e){const n=Math.max(0,Math.min(1,e)),i=/^#([0-9a-f]{6})$/i.exec(t.trim());if(!i)return t;const r=Number.parseInt(i[1],16);return`rgba(${r>>16&255}, ${r>>8&255}, ${r&255}, ${n.toFixed(3)})`}paintBase(t){if(this.ctx.fillStyle=this.dazzledFill(t,t.brightness??0),this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:i,height:r}=t.bounds,a=i/2,o=r/2;this.ctx.ellipse(e+a,n+o,a,o,t.angle,0,2*Math.PI)}else{const{x:e,y:n,width:i,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+i/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-i/2,-r/2),t.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(t){this.ctx.save(),this.ctx.shadowColor=t.color,this.ctx.shadowBlur=Yu*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(Tn.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of Tn.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,ju,ju,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(Tn.handlePointsFor(t))}paintSelectionOnly(t){this.paintSelectionHandles(t)}paintGroupHandles(t){this.paintHandleFrame(Tn.handlePointsFor({bounds:t,angle:0}),{includeRotate:!0})}paintOutline(t){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(t.nw.x,t.nw.y),this.ctx.lineTo(t.ne.x,t.ne.y),this.ctx.lineTo(t.se.x,t.se.y),this.ctx.lineTo(t.sw.x,t.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(t,{includeRotate:e}){this.paintOutline(t),this.ctx.fillStyle="lightgray";for(const n of Zf){const i=t[n];this.ctx.fillRect(i.x-La,i.y-La,Nl,Nl)}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,La+1,La+1,0,0,2*Math.PI),this.ctx.fill())}}const td=.05,ed=.08,nd=2,id=3,ug=14,dg=.02;class fg{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",t);return}}this.context.state==="suspended"&&this.context.resume()}setSound(t){if(this.requested=t,!this.context)return;const e=this.keyFor(t);if(!e){this.silence();return}if(this.voice?.key!==e){this.stopVoice();const n=++this.voiceToken;e.startsWith("src:")?this.buildRecordedVoice(t.src,e,n):this.voice=this.buildSynthesizedVoice(t,e)}this.applyTo(this.voice,t)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(t){if(!(t.volume<=0))return t.src?`src:${t.src}`:t.kind==="none"?void 0:t.kind}applyTo(t,e){const n=this.context;if(!t||!n)return;const i=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,i,td);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),i,td)}buildSynthesizedVoice(t,e){const n=this.context;if(n)switch(t.kind){case"hum":return this.buildHum(n,e);case"whistle":return this.buildWhistle(n,e);case"rumble":return this.buildRumble(n,e);case"crackle":return this.buildCrackle(n,e);default:return}}buildHum(t,e){const n=t.createOscillator();n.type="sawtooth";const i=t.createOscillator();i.type="sawtooth";const r=t.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=t.createGain();return a.gain.value=0,n.connect(r),i.connect(r),r.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:i.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const i=t.createOscillator();i.type="sine",i.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,i.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),i.start(),{key:e,nodes:[r,a],sources:[n,i],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(t,e){const n=t.createBufferSource();n.buffer=this.brownNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="lowpass",i.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(i).connect(r).connect(t.destination),n.start(),{key:e,nodes:[i,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:i.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const i=t.createBiquadFilter();i.type="bandpass",i.Q.value=1.2;const r=t.createGain();r.gain.value=0;const a=t.createBufferSource();a.buffer=this.crackleEnvelope(t),a.loop=!0;const o=t.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(i).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[i,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:i.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const i=this.context;if(!i)return;let r;try{r=await this.getBuffer(t)}catch(c){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",c);return}if(n!==this.voiceToken||!this.context)return;const a=i.createBufferSource();a.buffer=r,a.loop=!0;const o=i.createGain();o.gain.value=0,a.connect(o).connect(i.destination),a.start(),this.voice={key:e,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(t){const e=this.context;if(!e)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*nd),t.sampleRate),n=e.getChannelData(0);for(let i=0;i<n.length;i++)n[i]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*nd),t.sampleRate),n=e.getChannelData(0);let i=0,r=0;for(let a=0;a<n.length;a++)i=(i+.02*(Math.random()*2-1))/1.02,n[a]=i,r=Math.max(r,Math.abs(i));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return e}crackleEnvelope(t){if(!this.crackleBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*id),t.sampleRate),n=e.getChannelData(0),i=Math.max(1,Math.floor(dg*t.sampleRate)),r=Math.round(id*ug);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),c=.4+Math.random()*.6;for(let l=0;l<i&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/i))}this.crackleBuffer=e}return this.crackleBuffer}stopVoice(){const t=this.voice,e=this.context;if(this.voice=void 0,!t||!e)return;const n=e.currentTime;t.volumeParam.cancelScheduledValues(n),t.volumeParam.setTargetAtTime(0,n,ed/3);const i=n+ed;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(i)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}function Go(s){return[...s].sort((t,e)=>t.t-e.t)}function sd(s,t){let e;for(const n of Go(s)){if(n.t>t)break;e=n}return e}const Mc=Math.PI/180,Na=180/Math.PI;class Ii{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const i=n*Mc/2;this.focalPx=t==="equidistant"?e/2/i:e/2/Math.tan(i)}focalPx;static of(t,e,n){return new Ii(t.projection,e,n)}degToPx(t){const e=t*Mc;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Na:2*Math.atan(t/(2*this.focalPx))*Na}angleDegToRadiusPx(t){const e=t*Mc;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*Na:Math.atan(t/this.focalPx)*Na}ofBounds(t){return{widthDeg:this.pxToDeg(t.width),heightDeg:this.pxToDeg(t.height)}}toBoundsSize(t){return{width:this.degToPx(t.widthDeg),height:this.degToPx(t.heightDeg)}}widthPx(t){return this.degToPx(me.angularWidthDeg(t))}}class Un{static fovOf(t,e){return tn(t,e)?.fovDeg??ze.fieldOfViewDeg(t.instrument)}static toAngular(t){this.eachKeyframe(t,(e,n)=>({...e,angular:n.ofBounds(e.bounds)}))}static toBounds(t){this.eachKeyframe(t,(e,n)=>{if(!e.angular)return e;const{width:i,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-i)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:i,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:i/e.bounds.width,c=e.bounds.height===0?1:r/e.bounds.height;return{...e,bounds:a,points:e.points.map(l=>({x:l.x*o,y:l.y*c}))}})}static toAim(t){this.eachKeyframe(t,(e,n,i)=>{const r=this.aimFrom(t,n,i,e.bounds);return r?{...e,aim:r}:e})}static aimOf(t,e,n){const i=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,this.fovOf(t,e));return this.aimFrom(t,i,tn(t,e),n)}static aimFrom(t,e,n,i){if(n?.headingDeg===void 0)return;const r=this.frameCentre(t),a=e.radiusPxToAngleDeg(i.x+i.width/2-r.x),o=e.radiusPxToAngleDeg(r.y-(i.y+i.height/2));return{azimuthDeg:((n.headingDeg+a)%360+360)%360,altitudeDeg:n.pitchDeg+o}}static toPosition(t){this.eachKeyframe(t,(e,n,i)=>{if(!e.aim||i?.headingDeg===void 0)return e;const r=this.frameCentre(t),a=this.shortestArc(e.aim.azimuthDeg-i.headingDeg),o=e.aim.altitudeDeg-i.pitchDeg,c=r.x+this.offAxisPx(n,a)-e.bounds.width/2,l=r.y-this.offAxisPx(n,o)-e.bounds.height/2;return{...e,bounds:{...e.bounds,x:c,y:l}}})}static frameCentre(t){return{x:ze.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,y:me.CANVAS_HEIGHT_PX/2}}static shortestArc(t){return(t%360+540)%360-180}static offAxisPx(t,e){return Math.abs(e)>=Un.OFF_CANVAS_DEG?Math.sign(e)*Un.OFF_CANVAS_PX:t.angleDegToRadiusPx(e)}static OFF_CANVAS_DEG=89;static OFF_CANVAS_PX=1e5;static reproject(t,e,n){const i=ze.frameWidthPx(e,me.CANVAS_HEIGHT_PX)/2,r=ze.frameWidthPx(t.instrument,me.CANVAS_HEIGHT_PX)/2,a=me.CANVAS_HEIGHT_PX/2;for(const o of[...t.timeline.allKeyframes]){const c=this.fovOf(t,o.t),l=n?.get(o.t)??c,h=Ii.of(e,me.CANVAS_HEIGHT_PX,l),u=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,c);t.timeline.addKeyframe(o.t,o.shapes.map(d=>{const{bounds:f}=d.shape,g=f.x+f.width/2-i,v=f.y+f.height/2-a,p=Math.hypot(g,v),m=p===0?1:u.angleDegToRadiusPx(h.radiusPxToAngleDeg(p))/p,b={...f,x:r+g*m-f.width/2,y:a+v*m-f.height/2};return{...d,shape:{...d.shape,bounds:b}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const i of[...n.allKeyframes]){const r=tn(t,i.t),a=this.fovOf(t,i.t),o=Ii.of(t.instrument,me.CANVAS_HEIGHT_PX,a);n.addKeyframe(i.t,i.shapes.map(c=>({...c,shape:e(c.shape,o,r)})))}}}function pg(s){return On.restore(mg(s),s.provenance)}function mg(s){return Un.toAngular(s),Un.toAim(s),{version:1,time:s.event.time,endTime:s.event.endTime,durationSeconds:s.event.durationSeconds,utcOffsetHours:s.event.utcOffsetHours,timeZone:s.event.timeZone,place:s.event.place,witness:s.witness,testimony:s.testimony,caseId:s.caseId,description:s.event.description,tags:s.event.tags,timeline:s.timeline.toJSON(),witnessTrack:s.witnessTrack.toJSON(),weatherTrack:s.weatherTrack.toJSON(),soundTrack:s.soundTrack.toJSON(),weather:s.weather,decor:s.decor,milestones:s.milestones.length>0?s.milestones:void 0,weatherSource:s.weatherSource,instrument:s.instrumentId,exposureSeconds:s.exposureSeconds}}function gg(s){const{recording:t,provenance:e}=On.strip(s),n=vg(t);return n.provenance=e,n}function vg(s){const t=new lc({eventType:"sighting",time:s.time,endTime:s.endTime,durationSeconds:s.durationSeconds,utcOffsetHours:s.utcOffsetHours,timeZone:s.timeZone,place:s.place,description:s.description,tags:s.tags},cc.fromJSON(s.timeline),s.witnessTrack?fa.fromJSON(s.witnessTrack):new fa,s.weatherTrack?pa.fromJSON(s.weatherTrack):new pa,s.soundTrack?ma.fromJSON(s.soundTrack):new ma,s.witness,s.caseId,s.weather,s.decor??[],s.weatherSource,s.instrument,s.exposureSeconds??s.witnessTrack?.keyframes.map(e=>e.pose.exposureSeconds).find(e=>e!==void 0),Go(s.milestones??[]));return t.testimony=s.testimony,Un.toBounds(t),Un.toPosition(t),t}function eu(s,t){for(const e of s){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}class Vo{static preferencesFor(t){const e=navigator.languages??[],n=this.declaredFor(t);return n?[n,...e]:e}static declaredFor(t){for(let e=t;e;){const n=e.closest("[lang]")?.getAttribute("lang")?.trim();if(n)return n;const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:void 0}}}class ns{constructor(t){this.preferences=t}read(t){if(t===void 0||typeof t=="string")return t===""?void 0:t;for(const n of this.preferences){const i=t[n]??t[ns.base(n)];if(i)return i}const e=new Set(this.preferences.map(n=>ns.base(n)));for(const[n,i]of Object.entries(t))if(i&&e.has(ns.base(n)))return i;return Object.values(t).find(n=>n)??void 0}write(t,e,n){const i=e?.trim()?e.trim():void 0;if(t===void 0||typeof t=="string")return i;const r={...t},a=Object.keys(r).find(o=>o===n)??Object.keys(r).find(o=>ns.base(o)===ns.base(n))??n;return i===void 0?delete r[a]:r[a]=i,Object.keys(r).length===0?void 0:r}static base(t){return t.toLowerCase().split("-")[0]}}const xg="modulepreload",_g=function(s,t){return new URL(s,t).href},rd={},Ul=function(t,e,n){let i=Promise.resolve();if(e&&e.length>0){let a=function(h){return Promise.all(h.map(u=>Promise.resolve(u).then(d=>({status:"fulfilled",value:d}),d=>({status:"rejected",reason:d}))))};const o=document.getElementsByTagName("link"),c=document.querySelector("meta[property=csp-nonce]"),l=c?.nonce||c?.getAttribute("nonce");i=a(e.map(h=>{if(h=_g(h,n),h in rd)return;rd[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let v=o.length-1;v>=0;v--){const p=o[v];if(p.href===h&&(!u||p.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":xg,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((v,p)=>{g.addEventListener("load",v),g.addEventListener("error",()=>p(new Error(`Unable to preload CSS for ${h}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return i.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},Mg=["en","fr"],yg={en:()=>Ul(()=>Promise.resolve().then(()=>bg),void 0,import.meta.url).then(s=>s.ufoMessages_en),fr:()=>Ul(()=>import("./UfoMessages_fr-BJPYHN17.js"),[],import.meta.url).then(s=>s.ufoMessages_fr)};function Sg(s){return yg[s]()}const Jf={play:"Play",pause:"Pause",noDuration:"No observation duration",autoReplay:"Auto-replay",currentPosition:"Current position",duration:"Duration",switchToElapsed:"click to show elapsed time",switchToClockTime:"click to show the time of day",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",showWitnessMap:"Show where the witness was",hideWitnessMap:"Hide where the witness was",mapImageryUnavailable:"Aerial imagery unavailable",showMilestones:"Show the account's moments",hideMilestones:"Hide the account's moments",witnessHere:"The witness, here",decorHere:"Scenery"},bg=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Jf},Symbol.toStringTag,{value:"Module"})),ad=2;function Qf(s){return s==="building"||s==="vehicle"}function Eg(s,t){const e=s.litKeyframes;if(!e||e.length===0)return s.lit??!1;let n=e[0];for(const i of e){if(i.t>t)break;n=i}return n.lit}function wg(s,t){return s.pattern.kind==="steady"?!0:jf(s,t,t+1)>.5}function jf(s,t,e){if(s.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:i,phase:r=0}=s.pattern,a=Math.min(Math.max(i,0),1);if(a===0||n<=0)return 0;const o=6e4/n,c=t/o+r,l=e/o+r;if(l<=c)return Math.min(Math.max(c-Math.floor(c),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(l)-h(c))/(l-c)}function nu(s,t){const e=s.track,n={eastM:s.eastM,northM:s.northM,altitudeM:0,headingDeg:s.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return od(e[0],s);const i=e[e.length-1];if(t>=i.t)return od(i,s);for(let r=0;r<e.length-1;r++){const a=e[r],o=e[r+1];if(t<a.t||t>o.t)continue;const c=o.t-a.t,l=c===0?0:(t-a.t)/c;return{eastM:a.eastM+(o.eastM-a.eastM)*l,northM:a.northM+(o.northM-a.northM)*l,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*l,headingDeg:a.headingDeg??s.headingDeg}}return n}function od(s,t){return{eastM:s.eastM,northM:s.northM,altitudeM:s.altitudeM??0,headingDeg:s.headingDeg??t.headingDeg}}const tp=Math.PI/180,Ag=180/Math.PI,Tg=256,Rg=19;function Dg(s,t){return 156543.03392*Math.cos(s*tp)/2**t}function Cg(s,t){return Dg(s,t)*Tg}function ep(s,t){let e=0;for(;e<Rg&&Cg(s,e+1)>=t;)e++;return e}function Io(s){const t=s*tp;return(1-Math.log(Math.tan(t)+1/Math.cos(t))/Math.PI)/2}function np(s,t,e){const n=2**e;return{x:(s+180)/360*n,y:Io(t)*n}}function ip(s,t,e){const n=Io(s.north),i=Io(s.south);return{x:(t-s.west)/(s.east-s.west),y:(Io(e)-n)/(i-n)}}function Pg(s,t,e){const{x:n,y:i}=np(s,t,e);return{x:Math.floor(n),y:Math.floor(i),z:e}}function Ig(s){const t=2**s.z,e=s.x/t*360-180,n=(s.x+1)/t*360-180,i=cd(s.y,t);return{south:cd(s.y+1,t),north:i,west:e,east:n}}function cd(s,t){const e=s/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*Ag}function sp(s,t,e,n){const i=Pg(s,t,e),r=Math.floor(n/2),a=[];for(let l=-r;l<=r;l++)for(let h=-r;h<=r;h++)a.push({x:i.x+h,y:i.y+l,z:e});const o=a.map(Ig),c={south:Math.min(...o.map(l=>l.south)),north:Math.max(...o.map(l=>l.north)),west:Math.min(...o.map(l=>l.west)),east:Math.max(...o.map(l=>l.east))};return{tiles:a,bounds:c}}class Ms{constructor(t){this.ctx=t}static SCALE_STEPS_M=[5e3,2e3,1e3,500,200,100,50,20,10,5];static MARKER_RADIUS_PX=8.5;static ON_MARKER_M=3;targets=[];hitTest(t,e){let n,i=1/0;for(const r of this.targets){const a=Math.hypot(r.x-t,r.y-e);a>r.radius||a>i||(n=r,i=a)}return n}get width(){return this.ctx.canvas.width}get height(){return this.ctx.canvas.height}paint(t){const{ctx:e}=this;e.save(),this.targets=[],e.clearRect(0,0,this.width,this.height),this.paintGround(t),this.paintNight(t.nightFraction),this.paintPath(t),t.position?(this.paintCone(t,t.position),this.paintDecor(t),this.paintMarkers(t),this.paintWitness(t,t.position)):(this.paintDecor(t),this.paintMarkers(t)),this.paintNorth(),this.paintFooter(t.bounds,t.attribution),e.restore()}toCanvas(t,e,n){const i=ip(t,n,e);return{x:i.x*this.width,y:i.y*this.height}}paintGround(t){const{ctx:e}=this;e.fillStyle="#1d2321",e.fillRect(0,0,this.width,this.height);const n=t.imagery;if(!n)return;const i=this.toCanvas(t.bounds,n.bounds.north,n.bounds.west),r=this.toCanvas(t.bounds,n.bounds.south,n.bounds.east);e.drawImage(n.source,i.x,i.y,r.x-i.x,r.y-i.y)}paintNight(t=0){if(t<=0)return;const{ctx:e}=this;e.save(),e.fillStyle=`rgba(6, 12, 30, ${Math.min(t,1)*.78})`,e.fillRect(0,0,this.width,this.height),e.restore()}paintDecor(t){const{ctx:e}=this;for(const n of t.decor){const i=this.toCanvas(t.bounds,n.lat,n.lng);if(n.label&&this.targets.push({kind:"decor",label:n.label,lat:n.lat,lng:n.lng,x:i.x,y:i.y,radius:7}),e.beginPath(),e.rect(i.x-3.5,i.y-3.5,7,7),e.fillStyle="rgba(120, 220, 255, 0.85)",e.fill(),e.lineWidth=1.5,e.strokeStyle="rgba(0, 0, 0, 0.7)",e.stroke(),n.headingDeg===void 0)continue;const r=(n.headingDeg-90)*Math.PI/180;e.beginPath(),e.moveTo(i.x,i.y),e.lineTo(i.x+Math.cos(r)*10,i.y+Math.sin(r)*10),e.lineWidth=3,e.strokeStyle="rgba(0, 0, 0, 0.6)",e.stroke(),e.lineWidth=1.5,e.strokeStyle="rgba(120, 220, 255, 0.9)",e.stroke()}}paintPath(t){if(!t.path.moved)return;const{ctx:e}=this,n=t.path.points.map(i=>this.toCanvas(t.bounds,i.lat,i.lng));e.beginPath(),e.moveTo(n[0].x,n[0].y);for(const i of n.slice(1))e.lineTo(i.x,i.y);e.lineJoin="round",e.lineCap="round",e.strokeStyle="rgba(0, 0, 0, 0.65)",e.lineWidth=5,e.stroke(),e.strokeStyle="rgba(255, 255, 255, 0.9)",e.lineWidth=2,e.stroke()}paintCone(t,e){const{headingDeg:n,coneHalfAngleDeg:i}=t;if(n===void 0||i===void 0)return;const{ctx:r}=this,a=this.toCanvas(t.bounds,e.lat,e.lng),o=Math.hypot(this.width,this.height),c=(n-90)*Math.PI/180,l=i*Math.PI/180;r.save(),r.beginPath(),r.moveTo(a.x,a.y),r.arc(a.x,a.y,o,c-l,c+l),r.closePath();const h=r.createRadialGradient(a.x,a.y,0,a.x,a.y,o);h.addColorStop(0,"rgba(255, 224, 130, 0.55)"),h.addColorStop(.35,"rgba(255, 224, 130, 0.22)"),h.addColorStop(1,"rgba(255, 224, 130, 0)"),r.fillStyle=h,r.fill(),r.restore()}paintMarkers(t){const{ctx:e}=this;e.textAlign="center",e.textBaseline="middle",e.font="bold 10px sans-serif";for(const n of[...t.markers].sort((i,r)=>Number(i.current)-Number(r.current))){const i=this.toCanvas(t.bounds,n.lat,n.lng);this.targets.push({kind:"milestone",label:n.note?`${n.label} — ${n.note}`:n.label,lat:n.lat,lng:n.lng,t:n.t,x:i.x,y:i.y,radius:Ms.MARKER_RADIUS_PX}),e.beginPath(),e.arc(i.x,i.y,Ms.MARKER_RADIUS_PX,0,Math.PI*2),e.fillStyle=n.current?"rgba(255, 224, 130, 0.95)":"rgba(0, 0, 0, 0.55)",e.fill(),e.lineWidth=2,e.strokeStyle="rgba(255, 255, 255, 0.9)",e.stroke(),e.fillStyle=n.current?"#1d2321":"#fff",e.fillText(n.label,i.x,i.y)}}paintWitness(t,e){const{ctx:n}=this,i=this.toCanvas(t.bounds,e.lat,e.lng);t.witnessLabel&&this.targets.push({kind:"witness",label:t.witnessLabel,lat:e.lat,lng:e.lng,x:i.x,y:i.y,radius:8});const r=t.markers.some(a=>{if(!a.current)return!1;const o=un(a.lat,a.lng,e.lat,e.lng);return Math.hypot(o.x,o.z)<=Ms.ON_MARKER_M});n.beginPath(),n.arc(i.x,i.y,r?Ms.MARKER_RADIUS_PX+2.5:5.5,0,Math.PI*2),r||(n.fillStyle="#ff5a3c",n.fill()),n.lineWidth=4,n.strokeStyle="rgba(0, 0, 0, 0.5)",n.stroke(),n.lineWidth=r?3:2.5,n.strokeStyle=r?"#ff5a3c":"#fff",n.stroke()}paintNorth(){const{ctx:t}=this,e=this.width-14,n=16;t.beginPath(),t.moveTo(e,n-9),t.lineTo(e-4.5,n+5),t.lineTo(e,n+2),t.lineTo(e+4.5,n+5),t.closePath(),t.fillStyle="rgba(255, 255, 255, 0.92)",t.strokeStyle="rgba(0, 0, 0, 0.6)",t.lineWidth=1,t.fill(),t.stroke(),t.font="bold 9px sans-serif",t.textAlign="center",t.textBaseline="top",t.strokeText("N",e,n+6),t.fillText("N",e,n+6)}paintFooter(t,e){const{ctx:n}=this;n.font="9px sans-serif",n.textBaseline="bottom";const i=e?this.wrap(e,this.width-20):[];let r=this.height-4;n.textAlign="right";for(const f of i.slice().reverse())this.paintOutlinedText(f,this.width-6,r),r-=11;const a=(t.south+t.north)/2,c=Math.abs(un(a,t.east,a,t.west).x)/this.width,l=Ms.SCALE_STEPS_M.find(f=>f/c<=this.width/3);if(l===void 0)return;const h=l/c,u=8,d=r-3;n.lineWidth=3,n.strokeStyle="rgba(0, 0, 0, 0.6)",n.beginPath(),n.moveTo(u,d),n.lineTo(u+h,d),n.stroke(),n.lineWidth=1.5,n.strokeStyle="rgba(255, 255, 255, 0.95)",n.stroke(),n.textAlign="left",this.paintOutlinedText(l>=1e3?`${l/1e3} km`:`${l} m`,u,d-3)}paintOutlinedText(t,e,n){const{ctx:i}=this;i.lineWidth=3,i.strokeStyle="rgba(0, 0, 0, 0.75)",i.strokeText(t,e,n),i.fillStyle="#fff",i.fillText(t,e,n)}wrap(t,e){const n=[];let i="";for(const r of t.split(" ")){const a=i?`${i} ${r}`:r;i&&this.ctx.measureText(a).width>e?(n.push(i),i=r):i=a}return i&&n.push(i),n}}const Pn=256,ld=3,Lg=32768;class Ng{fetchImpl;tileUrlTemplate;constructor(t={}){this.fetchImpl=t.fetchImpl??fetch.bind(globalThis),this.tileUrlTemplate=t.tileUrlTemplate??"https://s3.amazonaws.com/elevation-tiles-prod/terrarium/{z}/{x}/{y}.png"}async getElevationGrid(t,e){const n=(t.south+t.north)/2,i=(t.west+t.east)/2,r=Math.abs(un(n,t.east,n,t.west).x),a=Math.abs(un(t.north,i,t.south,i).z),o=ep(n,Math.max(r,a)),{tiles:c}=sp(i,n,o,ld),l=ld*Pn,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 g=t.north+(t.south-t.north)*(f/(e.height-1));for(let v=0;v<e.width;v++){const p=t.west+(t.east-t.west)*(v/(e.width-1));d[f*e.width+v]=this.sampleAt(g,p,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,i){const r=this.tileUrlTemplate.replace("{z}",String(t.z)).replace("{x}",String(t.x)).replace("{y}",String(t.y)),a=await this.fetchImpl(r);if(!a.ok)throw new Error(`Elevation tile fetch failed (${a.status}): ${r}`);const o=await createImageBitmap(await a.blob()),c=document.createElement("canvas");c.width=Pn,c.height=Pn;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,Pn,Pn),u=(t.x-e.x)*Pn,d=(t.y-e.y)*Pn;for(let f=0;f<Pn;f++)for(let g=0;g<Pn;g++){const v=(f*Pn+g)*4,p=h[v]*256+h[v+1]+h[v+2]/256-Lg,m=u+g,b=d+f;n[b*i+m]=p}}sampleAt(t,e,n,i,r,a){const{x:o,y:c}=np(e,t,n),l=(o-i.x)*Pn,h=(c-i.y)*Pn,u=Math.max(0,Math.min(a-1,Math.floor(l))),d=Math.max(0,Math.min(a-1,Math.floor(h))),f=Math.min(a-1,u+1),g=Math.min(a-1,d+1),v=l-u,p=h-d,m=r[d*a+u],b=r[d*a+f],E=r[g*a+u],M=r[g*a+f],S=m+(b-m)*v,w=E+(M-E)*v;return S+(w-S)*p}}const yc=256,hd=3;async function Og(s,t,e,n){const i=(s.south+s.north)/2,r=(s.west+s.east)/2,a=Math.abs(un(i,s.east,i,s.west).x),o=Math.abs(un(s.north,r,s.south,r).z),c=ep(i,Math.max(a,o)/2),{tiles:l,bounds:h}=sp(r,i,c,hd),u=hd*yc,d=document.createElement("canvas");d.width=u,d.height=u;const f=d.getContext("2d");if(!f)throw new Error("2D canvas context unavailable");const g=l[0];await Promise.all(l.map(async m=>{const b=e(m),E=await n(b);if(!E.ok)throw new Error(`Imagery tile fetch failed (${E.status}): ${b}`);const M=await createImageBitmap(await E.blob());f.drawImage(M,(m.x-g.x)*yc,(m.y-g.y)*yc)}));const v=document.createElement("canvas");v.width=t.width,v.height=t.height;const p=v.getContext("2d");if(!p)throw new Error("2D canvas context unavailable");return p.drawImage(d,0,0,u,u,0,0,t.width,t.height),{source:v,width:t.width,height:t.height,bounds:h}}class Ug{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 Og(t,e,n=>this.tileUrlTemplate.replace("{z}",String(n.z)).replace("{y}",String(n.y)).replace("{x}",String(n.x)),this.fetchImpl)}}function Fg(){return{elevation:new Ng,imagery:rp()}}function rp(){return new Ug}const zg=new Set,fr="show-witness-map",pr="hide-milestones";class Ln extends HTMLElement{static get observedAttributes(){return["src",fr,pr]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;static WITNESS_MAP_MIN_SPAN_M=400;static WITNESS_MAP_MARGIN=.6;static WITNESS_MAP_IMAGERY_PX=768;fullscreenButton;cornerButtons;witnessMapButton;milestonesButton;witnessMapPanel;witnessMapCanvas;witnessMapRenderer;seekInput;milestoneMarks;milestoneCaption;timeStartLabel;timeEndLabel;witnessPath;witnessMapBounds;witnessMapImagery;witnessMapImageryRequested=!1;witnessMapImageryCredit;witnessMapImageryFailed=!1;creditShownExternally=!1;lookYawDeg=0;lookPitchDeg=0;milestonesShown=!0;currentSighting=lc.create();sightingAudio=new fg;soundPreview;player;loopEnabled=!0;playbackBeforeClick;highlightedSourceIds=new Set;paintsShapes=!0;enableClickToPlay=!0;fullscreenTarget;messages=Jf;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>{this.updateFullscreenButton(),this.resizeWitnessMap()};witnessMapResizeObserver=typeof ResizeObserver>"u"?void 0:new ResizeObserver(()=>this.resizeWitnessMap());resizeWitnessMap(){this.witnessMapPanel.hidden||(this.sizeWitnessMapCanvas(),this.paintWitnessMap(this.currentTime))}simulatedFullscreen=!1;styleBeforeSimulatedFullscreen;bodyOverflowBeforeSimulatedFullscreen;handleSimulatedFullscreenKey=t=>{t.key==="Escape"&&this.exitSimulatedFullscreen()};handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.shapeAt(e.x,e.y),i=this.said.read(n?.shape.title);if(!i){this.tooltip.hidden=!0;return}this.tooltip.textContent=i,this.tooltip.hidden=!1;const r=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-r.left+12}px`,this.tooltip.style.top=`${t.clientY-r.top+12}px`};handleWitnessMapPointerMove=t=>{const e=this.witnessMapTargetFrom(t);if(!e){this.tooltip.hidden=!0,this.witnessMapCanvas.style.cursor="default";return}this.witnessMapCanvas.style.cursor="pointer",this.tooltip.textContent=e.label,this.tooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-n.left+12}px`,this.tooltip.style.top=`${t.clientY-n.top+12}px`};handleWitnessMapClick=t=>{const e=this.witnessMapTargetFrom(t);if(e){if(e.kind==="milestone"&&e.t!==void 0){this.player.seek(e.t);return}this.dispatchEvent(new CustomEvent("lookat",{detail:{lat:e.lat,lng:e.lng,kind:e.kind},bubbles:!0,composed:!0}))}};witnessMapTargetFrom(t){const e=this.witnessMapCanvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return this.witnessMapRenderer.hitTest((t.clientX-e.left)/e.width*this.witnessMapCanvas.width,(t.clientY-e.top)/e.height*this.witnessMapCanvas.height)}handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Bm}</style>${zm}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new Ol(this.canvas.getContext("2d")),this.tooltip=this.shadow.getElementById("tooltip"),this.toolbar=this.shadow.getElementById("toolbar"),this.playPauseButton=this.shadow.getElementById("play-pause"),this.loopButton=this.shadow.getElementById("loop"),this.fullscreenButton=this.shadow.getElementById("fullscreen"),this.cornerButtons=this.shadow.getElementById("corner-buttons"),this.witnessMapButton=this.shadow.getElementById("witness-map"),this.milestonesButton=this.shadow.getElementById("milestones"),this.witnessMapPanel=this.shadow.getElementById("witness-map-panel"),this.witnessMapCanvas=this.shadow.getElementById("witness-map-canvas"),this.witnessMapRenderer=new Ms(this.witnessMapCanvas.getContext("2d")),this.seekInput=this.shadow.getElementById("seek"),this.milestoneMarks=this.shadow.getElementById("milestone-marks"),this.milestoneCaption=this.shadow.getElementById("milestone-caption"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const e of[this.timeStartLabel,this.timeEndLabel])e.addEventListener("click",()=>this.toggleTimeDisplay()),e.addEventListener("keydown",n=>{n.key!=="Enter"&&n.key!==" "||(n.preventDefault(),this.toggleTimeDisplay())});this.fullscreenTarget=this.stageElement,this.playPauseButton.addEventListener("click",()=>this.togglePlayPause()),this.loopButton.addEventListener("click",()=>this.toggleLoop()),this.fullscreenButton.addEventListener("click",()=>this.toggleFullscreen()),this.witnessMapButton.addEventListener("click",()=>this.toggleWitnessMap()),this.milestonesButton.addEventListener("click",()=>this.toggleMilestones()),this.witnessMapCanvas.addEventListener("pointermove",this.handleWitnessMapPointerMove),this.witnessMapCanvas.addEventListener("pointerleave",this.handlePointerLeave),this.witnessMapCanvas.addEventListener("click",this.handleWitnessMapClick),this.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",e=>{this.enableClickToPlay&&(e.detail<=1&&(this.playbackBeforeClick={state:this.playbackState,time:this.currentTime}),this.togglePlayPause())}),this.canvas.addEventListener("dblclick",e=>{this.enableClickToPlay&&(e.preventDefault(),this.restorePlayback(),this.toggleFullscreen())}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.observe(this.witnessMapPanel),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){this.saidTexts=void 0;const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.witnessMapResizeObserver?.disconnect(),this.exitSimulatedFullscreen(),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t===fr&&this.applyWitnessMapDefault(),t===pr&&this.setMilestonesShown(!this.hasAttribute(pr))}async loadFromSrc(t){this.sightingData=await qf.json(t)}get sightingData(){return pg(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=gg(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh(),this.applyWitnessMapDefault()}get sighting(){return this.currentSighting}previewSound(t){this.soundPreview=t,this.sightingAudio.resume(),this.sightingAudio.setSound(t)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(t){this.player.seek(t)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}set autoReplayEnabled(t){t!==this.loopEnabled&&this.toggleLoop()}play(){this.player.seekableDuration<=0||this.playbackState==="playing"||this.togglePlayPause()}pause(){this.playbackState==="playing"&&this.togglePlayPause()}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(t){this.toolbar.classList.toggle("hidden",!t)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(t){this.currentSighting.event.durationSeconds=t,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(t){const e=new Set(t);e.size===this.highlightedSourceIds.size&&[...e].every(i=>this.highlightedSourceIds.has(i))||(this.highlightedSourceIds=e,this.refresh())}hasVisibleShapeAt(t,e){return this.shapeAt(t,e)!==void 0}refresh(){this.applyFrameFormat(),this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.refreshMilestoneMarks(),this.updateMilestonesButton(),this.updateWitnessMap(),this.player.seek(this.player.time)}refreshMilestoneMarks(){const t=this.player.seekableDuration,e=t>0?Go(this.sighting.milestones):[];this.milestoneMarks.replaceChildren(...e.map(n=>{const i=document.createElement("button");i.type="button",i.className="milestone-mark",i.style.left=`${Math.min(Math.max(n.t/t,0),1)*100}%`;const r=this.said.read(n.label)??"",a=this.said.read(n.note),o=a?`${r} — ${a}`:r;return i.title=o,i.setAttribute("aria-label",o),i.addEventListener("click",()=>this.player.seek(n.t)),i}))}showMilestoneAt(t){const e=this.milestonesShown&&this.sighting.milestones.length>0?sd(this.sighting.milestones,t):void 0;if(this.milestoneCaption.hidden=e===void 0,!e)return;const n=document.createElement("b");n.textContent=this.said.read(e.label)??"";const i=this.said.read(e.note),r=i?` — ${i}`:"";this.milestoneCaption.replaceChildren(n,document.createTextNode(r))}exposureInstants(t){const e=this.exposureTimes(t),n=1/e.length;return e.map(i=>({shapes:this.shapesAt(i),share:n}))}exposureTimes(t=this.currentTime){const e=(this.currentSighting.exposure??0)*1e3;if(e<Ln.SHORTEST_VISIBLE_EXPOSURE_MS)return[t];const n=Math.min(Ln.MAX_EXPOSURE_STEPS,Math.max(2,Math.round(e/Ln.SHORTEST_VISIBLE_EXPOSURE_MS))),i=Math.ceil(this.travelPxOver(t,e)/Ln.EXPOSURE_STEP_PX),r=Math.min(Ln.MAX_TRAVEL_STEPS,Math.max(n,i)),a=[];for(let o=0;o<r;o++)a.push(t+e*o/r);return a}travelPxOver(t,e){const n=this.shapesAt(t),i=this.shapesAt(t+e);let r=0;for(const[a,o]of n){const c=i.get(a);if(!c)continue;const l=c.bounds.x+c.bounds.width/2-(o.bounds.x+o.bounds.width/2),h=c.bounds.y+c.bounds.height/2-(o.bounds.y+o.bounds.height/2);r=Math.max(r,Math.hypot(l,h))}return r}shapeAt(t,e,n){for(const i of this.exposureTimes()){const r=this.currentSighting.timeline.hitTest(i,t,e,n);if(r)return r}}shapesAt(t){const e=new Map;for(const n of this.currentSighting.timeline.sourceIds){const i=this.currentSighting.timeline.getInterpolatedShapeAt(t,n);i&&e.set(n,i)}return e}static SHORTEST_VISIBLE_EXPOSURE_MS=20;static MAX_EXPOSURE_STEPS=48;static EXPOSURE_STEP_PX=2;static MAX_TRAVEL_STEPS=320;applyFrameFormat(){const t=ze.frameWidthPx(this.currentSighting.instrument,this.canvas.height);if(this.canvas.width===t)return;this.canvas.width=t,this.canvas.parentElement?.style.setProperty("--frame-aspect",`${t} / ${this.canvas.height}`)}canvasPointFromEvent(t){const e=this.canvas.getBoundingClientRect();if(!(e.width===0||e.height===0))return{x:(t.clientX-e.left)/e.width*this.canvas.width,y:(t.clientY-e.top)/e.height*this.canvas.height}}onFrame(t,e){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:zg;this.canvasRenderer.setStarPoints(ze.starPointsOf(this.sighting.instrument));const i=(tn(this.sighting,t)?.rollDeg??0)+this.gaitAt(t).rollDeg;this.canvasRenderer.setRoll(i*Math.PI/180);const r=this.exposureInstants(t),a=this.frameShift;if(this.paintsShapes)for(const o of r)for(const[,c]of o.shapes){const l=o.share,h=l===1?c:{...c,transparency:1-(1-c.transparency)*l};this.canvasRenderer.paintShape(this.shifted(h,a))}for(const[o,c]of r[0].shapes)n.has(o)&&(this.paintsShapes?n.size===1?this.canvasRenderer.paintShape({...c,selected:!0}):this.canvasRenderer.paintMemberOutline(c):this.canvasRenderer.paintSelectionOnly(this.shifted(c,a)));if(n.size>1){const o=Tn.groupBoundsFor([...e].filter(([c])=>n.has(c)).map(([,c])=>c.bounds));this.canvasRenderer.paintGroupHandles(o)}this.keepWitnessMapClear(r[0].shapes),this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.showMilestoneAt(t),this.paintWitnessMap(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(rg(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}shifted(t,e){return e.x===0&&e.y===0?t:{...t,bounds:{...t.bounds,x:t.bounds.x+e.x,y:t.bounds.y+e.y}}}createPlayer(){const t=new ag(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,t.onEnded=()=>{this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("ended",{bubbles:!0,composed:!0}))},t}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const t=this.player.playbackState==="playing";this.playPauseButton.textContent=t?"⏸":"▶";const e=this.player.seekableDuration>0;this.playPauseButton.disabled=!e;const n=e?t?this.messages.pause:this.messages.play:this.messages.noDuration;this.playPauseButton.title=n,this.playPauseButton.setAttribute("aria-label",n),this.toolbar.classList.toggle("auto-hide",t),this.cornerButtons.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}restorePlayback(){const t=this.playbackBeforeClick;t&&(this.currentTime=t.time,t.state==="playing"?this.play():this.pause())}get canUseNativeFullscreen(){return typeof this.fullscreenTarget.requestFullscreen=="function"&&document.fullscreenEnabled}toggleFullscreen(){if(!this.canUseNativeFullscreen){this.simulatedFullscreen?this.exitSimulatedFullscreen():this.enterSimulatedFullscreen();return}document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}enterSimulatedFullscreen(){const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen=t.getAttribute("style")??"",this.bodyOverflowBeforeSimulatedFullscreen=document.body.style.overflow;const e=t.style;e.setProperty("position","fixed"),e.setProperty("inset","0"),e.setProperty("margin","0"),e.setProperty("max-width","none"),e.setProperty("max-height","none"),e.setProperty("aspect-ratio","auto"),e.setProperty("z-index","2147483647"),e.setProperty("background","#000"),e.setProperty("width","100vw"),e.setProperty("width","100dvw"),e.setProperty("height","100vh"),e.setProperty("height","100dvh"),document.body.style.overflow="hidden",this.simulatedFullscreen=!0,document.addEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}exitSimulatedFullscreen(){if(!this.simulatedFullscreen)return;const t=this.fullscreenTarget;this.styleBeforeSimulatedFullscreen?t.setAttribute("style",this.styleBeforeSimulatedFullscreen):t.removeAttribute("style"),document.body.style.overflow=this.bodyOverflowBeforeSimulatedFullscreen??"",this.simulatedFullscreen=!1,document.removeEventListener("keydown",this.handleSimulatedFullscreenKey),this.updateFullscreenButton()}toggleWitnessMap(){this.setWitnessMapOpen(this.witnessMapPanel.hidden)}applyWitnessMapDefault(){this.setWitnessMapOpen(this.hasAttribute(fr)&&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=da.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(Ln.WITNESS_MAP_MIN_SPAN_M,Ln.WITNESS_MAP_MARGIN);(!this.witnessMapBounds||!this.sameGround(this.witnessMapBounds,e))&&(this.witnessMapBounds=e,this.witnessMapImagery=void 0,this.witnessMapImageryCredit=void 0,this.witnessMapImageryFailed=!1,this.witnessMapImageryRequested=!1,this.witnessMapPanel.hidden||this.loadWitnessMapImagery())}sameGround(t,e){const n=Math.abs(t.east-t.west)/20;return Math.abs(t.north-e.north)<n&&Math.abs(t.south-e.south)<n&&Math.abs(t.west-e.west)<n&&Math.abs(t.east-e.east)<n}async loadWitnessMapImagery(){if(this.witnessMapImageryRequested||!this.witnessMapBounds)return;this.witnessMapImageryRequested=!0;const t=rp(),e=this.witnessMapBounds;try{const n=await t.getImageryTexture(e,{width:Ln.WITNESS_MAP_IMAGERY_PX,height:Ln.WITNESS_MAP_IMAGERY_PX});if(this.witnessMapBounds!==e)return;this.witnessMapImagery=n,this.witnessMapImageryCredit=t.attribution}catch{this.witnessMapImageryFailed=!0}this.paintWitnessMap(this.currentTime)}get witnessMapCredit(){return this.witnessMapImageryCredit}get witnessMapFooterLine(){return this.witnessMapImageryFailed?this.messages.mapImageryUnavailable:this.creditShownExternally?void 0:this.witnessMapImageryCredit}keepWitnessMapClear(t){if(this.witnessMapPanel.hidden)return;const e=this.witnessMapBoxPx;if(!e)return;const n=(o,c,l)=>{for(const h of t.values())if(!(h.transparency>=1)&&!(h.bounds.x+h.bounds.width<o-l||h.bounds.x>c+l)&&!(h.bounds.y>e.bottom+l||h.bounds.y+h.bounds.height<e.top-l))return!0;return!1},i=[this.canvas.width-e.width,this.canvas.width],r=[0,e.width],a=Ln.WITNESS_MAP_CLEARANCE_PX;if(this.witnessMapPanel.classList.contains("on-the-left")){n(i[0],i[1],a)||this.witnessMapPanel.classList.remove("on-the-left");return}n(i[0],i[1],0)&&!n(r[0],r[1],0)&&this.witnessMapPanel.classList.add("on-the-left")}witnessMapBoxPx;static WITNESS_MAP_CLEARANCE_PX=24;sizeWitnessMapCanvas(){const t=this.witnessMapPanel.clientWidth;if(t===0)return;const e=Math.round(t*(globalThis.devicePixelRatio??1));this.measureWitnessMapBox(),this.witnessMapCanvas.width!==e&&(this.witnessMapCanvas.width=e,this.witnessMapCanvas.height=e)}measureWitnessMapBox(){const t=this.witnessMapPanel.getBoundingClientRect(),e=this.canvas.getBoundingClientRect();if(e.width===0||e.height===0)return;const n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.witnessMapBoxPx={width:t.width*n,top:(t.top-e.top)*i,bottom:(t.bottom-e.top)*i}}paintWitnessMap(t){if(this.witnessMapPanel.hidden||!this.witnessPath||!this.witnessMapBounds)return;const e=tn(this.currentSighting,t),n=this.currentSighting.instrument,i=[],r=this.currentSighting.milestones.length>0?sd(this.currentSighting.milestones,t):void 0;for(const a of this.milestonesShown?Go(this.currentSighting.milestones):[]){const o=tn(this.currentSighting,a.t);o?.lat===void 0||o.lng===void 0||i.push({label:this.said.read(a.label)??"",note:this.said.read(a.note),t:a.t,lat:o.lat,lng:o.lng,current:a===r})}this.witnessMapRenderer.paint({bounds:this.witnessMapBounds,imagery:this.witnessMapImagery,path:this.witnessPath,position:e?.lat!==void 0&&e.lng!==void 0?{lat:e.lat,lng:e.lng}:void 0,headingDeg:e?.headingDeg===void 0?void 0:e.headingDeg+this.lookYawDeg,coneHalfAngleDeg:e?Ii.of(n,this.canvas.height,e.fovDeg).halfWidthAngleDeg(ze.aspectOf(n)):void 0,markers:i,decor:this.witnessMapDecorAt(t),witnessLabel:this.said.read(this.currentSighting.witness?.title)??this.messages.witnessHere,nightFraction:this.witnessMapNightFraction,attribution:this.witnessMapFooterLine})}toggleMilestones(){this.setMilestonesShown(!this.milestonesShown)}setMilestonesShown(t){this.milestonesShown=t,this.milestoneMarks.hidden=!t,this.milestonesButton.setAttribute("aria-pressed",String(t)),this.updateMilestonesButton(),this.showMilestoneAt(this.currentTime),this.paintWitnessMap(this.currentTime)}updateMilestonesButton(){this.milestonesButton.hidden=this.currentSighting.milestones.length===0;const t=this.milestonesShown?this.messages.hideMilestones:this.messages.showMilestones;this.milestonesButton.title=t,this.milestonesButton.setAttribute("aria-label",t)}witnessMapDecorAt(t){const e=tn(this.currentSighting,0);return e?.lat===void 0||e.lng===void 0?[]:this.currentSighting.decor.filter(n=>n.kind!=="crop").map(n=>{const i=nu(n,t),{lat:r,lng:a}=Pi(i.eastM,-i.northM,e.lat,e.lng);return{lat:r,lng:a,headingDeg:i.headingDeg,label:this.said.read(n.title)??this.messages.decorHere}})}witnessMapNightFraction;setSunAltitude(t){const e=t===void 0?void 0:Math.max(0,Math.min(1,-t/12));e!==this.witnessMapNightFraction&&(this.witnessMapNightFraction=e,this.paintWitnessMap(this.currentTime))}setLookOffset(t,e){t===this.lookYawDeg&&e===this.lookPitchDeg||(this.lookYawDeg=t,this.lookPitchDeg=e,this.refresh())}get frameShiftPx(){return this.frameShift}get frameShift(){const t=this.gaitAt(this.currentTime),e=this.lookYawDeg+t.yawDeg,n=this.lookPitchDeg+t.pitchDeg;if(e===0&&n===0)return{x:0,y:0};const i=tn(this.currentSighting,this.currentTime),r=Ii.of(this.currentSighting.instrument,this.canvas.height,i?.fovDeg??60);return{x:-r.angleDegToRadiusPx(e),y:r.angleDegToRadiusPx(n)}}gaitAt(t){return Fe.of(this.currentSighting)?.offsetAt(t)??Fe.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 ns(Vo.preferencesFor(this))}saidTexts;async loadLocaleMessages(){const t=eu(Vo.preferencesFor(this),Mg);t!=="en"&&this.applyMessages(await Sg(t))}updateTimeLabelTitles(){const t=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,e=this.canSwitchTimeDisplay?` — ${t}`:"";this.timeStartLabel.title=this.messages.currentPosition+e,this.timeEndLabel.title=this.messages.duration+e;for(const n of[this.timeStartLabel,this.timeEndLabel])n.classList.toggle("switchable",this.canSwitchTimeDisplay),this.canSwitchTimeDisplay?(n.setAttribute("role","button"),n.setAttribute("tabindex","0")):(n.removeAttribute("role"),n.removeAttribute("tabindex"))}applyMessages(t){this.messages=t,this.updateTimeLabelTitles(),this.loopButton.title=t.autoReplay,this.loopButton.setAttribute("aria-label",t.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.updateWitnessMapButton(),this.updateMilestonesButton()}updateTimeLabels(){const t=this.currentSighting.event,e=ng(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?Ll(t.time):void 0;const n=this.currentSighting.timeline.duration;this.player.playbackRate=this.realDurationMs!==void 0&&n>0?n/this.realDurationMs:1,this.player.durationOverrideMs=n>0?0:this.realDurationMs??0,this.timeEndLabel.textContent=this.formatEndOfTimeline(),this.timeStartLabel.textContent=this.formatPosition(this.player.time),this.updateTimeLabelTitles()}formatPosition(t){if(this.realDurationMs===void 0)return Oa(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?dd(ud(this.realStartMs+n)):Oa(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Oa(this.currentSighting.timeline.duration):this.canShowClockTime?dd(ud(this.realStartMs+this.realDurationMs)):Oa(this.realDurationMs)}}function ud(s){const t=new Date(s);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function dd(s){if(s.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return s.second?`${t(s.hour)}:${t(s.minute??0)}:${t(s.second)}`:`${t(s.hour)}:${t(s.minute??0)}`}function Oa(s){const t=Math.round(s/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const Fl="rr0-ufo";function ap(){customElements.get(Fl)||customElements.define(Fl,Ln)}/**
|
|
511
511
|
* @license
|
|
512
512
|
* Copyright 2010-2026 Three.js Authors
|
|
513
513
|
* SPDX-License-Identifier: MIT
|
|
514
|
-
*/const iu="185",Fg=0,fd=1,zg=2,ra=1,Bg=2,jr=3,cs=0,Be=1,qn=2,mi=0,mr=1,Zn=2,pd=3,md=4,kg=5,ys=100,Hg=101,Gg=102,Vg=103,Wg=104,Xg=200,qg=201,Yg=202,Kg=203,zl=204,Bl=205,$g=206,Zg=207,Jg=208,Qg=209,jg=210,t1=211,e1=212,n1=213,i1=214,kl=0,Hl=1,Gl=2,br=3,Vl=4,Wl=5,Xl=6,ql=7,su=0,s1=1,r1=2,gi=0,op=1,cp=2,lp=3,hp=4,up=5,dp=6,fp=7,gd="attached",a1="detached",pp=300,Ds=301,Er=302,Sc=303,bc=304,hc=306,Wo=1e3,dn=1001,Yl=1002,ke=1003,o1=1004,Ua=1005,ye=1006,Ec=1007,ws=1008,Dn=1009,mp=1010,gp=1011,ga=1012,ru=1013,Jn=1014,zn=1015,nn=1016,au=1017,ou=1018,va=1020,vp=35902,xp=35899,_p=1021,Mp=1022,fn=1023,Ui=1026,As=1027,cu=1028,lu=1029,Cs=1030,hu=1031,uu=1033,Lo=33776,No=33777,Oo=33778,Uo=33779,Kl=35840,$l=35841,Zl=35842,Jl=35843,Ql=36196,jl=37492,th=37496,eh=37488,nh=37489,Xo=37490,ih=37491,sh=37808,rh=37809,ah=37810,oh=37811,ch=37812,lh=37813,hh=37814,uh=37815,dh=37816,fh=37817,ph=37818,mh=37819,gh=37820,vh=37821,xh=36492,_h=36494,Mh=36495,yh=36283,Sh=36284,qo=36285,bh=36286,Yo=2300,Eh=2301,wc=2302,vd=2303,xd=2400,_d=2401,Md=2402,c1=2500,UE=0,FE=1,zE=2,l1=3200,Ko=0,h1=1,is="",Rn="srgb",$o="srgb-linear",Zo="linear",se="srgb",Bs=7680,yd=519,u1=512,d1=513,f1=514,du=515,p1=516,m1=517,fu=518,g1=519,wh=35044,Sd="300 es",fi=2e3,xa=2001;function v1(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function x1(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function _a(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function _1(){const s=_a("canvas");return s.style.display="block",s}const bd={};function Jo(...s){const t="THREE."+s.shift();console.log(t,...s)}function yp(s){const t=s[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=s[1];e&&e.isStackTrace?s[0]+=" "+e.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function wt(...s){s=yp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...s)}}function zt(...s){s=yp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...s)}}function gr(...s){const t=s.join(" ");t in bd||(bd[t]=!0,wt(...s))}function M1(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const y1={[kl]:Hl,[Gl]:Xl,[Vl]:ql,[br]:Wl,[Hl]:kl,[Xl]:Gl,[ql]:Vl,[Wl]:br};class Ns{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,t);t.target=null}}}const Je=["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 Ed=1234567;const aa=Math.PI/180,wr=180/Math.PI;function $n(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Je[s&255]+Je[s>>8&255]+Je[s>>16&255]+Je[s>>24&255]+"-"+Je[t&255]+Je[t>>8&255]+"-"+Je[t>>16&15|64]+Je[t>>24&255]+"-"+Je[e&63|128]+Je[e>>8&255]+"-"+Je[e>>16&255]+Je[e>>24&255]+Je[n&255]+Je[n>>8&255]+Je[n>>16&255]+Je[n>>24&255]).toLowerCase()}function Yt(s,t,e){return Math.max(t,Math.min(e,s))}function pu(s,t){return(s%t+t)%t}function S1(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function b1(s,t,e){return s!==t?(e-s)/(t-s):0}function oa(s,t,e){return(1-e)*s+e*t}function E1(s,t,e,n){return oa(s,t,1-Math.exp(-e*n))}function w1(s,t=1){return t-Math.abs(pu(s,t*2)-t)}function A1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function T1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function R1(s,t){return s+Math.floor(Math.random()*(t-s+1))}function D1(s,t){return s+Math.random()*(t-s)}function C1(s){return s*(.5-Math.random())}function P1(s){s!==void 0&&(Ed=s);let t=Ed+=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 I1(s){return s*aa}function L1(s){return s*wr}function N1(s){return(s&s-1)===0&&s!==0}function O1(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function U1(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function F1(s,t,e,n,i){const r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),g=a((n-t)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*g,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*g,o*l);break;case"ZYZ":s.set(c*g,c*f,o*h,o*l);break;default:wt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Yn(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function re(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const BE={DEG2RAD:aa,RAD2DEG:wr,generateUUID:$n,clamp:Yt,euclideanModulo:pu,mapLinear:S1,inverseLerp:b1,lerp:oa,damp:E1,pingpong:w1,smoothstep:A1,smootherstep:T1,randInt:R1,randFloat:D1,randFloatSpread:C1,seededRandom:P1,degToRad:I1,radToDeg:L1,isPowerOfTwo:N1,ceilPowerOfTwo:O1,floorPowerOfTwo:U1,setQuaternionFromProperEuler:F1,normalize:re,denormalize:Yn};class Pt{static{Pt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hs{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3],d=r[a+0],f=r[a+1],g=r[a+2],v=r[a+3];if(u!==v||c!==d||l!==f||h!==g){let p=c*d+l*f+h*g+u*v;p<0&&(d=-d,f=-f,g=-g,v=-v,p=-p);let m=1-o;if(p<.9995){const b=Math.acos(p),E=Math.sin(b);m=Math.sin(m*b)/E,o=Math.sin(o*b)/E,c=c*m+d*o,l=l*m+f*o,h=h*m+g*o,u=u*m+v*o}else{c=c*m+d*o,l=l*m+f*o,h=h*m+g*o,u=u*m+v*o;const b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return t[e]=o*g+h*u+c*f-l*d,t[e+1]=c*g+h*d+l*u-o*f,t[e+2]=l*g+h*f+o*d-c*u,t[e+3]=h*g-o*u-c*d-l*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),g=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"YZX":this._x=d*h*u+l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u-d*f*g;break;case"XZY":this._x=d*h*u-l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u+d*f*g;break;default:wt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Yt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{static{P.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(wd.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(wd.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ac.copy(this).projectOnVector(t),this.sub(Ac)}reflect(t){return this.sub(Ac.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ac=new P,wd=new hs;class Bt{static{Bt.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],v=i[0],p=i[3],m=i[6],b=i[1],E=i[4],M=i[7],S=i[2],w=i[5],R=i[8];return r[0]=a*v+o*b+c*S,r[3]=a*p+o*E+c*w,r[6]=a*m+o*M+c*R,r[1]=l*v+h*b+u*S,r[4]=l*p+h*E+u*w,r[7]=l*m+h*M+u*R,r[2]=d*v+f*b+g*S,r[5]=d*p+f*E+g*w,r[8]=d*m+f*M+g*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,g=e*u+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=u*v,t[1]=(i*l-h*n)*v,t[2]=(o*n-i*a)*v,t[3]=d*v,t[4]=(h*e-i*c)*v,t[5]=(i*r-o*e)*v,t[6]=f*v,t[7]=(n*c-l*e)*v,t[8]=(a*e-n*r)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return gr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Tc.makeScale(t,e)),this}rotate(t){return gr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Tc.makeRotation(-t)),this}translate(t,e){return gr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Tc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Tc=new Bt,Ad=new Bt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Td=new Bt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function z1(){const s={enabled:!0,workingColorSpace:$o,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===se&&(i.r=Ni(i.r),i.g=Ni(i.g),i.b=Ni(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===se&&(i.r=vr(i.r),i.g=vr(i.g),i.b=vr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===is?Zo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return gr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return gr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[$o]:{primaries:t,whitePoint:n,transfer:Zo,toXYZ:Ad,fromXYZ:Td,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Rn},outputColorSpaceConfig:{drawingBufferColorSpace:Rn}},[Rn]:{primaries:t,whitePoint:n,transfer:se,toXYZ:Ad,fromXYZ:Td,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Rn}}}),s}const Qt=z1();function Ni(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function vr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ks;class B1{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ks===void 0&&(ks=_a("canvas")),ks.width=t.width,ks.height=t.height;const i=ks.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=ks}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=_a("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Ni(r[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ni(e[n]/255)*255):e[n]=Ni(e[n]);return{data:e,width:t.width,height:t.height}}else return wt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let k1=0;class mu{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:k1++}),this.uuid=$n(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Rc(i[a].image)):r.push(Rc(i[a]))}else r=Rc(i);n.url=r}return e||(t.images[this.uuid]=n),n}}function Rc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?B1.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(wt("Texture: Unable to serialize Texture."),{})}let H1=0;const Dc=new P;class $e extends Ns{constructor(t=$e.DEFAULT_IMAGE,e=$e.DEFAULT_MAPPING,n=dn,i=dn,r=ye,a=ws,o=fn,c=Dn,l=$e.DEFAULT_ANISOTROPY,h=is){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:H1++}),this.uuid=$n(),this.name="",this.source=new mu(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Pt(0,0),this.repeat=new Pt(1,1),this.center=new Pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,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(Dc).x}get height(){return this.source.getSize(Dc).y}get depth(){return this.source.getSize(Dc).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){wt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==pp)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Wo:t.x=t.x-Math.floor(t.x);break;case dn:t.x=t.x<0?0:1;break;case Yl: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 Wo:t.y=t.y-Math.floor(t.y);break;case dn:t.y=t.y<0?0:1;break;case Yl: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++}}$e.DEFAULT_IMAGE=null;$e.DEFAULT_MAPPING=pp;$e.DEFAULT_ANISOTROPY=1;class le{static{le.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],g=c[9],v=c[2],p=c[6],m=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(g+p)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const E=(l+1)/2,M=(f+1)/2,S=(m+1)/2,w=(h+d)/4,R=(u+v)/4,_=(g+p)/4;return E>M&&E>S?E<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(E),i=w/n,r=R/n):M>S?M<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(M),n=w/i,r=_/i):S<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(S),n=R/r,i=_/r),this.set(n,i,r,e),this}let b=Math.sqrt((p-g)*(p-g)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(p-g)/b,this.y=(u-v)/b,this.z=(d-h)/b,this.w=Math.acos((l+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this.w=Yt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this.w=Yt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class G1 extends Ns{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ye,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new le(0,0,t,e),this.scissorTest=!1,this.viewport=new le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new $e(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:ye,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new mu(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Sn extends G1{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Sp extends $e{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ke,this.minFilter=ke,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class V1 extends $e{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ke,this.minFilter=ke,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Xt{static{Xt.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=g,m[11]=v,m[15]=p,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 Xt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Hs.setFromMatrixColumn(t,0).length(),r=1/Hs.setFromMatrixColumn(t,1).length(),a=1/Hs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+g*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=g+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,g=l*h,v=l*u;e[0]=d+v*o,e[4]=g*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-g,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,g=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,g=o*h,v=o*u;e[0]=c*h,e[4]=g*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,g=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=g*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+g,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,g=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-g,e[2]=g*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(W1,t,X1)}lookAt(t,e,n){const i=this.elements;return En.subVectors(t,e),En.lengthSq()===0&&(En.z=1),En.normalize(),qi.crossVectors(n,En),qi.lengthSq()===0&&(Math.abs(n.z)===1?En.x+=1e-4:En.z+=1e-4,En.normalize(),qi.crossVectors(n,En)),qi.normalize(),Fa.crossVectors(En,qi),i[0]=qi.x,i[4]=Fa.x,i[8]=En.x,i[1]=qi.y,i[5]=Fa.y,i[9]=En.y,i[2]=qi.z,i[6]=Fa.z,i[10]=En.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],v=n[6],p=n[10],m=n[14],b=n[3],E=n[7],M=n[11],S=n[15],w=i[0],R=i[4],_=i[8],A=i[12],C=i[1],D=i[5],I=i[9],V=i[13],q=i[2],O=i[6],W=i[10],G=i[14],Z=i[3],et=i[7],j=i[11],it=i[15];return r[0]=a*w+o*C+c*q+l*Z,r[4]=a*R+o*D+c*O+l*et,r[8]=a*_+o*I+c*W+l*j,r[12]=a*A+o*V+c*G+l*it,r[1]=h*w+u*C+d*q+f*Z,r[5]=h*R+u*D+d*O+f*et,r[9]=h*_+u*I+d*W+f*j,r[13]=h*A+u*V+d*G+f*it,r[2]=g*w+v*C+p*q+m*Z,r[6]=g*R+v*D+p*O+m*et,r[10]=g*_+v*I+p*W+m*j,r[14]=g*A+v*V+p*G+m*it,r[3]=b*w+E*C+M*q+S*Z,r[7]=b*R+E*D+M*O+S*et,r[11]=b*_+E*I+M*W+S*j,r[15]=b*A+E*V+M*G+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],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],v=t[7],p=t[11],m=t[15],b=c*f-l*d,E=o*f-l*u,M=o*d-c*u,S=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return e*(v*b-p*E+m*M)-n*(g*b-p*S+m*w)+i*(g*E-v*S+m*R)-r*(g*M-v*w+p*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],v=t[13],p=t[14],m=t[15],b=e*o-n*a,E=e*c-i*a,M=e*l-r*a,S=n*c-i*o,w=n*l-r*o,R=i*l-r*c,_=h*v-u*g,A=h*p-d*g,C=h*m-f*g,D=u*p-d*v,I=u*m-f*v,V=d*m-f*p,q=b*V-E*I+M*D+S*C-w*A+R*_;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/q;return t[0]=(o*V-c*I+l*D)*O,t[1]=(i*I-n*V-r*D)*O,t[2]=(v*R-p*w+m*S)*O,t[3]=(d*w-u*R-f*S)*O,t[4]=(c*C-a*V-l*A)*O,t[5]=(e*V-i*C+r*A)*O,t[6]=(p*M-g*R-m*E)*O,t[7]=(h*R-d*M+f*E)*O,t[8]=(a*I-o*C+l*_)*O,t[9]=(n*C-e*I-r*_)*O,t[10]=(g*w-v*M+m*b)*O,t[11]=(u*M-h*w-f*b)*O,t[12]=(o*A-a*D-c*_)*O,t[13]=(e*D-n*A+i*_)*O,t[14]=(v*E-g*S-p*b)*O,t[15]=(h*S-u*E+d*b)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,g=r*u,v=a*h,p=a*u,m=o*u,b=c*l,E=c*h,M=c*u,S=n.x,w=n.y,R=n.z;return i[0]=(1-(v+m))*S,i[1]=(f+M)*S,i[2]=(g-E)*S,i[3]=0,i[4]=(f-M)*w,i[5]=(1-(d+m))*w,i[6]=(p+b)*w,i[7]=0,i[8]=(g+E)*R,i[9]=(p-b)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=Hs.set(i[0],i[1],i[2]).length();const o=Hs.set(i[4],i[5],i[6]).length(),c=Hs.set(i[8],i[9],i[10]).length();r<0&&(a=-a),kn.copy(this);const l=1/a,h=1/o,u=1/c;return kn.elements[0]*=l,kn.elements[1]*=l,kn.elements[2]*=l,kn.elements[4]*=h,kn.elements[5]*=h,kn.elements[6]*=h,kn.elements[8]*=u,kn.elements[9]*=u,kn.elements[10]*=u,e.setFromRotationMatrix(kn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,i,r,a,o=fi,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let g,v;if(c)g=r/(a-r),v=a*r/(a-r);else if(o===fi)g=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===xa)g=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=fi,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let g,v;if(c)g=1/(a-r),v=a/(a-r);else if(o===fi)g=-2/(a-r),v=-(a+r)/(a-r);else if(o===xa)g=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=g,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Hs=new P,kn=new Xt,W1=new P(0,0,0),X1=new P(1,1,1),qi=new P,Fa=new P,En=new P,Rd=new Xt,Dd=new hs;class Fi{constructor(t=0,e=0,n=0,i=Fi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Yt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Yt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Yt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:wt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Rd.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Rd,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Dd.setFromEuler(this),this.setFromQuaternion(Dd,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}}Fi.DEFAULT_ORDER="XYZ";class gu{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 q1=0;const Cd=new P,Gs=new hs,Mi=new Xt,za=new P,Or=new P,Y1=new P,K1=new hs,Pd=new P(1,0,0),Id=new P(0,1,0),Ld=new P(0,0,1),Nd={type:"added"},$1={type:"removed"},Vs={type:"childadded",child:null},Cc={type:"childremoved",child:null};class _e extends Ns{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:q1++}),this.uuid=$n(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_e.DEFAULT_UP.clone();const t=new P,e=new Fi,n=new hs,i=new P(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xt},normalMatrix:{value:new Bt}}),this.matrix=new Xt,this.matrixWorld=new Xt,this.matrixAutoUpdate=_e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gu,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 Gs.setFromAxisAngle(t,e),this.quaternion.multiply(Gs),this}rotateOnWorldAxis(t,e){return Gs.setFromAxisAngle(t,e),this.quaternion.premultiply(Gs),this}rotateX(t){return this.rotateOnAxis(Pd,t)}rotateY(t){return this.rotateOnAxis(Id,t)}rotateZ(t){return this.rotateOnAxis(Ld,t)}translateOnAxis(t,e){return Cd.copy(t).applyQuaternion(this.quaternion),this.position.add(Cd.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Pd,t)}translateY(t){return this.translateOnAxis(Id,t)}translateZ(t){return this.translateOnAxis(Ld,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Mi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?za.copy(t):za.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mi.lookAt(Or,za,this.up):Mi.lookAt(za,Or,this.up),this.quaternion.setFromRotationMatrix(Mi),i&&(Mi.extractRotation(i.matrixWorld),Gs.setFromRotationMatrix(Mi),this.quaternion.premultiply(Gs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(zt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Nd),Vs.child=t,this.dispatchEvent(Vs),Vs.child=null):zt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent($1),Cc.child=t,this.dispatchEvent(Cc),Cc.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),Mi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Mi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Mi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Nd),Vs.child=t,this.dispatchEvent(Vs),Vs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Or,t,Y1),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Or,K1,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));i.material=o}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}_e.DEFAULT_UP=new P(0,1,0);_e.DEFAULT_MATRIX_AUTO_UPDATE=!0;_e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class en extends _e{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Z1={type:"move"};class Pc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new en,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 en,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new en,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const p=e.getJointPose(v,n),m=this._getHandJoint(l,v);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;l.inputState.pinching&&d>f+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Z1)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new en;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const bp={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},Yi={h:0,s:0,l:0},Ba={h:0,s:0,l:0};function Ic(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}class vt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Rn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Qt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Qt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Qt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Qt.workingColorSpace){if(t=pu(t,1),e=Yt(e,0,1),n=Yt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Ic(a,r,t+1/3),this.g=Ic(a,r,t),this.b=Ic(a,r,t-1/3)}return Qt.colorSpaceToWorking(this,i),this}setStyle(t,e=Rn){function n(r){r!==void 0&&parseFloat(r)<1&&wt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:wt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);wt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Rn){const n=bp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):wt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ni(t.r),this.g=Ni(t.g),this.b=Ni(t.b),this}copyLinearToSRGB(t){return this.r=vr(t.r),this.g=vr(t.g),this.b=vr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Rn){return Qt.workingToColorSpace(Qe.copy(this),t),Math.round(Yt(Qe.r*255,0,255))*65536+Math.round(Yt(Qe.g*255,0,255))*256+Math.round(Yt(Qe.b*255,0,255))}getHexString(t=Rn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Qt.workingColorSpace){Qt.workingToColorSpace(Qe.copy(this),e);const n=Qe.r,i=Qe.g,r=Qe.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Qt.workingColorSpace){return Qt.workingToColorSpace(Qe.copy(this),e),t.r=Qe.r,t.g=Qe.g,t.b=Qe.b,t}getStyle(t=Rn){Qt.workingToColorSpace(Qe.copy(this),t);const e=Qe.r,n=Qe.g,i=Qe.b;return t!==Rn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Yi),this.setHSL(Yi.h+t,Yi.s+e,Yi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Yi),t.getHSL(Ba);const n=oa(Yi.h,Ba.h,e),i=oa(Yi.s,Ba.s,e),r=oa(Yi.l,Ba.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Qe=new vt;vt.NAMES=bp;class vu{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new vt(t),this.near=e,this.far=n}clone(){return new vu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class uc extends _e{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 Fi,this.environmentIntensity=1,this.environmentRotation=new Fi,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 Hn=new P,yi=new P,Lc=new P,Si=new P,Ws=new P,Xs=new P,Od=new P,Nc=new P,Oc=new P,Uc=new P,Fc=new le,zc=new le,Bc=new le;class Fn{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Hn.subVectors(t,e),i.cross(Hn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Hn.subVectors(i,e),yi.subVectors(n,e),Lc.subVectors(t,e);const a=Hn.dot(Hn),o=Hn.dot(yi),c=Hn.dot(Lc),l=yi.dot(yi),h=yi.dot(Lc),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,g=(a*h-o*c)*d;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Si)===null?!1:Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,Si)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Si.x),c.addScaledVector(a,Si.y),c.addScaledVector(o,Si.z),c)}static getInterpolatedAttribute(t,e,n,i,r,a){return Fc.setScalar(0),zc.setScalar(0),Bc.setScalar(0),Fc.fromBufferAttribute(t,e),zc.fromBufferAttribute(t,n),Bc.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Fc,r.x),a.addScaledVector(zc,r.y),a.addScaledVector(Bc,r.z),a}static isFrontFacing(t,e,n,i){return Hn.subVectors(n,e),yi.subVectors(t,e),Hn.cross(yi).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Hn.subVectors(this.c,this.b),yi.subVectors(this.a,this.b),Hn.cross(yi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Fn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Fn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Fn.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Fn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Fn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;Ws.subVectors(i,n),Xs.subVectors(r,n),Nc.subVectors(t,n);const c=Ws.dot(Nc),l=Xs.dot(Nc);if(c<=0&&l<=0)return e.copy(n);Oc.subVectors(t,i);const h=Ws.dot(Oc),u=Xs.dot(Oc);if(h>=0&&u<=h)return e.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(Ws,a);Uc.subVectors(t,r);const f=Ws.dot(Uc),g=Xs.dot(Uc);if(g>=0&&f<=g)return e.copy(r);const v=f*l-c*g;if(v<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(Xs,o);const p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return Od.subVectors(r,i),o=(u-h)/(u-h+(f-g)),e.copy(i).addScaledVector(Od,o);const m=1/(p+v+d);return a=v*m,o=d*m,e.copy(n).addScaledVector(Ws,a).addScaledVector(Xs,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class xi{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Gn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Gn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Gn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Gn):Gn.fromBufferAttribute(r,a),Gn.applyMatrix4(t.matrixWorld),this.expandByPoint(Gn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ka.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ka.copy(n.boundingBox)),ka.applyMatrix4(t.matrixWorld),this.union(ka)}const i=t.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Gn),Gn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ur),Ha.subVectors(this.max,Ur),qs.subVectors(t.a,Ur),Ys.subVectors(t.b,Ur),Ks.subVectors(t.c,Ur),Ki.subVectors(Ys,qs),$i.subVectors(Ks,Ys),ds.subVectors(qs,Ks);let e=[0,-Ki.z,Ki.y,0,-$i.z,$i.y,0,-ds.z,ds.y,Ki.z,0,-Ki.x,$i.z,0,-$i.x,ds.z,0,-ds.x,-Ki.y,Ki.x,0,-$i.y,$i.x,0,-ds.y,ds.x,0];return!kc(e,qs,Ys,Ks,Ha)||(e=[1,0,0,0,1,0,0,0,1],!kc(e,qs,Ys,Ks,Ha))?!1:(Ga.crossVectors(Ki,$i),e=[Ga.x,Ga.y,Ga.z],kc(e,qs,Ys,Ks,Ha))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Gn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Gn).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:(bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(bi),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 bi=[new P,new P,new P,new P,new P,new P,new P,new P],Gn=new P,ka=new xi,qs=new P,Ys=new P,Ks=new P,Ki=new P,$i=new P,ds=new P,Ur=new P,Ha=new P,Ga=new P,fs=new P;function kc(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){fs.fromArray(s,r);const o=i.x*Math.abs(fs.x)+i.y*Math.abs(fs.y)+i.z*Math.abs(fs.z),c=t.dot(fs),l=e.dot(fs),h=n.dot(fs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Ci=J1();function J1(){const s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function Q1(s){Math.abs(s)>65504&&wt("DataUtils.toHalfFloat(): Value out of range."),s=Yt(s,-65504,65504),Ci.floatView[0]=s;const t=Ci.uint32View[0],e=t>>23&511;return Ci.baseTable[e]+((t&8388607)>>Ci.shiftTable[e])}function j1(s){const t=s>>10;return Ci.uint32View[0]=Ci.mantissaTable[Ci.offsetTable[t]+(s&1023)]+Ci.exponentTable[t],Ci.floatView[0]}class as{static toHalfFloat(t){return Q1(t)}static fromHalfFloat(t){return j1(t)}}const Oe=new P,Va=new Pt;let t2=0;class de extends Ns{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:t2++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=wh,this.updateRanges=[],this.gpuType=zn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Va.fromBufferAttribute(this,e),Va.applyMatrix3(t),this.setXY(e,Va.x,Va.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix3(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyMatrix4(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.applyNormalMatrix(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Oe.fromBufferAttribute(this,e),Oe.transformDirection(t),this.setXYZ(e,Oe.x,Oe.y,Oe.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Yn(e,this.array)),e}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Yn(e,this.array)),e}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Yn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Yn(e,this.array)),e}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==wh&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Ep extends de{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xu extends de{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Se extends de{constructor(t,e,n){super(new Float32Array(t),e,n)}}const e2=new xi,Fr=new P,Hc=new P;class zi{constructor(t=new P,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):e2.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;r<a;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Fr.subVectors(t,this.center);const e=Fr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Fr,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Hc.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Fr.copy(t.center).add(Hc)),this.expandByPoint(Fr.copy(t.center).sub(Hc))),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 n2=0;const In=new Xt,Gc=new _e,$s=new P,wn=new xi,zr=new xi,We=new P;class be extends Ns{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:n2++}),this.uuid=$n(),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(v1(t)?xu:Ep)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Bt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return In.makeRotationFromQuaternion(t),this.applyMatrix4(In),this}rotateX(t){return In.makeRotationX(t),this.applyMatrix4(In),this}rotateY(t){return In.makeRotationY(t),this.applyMatrix4(In),this}rotateZ(t){return In.makeRotationZ(t),this.applyMatrix4(In),this}translate(t,e,n){return In.makeTranslation(t,e,n),this.applyMatrix4(In),this}scale(t,e,n){return In.makeScale(t,e,n),this.applyMatrix4(In),this}lookAt(t){return Gc.lookAt(t),Gc.updateMatrix(),this.applyMatrix4(Gc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($s).negate(),this.translate($s.x,$s.y,$s.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,r=t.length;i<r;i++){const a=t[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Se(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&wt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const r=e[n];wn.setFromBufferAttribute(r),this.morphTargetsRelative?(We.addVectors(this.boundingBox.min,wn.min),this.boundingBox.expandByPoint(We),We.addVectors(this.boundingBox.max,wn.max),this.boundingBox.expandByPoint(We)):(this.boundingBox.expandByPoint(wn.min),this.boundingBox.expandByPoint(wn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(t){const n=this.boundingSphere.center;if(wn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];zr.setFromBufferAttribute(o),this.morphTargetsRelative?(We.addVectors(wn.min,zr.min),wn.expandByPoint(We),We.addVectors(wn.max,zr.max),wn.expandByPoint(We)):(wn.expandByPoint(zr.min),wn.expandByPoint(zr.max))}wn.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)We.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(We));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)We.fromBufferAttribute(o,l),c&&($s.fromBufferAttribute(t,l),We.add($s)),i=Math.max(i,n.distanceToSquared(We))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){zt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new de(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let _=0;_<n.count;_++)o[_]=new P,c[_]=new P;const l=new P,h=new P,u=new P,d=new Pt,f=new Pt,g=new Pt,v=new P,p=new P;function m(_,A,C){l.fromBufferAttribute(n,_),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,C),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,A),g.fromBufferAttribute(r,C),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),p.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[_].add(v),o[A].add(v),o[C].add(v),c[_].add(p),c[A].add(p),c[C].add(p))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let _=0,A=b.length;_<A;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)m(t.getX(V+0),t.getX(V+1),t.getX(V+2))}const E=new P,M=new P,S=new P,w=new P;function R(_){S.fromBufferAttribute(i,_),w.copy(S);const A=o[_];E.copy(A),E.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(w,A);const D=M.dot(c[_])<0?-1:1;a.setXYZW(_,E.x,E.y,E.z,D)}for(let _=0,A=b.length;_<A;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)R(t.getX(V+0)),R(t.getX(V+1)),R(t.getX(V+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new de(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new P,r=new P,a=new P,o=new P,c=new P,l=new P,h=new P,u=new P;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),v=t.getX(d+1),p=t.getX(d+2);i.fromBufferAttribute(e,g),r.fromBufferAttribute(e,v),a.fromBufferAttribute(e,p),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,p),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)We.fromBufferAttribute(t,e),We.normalize(),t.setXYZ(e,We.x,We.y,We.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,g=0;for(let v=0,p=c.length;v<p;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let m=0;m<h;m++)d[g++]=l[f++]}return new de(d,h,u)}if(this.index===null)return wt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new be,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,n);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class i2{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=wh,this.updateRanges=[],this.version=0,this.uuid=$n()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$n()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$n()),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 sn=new P;class Qo{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyMatrix4(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyNormalMatrix(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.transformDirection(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Yn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Yn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Yn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Yn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){Jo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new de(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Qo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Jo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let s2=0;class Bi extends Ns{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:s2++}),this.uuid=$n(),this.name="",this.type="Material",this.blending=mr,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=zl,this.blendDst=Bl,this.blendEquation=ys,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vt(0,0,0),this.blendAlpha=0,this.depthFunc=br,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Bs,this.stencilZFail=Bs,this.stencilZPass=Bs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){wt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==mr&&(n.blending=this.blending),this.side!==cs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zl&&(n.blendSrc=this.blendSrc),this.blendDst!==Bl&&(n.blendDst=this.blendDst),this.blendEquation!==ys&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==br&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Bs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Bs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Bs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Pt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Pt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class ta extends Bi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new vt(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 Zs;const Br=new P,Js=new P,Qs=new P,js=new Pt,kr=new Pt,wp=new Xt,Wa=new P,Hr=new P,Xa=new P,Ud=new Pt,Vc=new Pt,Fd=new Pt;class qa extends _e{constructor(t=new ta){if(super(),this.isSprite=!0,this.type="Sprite",Zs===void 0){Zs=new be;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new i2(e,5);Zs.setIndex([0,1,2,0,2,3]),Zs.setAttribute("position",new Qo(n,3,0,!1)),Zs.setAttribute("uv",new Qo(n,2,3,!1))}this.geometry=Zs,this.material=t,this.center=new Pt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&zt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Js.setFromMatrixScale(this.matrixWorld),wp.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Qs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Js.multiplyScalar(-Qs.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Ya(Wa.set(-.5,-.5,0),Qs,a,Js,i,r),Ya(Hr.set(.5,-.5,0),Qs,a,Js,i,r),Ya(Xa.set(.5,.5,0),Qs,a,Js,i,r),Ud.set(0,0),Vc.set(1,0),Fd.set(1,1);let o=t.ray.intersectTriangle(Wa,Hr,Xa,!1,Br);if(o===null&&(Ya(Hr.set(-.5,.5,0),Qs,a,Js,i,r),Vc.set(0,1),o=t.ray.intersectTriangle(Wa,Xa,Hr,!1,Br),o===null))return;const c=t.ray.origin.distanceTo(Br);c<t.near||c>t.far||e.push({distance:c,point:Br.clone(),uv:Fn.getInterpolation(Br,Wa,Hr,Xa,Ud,Vc,Fd,new Pt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Ya(s,t,e,n,i,r){js.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(kr.x=r*js.x-i*js.y,kr.y=i*js.x+r*js.y):kr.copy(js),s.copy(t),s.x+=kr.x,s.y+=kr.y,s.applyMatrix4(wp)}const Ei=new P,Wc=new P,Ka=new P,Zi=new P,Xc=new P,$a=new P,qc=new P;class ya{constructor(t=new P,e=new P(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,Ei)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ei.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ei.copy(this.origin).addScaledVector(this.direction,e),Ei.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Wc.copy(t).add(e).multiplyScalar(.5),Ka.copy(e).sub(t).normalize(),Zi.copy(this.origin).sub(Wc);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Ka),o=Zi.dot(this.direction),c=-Zi.dot(Ka),l=Zi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*c-o,d=a*o-c,g=r*h,u>=0)if(d>=-g)if(d<=g){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Wc).addScaledVector(Ka,d),f}intersectSphere(t,e){Ei.subVectors(t.center,this.origin);const n=Ei.dot(this.direction),i=Ei.dot(Ei)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ei)!==null}intersectTriangle(t,e,n,i,r){Xc.subVectors(e,t),$a.subVectors(n,t),qc.crossVectors(Xc,$a);let a=this.direction.dot(qc),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zi.subVectors(this.origin,t);const c=o*this.direction.dot($a.crossVectors(Zi,$a));if(c<0)return null;const l=o*this.direction.dot(Xc.cross(Zi));if(l<0||c+l>a)return null;const h=-o*Zi.dot(qc);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Oi extends Bi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vt(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 Fi,this.combine=su,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 zd=new Xt,ps=new ya,Za=new zi,Bd=new P,Ja=new P,Qa=new P,ja=new P,Yc=new P,to=new P,kd=new P,eo=new P;class $t extends _e{constructor(t=new be,e=new Oi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){to.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Yc.fromBufferAttribute(u,t),a?to.addScaledVector(Yc,h):to.addScaledVector(Yc.sub(e),h))}e.add(to)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Za.copy(n.boundingSphere),Za.applyMatrix4(r),ps.copy(t.ray).recast(t.near),!(Za.containsPoint(ps.origin)===!1&&(ps.intersectSphere(Za,Bd)===null||ps.origin.distanceToSquared(Bd)>(t.far-t.near)**2))&&(zd.copy(r).invert(),ps.copy(t.ray).applyMatrix4(zd),!(n.boundingBox!==null&&ps.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ps)))}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const p=d[g],m=a[p.materialIndex],b=Math.max(p.start,f.start),E=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let M=b,S=E;M<S;M+=3){const w=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);i=no(this,m,t,n,l,h,u,w,R,_),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=p.materialIndex,e.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const b=o.getX(p),E=o.getX(p+1),M=o.getX(p+2);i=no(this,a,t,n,l,h,u,b,E,M),i&&(i.faceIndex=Math.floor(p/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const p=d[g],m=a[p.materialIndex],b=Math.max(p.start,f.start),E=Math.min(c.count,Math.min(p.start+p.count,f.start+f.count));for(let M=b,S=E;M<S;M+=3){const w=M,R=M+1,_=M+2;i=no(this,m,t,n,l,h,u,w,R,_),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=p.materialIndex,e.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const b=p,E=p+1,M=p+2;i=no(this,a,t,n,l,h,u,b,E,M),i&&(i.faceIndex=Math.floor(p/3),e.push(i))}}}}function r2(s,t,e,n,i,r,a,o){let c;if(t.side===Be?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,t.side===cs,o),c===null)return null;eo.copy(o),eo.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(eo);return l<e.near||l>e.far?null:{distance:l,point:eo.clone(),object:s}}function no(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,Ja),s.getVertexPosition(c,Qa),s.getVertexPosition(l,ja);const h=r2(s,t,e,n,Ja,Qa,ja,kd);if(h){const u=new P;Fn.getBarycoord(kd,Ja,Qa,ja,u),i&&(h.uv=Fn.getInterpolatedAttribute(i,o,c,l,u,new Pt)),r&&(h.uv1=Fn.getInterpolatedAttribute(r,o,c,l,u,new Pt)),a&&(h.normal=Fn.getInterpolatedAttribute(a,o,c,l,u,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new P,materialIndex:0};Fn.getNormal(Ja,Qa,ja,d.normal),h.face=d,h.barycoord=u}return h}const Gr=new le,Hd=new le,Gd=new le,a2=new le,Vd=new Xt,io=new P,Kc=new zi,Wd=new Xt,$c=new ya;class kE extends $t{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gd,this.bindMatrix=new Xt,this.bindMatrixInverse=new Xt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new xi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,io),this.boundingBox.expandByPoint(io)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new zi),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,io),this.boundingSphere.expandByPoint(io)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Kc.copy(this.boundingSphere),Kc.applyMatrix4(i),t.ray.intersectsSphere(Kc)!==!1&&(Wd.copy(i).invert(),$c.copy(t.ray).applyMatrix4(Wd),!(this.boundingBox!==null&&$c.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,$c)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===gd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===a1?this.bindMatrixInverse.copy(this.bindMatrix).invert():wt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Hd.fromBufferAttribute(i.attributes.skinIndex,t),Gd.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(Gr.copy(e),e.set(0,0,0,0)):(Gr.set(...e,1),e.set(0,0,0)),Gr.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=Gd.getComponent(r);if(a!==0){const o=Hd.getComponent(r);Vd.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(a2.copy(Gr).applyMatrix4(Vd),a)}}return e.isVector4&&(e.w=Gr.w),e.applyMatrix4(this.bindMatrixInverse)}}class o2 extends _e{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Dr extends $e{constructor(t=null,e=1,n=1,i,r,a,o,c,l=ke,h=ke,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xd=new Xt,c2=new Xt;class Ap{constructor(t=[],e=[]){this.uuid=$n(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){wt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Xt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=t.length;r<a;r++){const o=t[r]?t[r].matrixWorld:c2;Xd.multiplyMatrices(o,e[r]),Xd.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Ap(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Dr(e,t,t,fn,zn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const r=t.bones[n];let a=e[r];a===void 0&&(wt("Skeleton: No bone found with UUID:",r),a=new o2),this.bones.push(a),this.boneInverses.push(new Xt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const a=e[i];t.bones.push(a.uuid);const o=n[i];t.boneInverses.push(o.toArray())}return t}}class qd extends de{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const tr=new Xt,Yd=new Xt,so=[],Kd=new xi,l2=new Xt,Vr=new $t,Wr=new zi;class HE extends $t{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new qd(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,l2)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new xi),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,tr),Kd.copy(t.boundingBox).applyMatrix4(tr),this.boundingBox.union(Kd)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new zi),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,tr),Wr.copy(t.boundingSphere).applyMatrix4(tr),this.boundingSphere.union(Wr)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=t*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Vr.geometry=this.geometry,Vr.material=this.material,Vr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Wr.copy(this.boundingSphere),Wr.applyMatrix4(n),t.ray.intersectsSphere(Wr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,tr),Yd.multiplyMatrices(n,tr),Vr.matrixWorld=Yd,Vr.raycast(t,so);for(let a=0,o=so.length;a<o;a++){const c=so[a];c.instanceId=r,c.object=this,e.push(c)}so.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new qd(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Dr(new Float32Array(i*this.count),i,this.count,cu,zn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*t;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Zc=new P,h2=new P,u2=new Bt;class _s{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Zc.subVectors(n,e).cross(h2.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(Zc),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||u2.getNormalMatrix(t),i=this.coplanarPoint(Zc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ms=new zi,d2=new Pt(.5,.5),ro=new P;class _u{constructor(t=new _s,e=new _s,n=new _s,i=new _s,r=new _s,a=new _s){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=fi,n=!1){const i=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],g=r[8],v=r[9],p=r[10],m=r[11],b=r[12],E=r[13],M=r[14],S=r[15];if(i[0].setComponents(l-a,f-h,m-g,S-b).normalize(),i[1].setComponents(l+a,f+h,m+g,S+b).normalize(),i[2].setComponents(l+o,f+u,m+v,S+E).normalize(),i[3].setComponents(l-o,f-u,m-v,S-E).normalize(),n)i[4].setComponents(c,d,p,M).normalize(),i[5].setComponents(l-c,f-d,m-p,S-M).normalize();else if(i[4].setComponents(l-c,f-d,m-p,S-M).normalize(),e===fi)i[5].setComponents(l+c,f+d,m+p,S+M).normalize();else if(e===xa)i[5].setComponents(c,d,p,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(),ms.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ms.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ms)}intersectsSprite(t){ms.center.set(0,0,0);const e=d2.distanceTo(t.center);return ms.radius=.7071067811865476+e,ms.applyMatrix4(t.matrixWorld),this.intersectsSphere(ms)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(ro.x=i.normal.x>0?t.max.x:t.min.x,ro.y=i.normal.y>0?t.max.y:t.min.y,ro.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ro)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class f2 extends Bi{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new vt(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 jo=new P,tc=new P,$d=new Xt,Xr=new ya,ao=new zi,Jc=new P,Zd=new P;class Tp extends _e{constructor(t=new be,e=new f2){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)jo.fromBufferAttribute(e,i-1),tc.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=jo.distanceTo(tc);t.setAttribute("lineDistance",new Se(n,1))}else wt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ao.copy(n.boundingSphere),ao.applyMatrix4(i),ao.radius+=r,t.ray.intersectsSphere(ao)===!1)return;$d.copy(i).invert(),Xr.copy(t.ray).applyMatrix4($d);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let v=f,p=g-1;v<p;v+=l){const m=h.getX(v),b=h.getX(v+1),E=oo(this,t,Xr,c,m,b,v);E&&e.push(E)}if(this.isLineLoop){const v=h.getX(g-1),p=h.getX(f),m=oo(this,t,Xr,c,v,p,g-1);m&&e.push(m)}}else{const f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let v=f,p=g-1;v<p;v+=l){const m=oo(this,t,Xr,c,v,v+1,v);m&&e.push(m)}if(this.isLineLoop){const v=oo(this,t,Xr,c,g-1,f,g-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function oo(s,t,e,n,i,r,a){const o=s.geometry.attributes.position;if(jo.fromBufferAttribute(o,i),tc.fromBufferAttribute(o,r),e.distanceSqToSegment(jo,tc,Jc,Zd)>n)return;Jc.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Jc);if(!(l<t.near||l>t.far))return{distance:l,point:Zd.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Jd=new P,Qd=new P;class GE extends Tp{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)Jd.fromBufferAttribute(e,i),Qd.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jd.distanceTo(Qd);t.setAttribute("lineDistance",new Se(n,1))}else wt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class VE extends Tp{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Rp extends Bi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new vt(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 jd=new Xt,Ah=new ya,co=new zi,lo=new P;class Fo extends _e{constructor(t=new be,e=new Rp){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),co.copy(n.boundingSphere),co.applyMatrix4(i),co.radius+=r,t.ray.intersectsSphere(co)===!1)return;jd.copy(i).invert(),Ah.copy(t.ray).applyMatrix4(jd);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let g=d,v=f;g<v;g++){const p=l.getX(g);lo.fromBufferAttribute(u,p),t0(lo,p,c,i,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,v=f;g<v;g++)lo.fromBufferAttribute(u,g),t0(lo,g,c,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function t0(s,t,e,n,i,r,a){const o=Ah.distanceSqToPoint(s);if(o<e){const c=new P;Ah.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Dp extends $e{constructor(t=[],e=Ds,n,i,r,a,o,c,l,h){super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class _i extends $e{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ps extends $e{constructor(t,e,n=Jn,i,r,a,o=ke,c=ke,l,h=Ui,u=1){if(h!==Ui&&h!==As)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new mu(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 p2 extends Ps{constructor(t,e=Jn,n=Ds,i,r,a=ke,o=ke,c,l=Ui){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Cp extends $e{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Bn extends be{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,i,a,2),g("x","z","y",1,-1,t,n,-e,i,a,3),g("x","y","z",1,-1,t,e,n,i,r,4),g("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Se(l,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function g(v,p,m,b,E,M,S,w,R,_,A){const C=M/R,D=S/_,I=M/2,V=S/2,q=w/2,O=R+1,W=_+1;let G=0,Z=0;const et=new P;for(let j=0;j<W;j++){const it=j*D-V;for(let ut=0;ut<O;ut++){const Ht=ut*C-I;et[v]=Ht*b,et[p]=it*E,et[m]=q,l.push(et.x,et.y,et.z),et[v]=0,et[p]=0,et[m]=w>0?1:-1,h.push(et.x,et.y,et.z),u.push(ut/R),u.push(1-j/_),G+=1}}for(let j=0;j<_;j++)for(let it=0;it<R;it++){const ut=d+it+O*j,Ht=d+it+O*(j+1),Jt=d+(it+1)+O*(j+1),kt=d+(it+1)+O*j;c.push(ut,Ht,kt),c.push(Ht,Jt,kt),Z+=6}o.addGroup(f,Z,A),f+=Z,d+=G}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Mu extends be{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new P,h=new Pt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(o,3)),this.setAttribute("uv",new Se(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mu(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class ki extends be{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const v=[],p=n/2;let m=0;b(),a===!1&&(t>0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function b(){const M=new P,S=new P;let w=0;const R=(e-t)/n;for(let _=0;_<=r;_++){const A=[],C=_/r,D=C*(e-t)+t;for(let I=0;I<=i;I++){const V=I/i,q=V*c+o,O=Math.sin(q),W=Math.cos(q);S.x=D*O,S.y=-C*n+p,S.z=D*W,u.push(S.x,S.y,S.z),M.set(O,R,W).normalize(),d.push(M.x,M.y,M.z),f.push(V,1-C),A.push(g++)}v.push(A)}for(let _=0;_<i;_++)for(let A=0;A<r;A++){const C=v[A][_],D=v[A+1][_],I=v[A+1][_+1],V=v[A][_+1];(t>0||A!==0)&&(h.push(C,D,V),w+=3),(e>0||A!==r-1)&&(h.push(D,I,V),w+=3)}l.addGroup(m,w,0),m+=w}function E(M){const S=g,w=new Pt,R=new P;let _=0;const A=M===!0?t:e,C=M===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,p*C,0),d.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let I=0;I<=i;I++){const q=I/i*c+o,O=Math.cos(q),W=Math.sin(q);R.x=A*W,R.y=p*C,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,C,0),w.x=O*.5+.5,w.y=W*.5*C+.5,f.push(w.x,w.y),g++}for(let I=0;I<i;I++){const V=S+I,q=D+I;M===!0?h.push(q,q+1,V):h.push(q+1,q,V),_+=3}l.addGroup(m,_,M===!0?1:2),m+=_}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ki(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Sa extends ki{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Sa(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Hi extends be{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=t/o,d=e/c,f=[],g=[],v=[],p=[];for(let m=0;m<h;m++){const b=m*d-a;for(let E=0;E<l;E++){const M=E*u-r;g.push(M,-b,0),v.push(0,0,1),p.push(E/o),p.push(1-m/c)}}for(let m=0;m<c;m++)for(let b=0;b<o;b++){const E=b+l*m,M=b+l*(m+1),S=b+1+l*(m+1),w=b+1+l*m;f.push(E,M,w),f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new Se(g,3)),this.setAttribute("normal",new Se(v,3)),this.setAttribute("uv",new Se(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hi(t.width,t.height,t.widthSegments,t.heightSegments)}}class pn extends be{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new P,d=new P,f=[],g=[],v=[],p=[];for(let m=0;m<=n;m++){const b=[],E=m/n,M=a+E*o,S=t*Math.cos(M),w=Math.sqrt(t*t-S*S);let R=0;m===0&&a===0?R=.5/e:m===n&&c===Math.PI&&(R=-.5/e);for(let _=0;_<=e;_++){const A=_/e,C=i+A*r;u.x=-w*Math.cos(C),u.y=S,u.z=w*Math.sin(C),g.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),p.push(A+R,1-E),b.push(l++)}h.push(b)}for(let m=0;m<n;m++)for(let b=0;b<e;b++){const E=h[m][b+1],M=h[m][b],S=h[m+1][b],w=h[m+1][b+1];(m!==0||a>0)&&f.push(E,M,w),(m!==n-1||c<Math.PI)&&f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new Se(g,3)),this.setAttribute("normal",new Se(v,3)),this.setAttribute("uv",new Se(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Ar(s){const t={};for(const e in s){t[e]={};for(const n in s[e]){const i=s[e][n];if(e0(i))i.isRenderTargetTexture?(wt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(e0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();t[e][n]=r}else t[e][n]=i.slice();else t[e][n]=i}}return t}function rn(s){const t={};for(let e=0;e<s.length;e++){const n=Ar(s[e]);for(const i in n)t[i]=n[i]}return t}function e0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function m2(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function Pp(s){const t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Qt.workingColorSpace}const g2={clone:Ar,merge:rn};var v2=`void main() {
|
|
514
|
+
*/const iu="185",Bg=0,fd=1,kg=2,ra=1,Hg=2,jr=3,cs=0,Be=1,qn=2,mi=0,mr=1,Zn=2,pd=3,md=4,Gg=5,ys=100,Vg=101,Wg=102,Xg=103,qg=104,Yg=200,Kg=201,$g=202,Zg=203,zl=204,Bl=205,Jg=206,Qg=207,jg=208,t1=209,e1=210,n1=211,i1=212,s1=213,r1=214,kl=0,Hl=1,Gl=2,br=3,Vl=4,Wl=5,Xl=6,ql=7,su=0,a1=1,o1=2,gi=0,op=1,cp=2,lp=3,hp=4,up=5,dp=6,fp=7,gd="attached",c1="detached",pp=300,Ds=301,Er=302,Sc=303,bc=304,hc=306,Wo=1e3,dn=1001,Yl=1002,ke=1003,l1=1004,Ua=1005,ye=1006,Ec=1007,ws=1008,Dn=1009,mp=1010,gp=1011,ga=1012,ru=1013,Jn=1014,zn=1015,nn=1016,au=1017,ou=1018,va=1020,vp=35902,xp=35899,_p=1021,Mp=1022,fn=1023,Ui=1026,As=1027,cu=1028,lu=1029,Cs=1030,hu=1031,uu=1033,Lo=33776,No=33777,Oo=33778,Uo=33779,Kl=35840,$l=35841,Zl=35842,Jl=35843,Ql=36196,jl=37492,th=37496,eh=37488,nh=37489,Xo=37490,ih=37491,sh=37808,rh=37809,ah=37810,oh=37811,ch=37812,lh=37813,hh=37814,uh=37815,dh=37816,fh=37817,ph=37818,mh=37819,gh=37820,vh=37821,xh=36492,_h=36494,Mh=36495,yh=36283,Sh=36284,qo=36285,bh=36286,Yo=2300,Eh=2301,wc=2302,vd=2303,xd=2400,_d=2401,Md=2402,h1=2500,kE=0,HE=1,GE=2,u1=3200,Ko=0,d1=1,is="",Rn="srgb",$o="srgb-linear",Zo="linear",se="srgb",Bs=7680,yd=519,f1=512,p1=513,m1=514,du=515,g1=516,v1=517,fu=518,x1=519,wh=35044,Sd="300 es",fi=2e3,xa=2001;function _1(s){for(let t=s.length-1;t>=0;--t)if(s[t]>=65535)return!0;return!1}function M1(s){return ArrayBuffer.isView(s)&&!(s instanceof DataView)}function _a(s){return document.createElementNS("http://www.w3.org/1999/xhtml",s)}function y1(){const s=_a("canvas");return s.style.display="block",s}const bd={};function Jo(...s){const t="THREE."+s.shift();console.log(t,...s)}function yp(s){const t=s[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=s[1];e&&e.isStackTrace?s[0]+=" "+e.getLocation():s[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return s}function wt(...s){s=yp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...s)}}function zt(...s){s=yp(s);const t="THREE."+s.shift();{const e=s[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...s)}}function gr(...s){const t=s.join(" ");t in bd||(bd[t]=!0,wt(...s))}function S1(s,t,e){return new Promise(function(n,i){function r(){switch(s.clientWaitSync(t,s.SYNC_FLUSH_COMMANDS_BIT,0)){case s.WAIT_FAILED:i();break;case s.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const b1={[kl]:Hl,[Gl]:Xl,[Vl]:ql,[br]:Wl,[Hl]:kl,[Xl]:Gl,[ql]:Vl,[Wl]:br};class Ns{addEventListener(t,e){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[t]===void 0&&(n[t]=[]),n[t].indexOf(e)===-1&&n[t].push(e)}hasEventListener(t,e){const n=this._listeners;return n===void 0?!1:n[t]!==void 0&&n[t].indexOf(e)!==-1}removeEventListener(t,e){const n=this._listeners;if(n===void 0)return;const i=n[t];if(i!==void 0){const r=i.indexOf(e);r!==-1&&i.splice(r,1)}}dispatchEvent(t){const e=this._listeners;if(e===void 0)return;const n=e[t.type];if(n!==void 0){t.target=this;const i=n.slice(0);for(let r=0,a=i.length;r<a;r++)i[r].call(this,t);t.target=null}}}const Je=["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 Ed=1234567;const aa=Math.PI/180,wr=180/Math.PI;function $n(){const s=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(Je[s&255]+Je[s>>8&255]+Je[s>>16&255]+Je[s>>24&255]+"-"+Je[t&255]+Je[t>>8&255]+"-"+Je[t>>16&15|64]+Je[t>>24&255]+"-"+Je[e&63|128]+Je[e>>8&255]+"-"+Je[e>>16&255]+Je[e>>24&255]+Je[n&255]+Je[n>>8&255]+Je[n>>16&255]+Je[n>>24&255]).toLowerCase()}function Yt(s,t,e){return Math.max(t,Math.min(e,s))}function pu(s,t){return(s%t+t)%t}function E1(s,t,e,n,i){return n+(s-t)*(i-n)/(e-t)}function w1(s,t,e){return s!==t?(e-s)/(t-s):0}function oa(s,t,e){return(1-e)*s+e*t}function A1(s,t,e,n){return oa(s,t,1-Math.exp(-e*n))}function T1(s,t=1){return t-Math.abs(pu(s,t*2)-t)}function R1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*(3-2*s))}function D1(s,t,e){return s<=t?0:s>=e?1:(s=(s-t)/(e-t),s*s*s*(s*(s*6-15)+10))}function C1(s,t){return s+Math.floor(Math.random()*(t-s+1))}function P1(s,t){return s+Math.random()*(t-s)}function I1(s){return s*(.5-Math.random())}function L1(s){s!==void 0&&(Ed=s);let t=Ed+=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 N1(s){return s*aa}function O1(s){return s*wr}function U1(s){return(s&s-1)===0&&s!==0}function F1(s){return Math.pow(2,Math.ceil(Math.log(s)/Math.LN2))}function z1(s){return Math.pow(2,Math.floor(Math.log(s)/Math.LN2))}function B1(s,t,e,n,i){const r=Math.cos,a=Math.sin,o=r(e/2),c=a(e/2),l=r((t+n)/2),h=a((t+n)/2),u=r((t-n)/2),d=a((t-n)/2),f=r((n-t)/2),g=a((n-t)/2);switch(i){case"XYX":s.set(o*h,c*u,c*d,o*l);break;case"YZY":s.set(c*d,o*h,c*u,o*l);break;case"ZXZ":s.set(c*u,c*d,o*h,o*l);break;case"XZX":s.set(o*h,c*g,c*f,o*l);break;case"YXY":s.set(c*f,o*h,c*g,o*l);break;case"ZYZ":s.set(c*g,c*f,o*h,o*l);break;default:wt("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+i)}}function Yn(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return s/4294967295;case Uint16Array:return s/65535;case Uint8Array:return s/255;case Int32Array:return Math.max(s/2147483647,-1);case Int16Array:return Math.max(s/32767,-1);case Int8Array:return Math.max(s/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function re(s,t){switch(t.constructor){case Float32Array:return s;case Uint32Array:return Math.round(s*4294967295);case Uint16Array:return Math.round(s*65535);case Uint8Array:return Math.round(s*255);case Int32Array:return Math.round(s*2147483647);case Int16Array:return Math.round(s*32767);case Int8Array:return Math.round(s*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const VE={DEG2RAD:aa,RAD2DEG:wr,generateUUID:$n,clamp:Yt,euclideanModulo:pu,mapLinear:E1,inverseLerp:w1,lerp:oa,damp:A1,pingpong:T1,smoothstep:R1,smootherstep:D1,randInt:C1,randFloat:P1,randFloatSpread:I1,seededRandom:L1,degToRad:N1,radToDeg:O1,isPowerOfTwo:U1,ceilPowerOfTwo:F1,floorPowerOfTwo:z1,setQuaternionFromProperEuler:B1,normalize:re,denormalize:Yn};class Pt{static{Pt.prototype.isVector2=!0}constructor(t=0,e=0){this.x=t,this.y=e}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,e){return this.x=t,this.y=e,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const e=this.x,n=this.y,i=t.elements;return this.x=i[0]*e+i[3]*n+i[6],this.y=i[1]*e+i[4]*n+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y;return e*e+n*n}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this}rotateAround(t,e){const n=Math.cos(e),i=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*i+t.x,this.y=r*i+a*n+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class hs{constructor(t=0,e=0,n=0,i=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=i}static slerpFlat(t,e,n,i,r,a,o){let c=n[i+0],l=n[i+1],h=n[i+2],u=n[i+3],d=r[a+0],f=r[a+1],g=r[a+2],v=r[a+3];if(u!==v||c!==d||l!==f||h!==g){let p=c*d+l*f+h*g+u*v;p<0&&(d=-d,f=-f,g=-g,v=-v,p=-p);let m=1-o;if(p<.9995){const b=Math.acos(p),E=Math.sin(b);m=Math.sin(m*b)/E,o=Math.sin(o*b)/E,c=c*m+d*o,l=l*m+f*o,h=h*m+g*o,u=u*m+v*o}else{c=c*m+d*o,l=l*m+f*o,h=h*m+g*o,u=u*m+v*o;const b=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=b,l*=b,h*=b,u*=b}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,i,r,a){const o=n[i],c=n[i+1],l=n[i+2],h=n[i+3],u=r[a],d=r[a+1],f=r[a+2],g=r[a+3];return t[e]=o*g+h*u+c*f-l*d,t[e+1]=c*g+h*d+l*u-o*f,t[e+2]=l*g+h*f+o*d-c*u,t[e+3]=h*g-o*u-c*d-l*f,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,e,n,i){return this._x=t,this._y=e,this._z=n,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,e=!0){const n=t._x,i=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(i/2),u=o(r/2),d=c(n/2),f=c(i/2),g=c(r/2);switch(a){case"XYZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"YXZ":this._x=d*h*u+l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"ZXY":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u-d*f*g;break;case"ZYX":this._x=d*h*u-l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u+d*f*g;break;case"YZX":this._x=d*h*u+l*f*g,this._y=l*f*u+d*h*g,this._z=l*h*g-d*f*u,this._w=l*h*u-d*f*g;break;case"XZY":this._x=d*h*u-l*f*g,this._y=l*f*u-d*h*g,this._z=l*h*g+d*f*u,this._w=l*h*u+d*f*g;break;default:wt("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,i=Math.sin(n);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],i=e[4],r=e[8],a=e[1],o=e[5],c=e[9],l=e[2],h=e[6],u=e[10],d=n+o+u;if(d>0){const f=.5/Math.sqrt(d+1);this._w=.25/f,this._x=(h-c)*f,this._y=(r-l)*f,this._z=(a-i)*f}else if(n>o&&n>u){const f=2*Math.sqrt(1+n-o-u);this._w=(h-c)/f,this._x=.25*f,this._y=(i+a)/f,this._z=(r+l)/f}else if(o>u){const f=2*Math.sqrt(1+o-n-u);this._w=(r-l)/f,this._x=(i+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-i)/f,this._x=(r+l)/f,this._y=(c+h)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(t,e){let n=t.dot(e)+1;return n<1e-8?(n=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=n):(this._x=0,this._y=-t.z,this._z=t.y,this._w=n)):(this._x=t.y*e.z-t.z*e.y,this._y=t.z*e.x-t.x*e.z,this._z=t.x*e.y-t.y*e.x,this._w=n),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(Yt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const i=Math.min(1,e/n);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return t===0?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,e){const n=t._x,i=t._y,r=t._z,a=t._w,o=e._x,c=e._y,l=e._z,h=e._w;return this._x=n*h+a*o+i*l-r*c,this._y=i*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-i*o,this._w=a*h-n*o-i*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,i=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,i=-i,r=-r,a=-a,o=-o);let c=1-e;if(o<.9995){const l=Math.acos(o),h=Math.sin(l);c=Math.sin(c*l)/h,e=Math.sin(e*l)/h,this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this._onChangeCallback()}else this._x=this._x*c+n*e,this._y=this._y*c+i*e,this._z=this._z*c+r*e,this._w=this._w*c+a*e,this.normalize();return this}slerpQuaternions(t,e,n){return this.copy(t).slerp(e,n)}random(){const t=2*Math.PI*Math.random(),e=2*Math.PI*Math.random(),n=Math.random(),i=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(e),r*Math.cos(e))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,e=0){return this._x=t[e],this._y=t[e+1],this._z=t[e+2],this._w=t[e+3],this._onChangeCallback(),this}toArray(t=[],e=0){return t[e]=this._x,t[e+1]=this._y,t[e+2]=this._z,t[e+3]=this._w,t}fromBufferAttribute(t,e){return this._x=t.getX(e),this._y=t.getY(e),this._z=t.getZ(e),this._w=t.getW(e),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class P{static{P.prototype.isVector3=!0}constructor(t=0,e=0,n=0){this.x=t,this.y=e,this.z=n}set(t,e,n){return n===void 0&&(n=this.z),this.x=t,this.y=e,this.z=n,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,e){return this.x=t.x*e.x,this.y=t.y*e.y,this.z=t.z*e.z,this}applyEuler(t){return this.applyQuaternion(wd.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(wd.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*i,this.y=r[1]*e+r[4]*n+r[7]*i,this.z=r[2]*e+r[5]*n+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*i+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*i+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*i+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*i+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,i=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*i-o*n),h=2*(o*e-r*i),u=2*(r*n-a*e);return this.x=e+c*l+a*u-o*h,this.y=n+c*h+o*l-r*u,this.z=i+c*u+r*h-a*l,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const e=this.x,n=this.y,i=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*i,this.y=r[1]*e+r[5]*n+r[9]*i,this.z=r[2]*e+r[6]*n+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,e){const n=t.x,i=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=i*c-r*o,this.y=r*a-n*c,this.z=n*o-i*a,this}projectOnVector(t){const e=t.lengthSq();if(e===0)return this.set(0,0,0);const n=t.dot(this)/e;return this.copy(t).multiplyScalar(n)}projectOnPlane(t){return Ac.copy(this).projectOnVector(t),this.sub(Ac)}reflect(t){return this.sub(Ac.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const e=Math.sqrt(this.lengthSq()*t.lengthSq());if(e===0)return Math.PI/2;const n=this.dot(t)/e;return Math.acos(Yt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,i=this.z-t.z;return e*e+n*n+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,e,n){const i=Math.sin(e)*t;return this.x=i*Math.sin(n),this.y=Math.cos(e)*t,this.z=i*Math.cos(n),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,e,n){return this.x=t*Math.sin(e),this.y=n,this.z=t*Math.cos(e),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this}setFromMatrixScale(t){const e=this.setFromMatrixColumn(t,0).length(),n=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=i,this}setFromMatrixColumn(t,e){return this.fromArray(t.elements,e*4)}setFromMatrix3Column(t,e){return this.fromArray(t.elements,e*3)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,e=Math.random()*2-1,n=Math.sqrt(1-e*e);return this.x=n*Math.cos(t),this.y=e,this.z=n*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const Ac=new P,wd=new hs;class Bt{static{Bt.prototype.isMatrix3=!0}constructor(t,e,n,i,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l)}set(t,e,n,i,r,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=i,h[2]=o,h[3]=e,h[4]=r,h[5]=c,h[6]=n,h[7]=a,h[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],this}extractBasis(t,e,n){return t.setFromMatrix3Column(this,0),e.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const e=t.elements;return this.set(e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[3],c=n[6],l=n[1],h=n[4],u=n[7],d=n[2],f=n[5],g=n[8],v=i[0],p=i[3],m=i[6],b=i[1],E=i[4],M=i[7],S=i[2],w=i[5],R=i[8];return r[0]=a*v+o*b+c*S,r[3]=a*p+o*E+c*w,r[6]=a*m+o*M+c*R,r[1]=l*v+h*b+u*S,r[4]=l*p+h*E+u*w,r[7]=l*m+h*M+u*R,r[2]=d*v+f*b+g*S,r[5]=d*p+f*E+g*w,r[8]=d*m+f*M+g*R,this}multiplyScalar(t){const e=this.elements;return e[0]*=t,e[3]*=t,e[6]*=t,e[1]*=t,e[4]*=t,e[7]*=t,e[2]*=t,e[5]*=t,e[8]*=t,this}determinant(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8];return e*a*h-e*o*l-n*r*h+n*o*c+i*r*l-i*a*c}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=h*a-o*l,d=o*c-h*r,f=l*r-a*c,g=e*u+n*d+i*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const v=1/g;return t[0]=u*v,t[1]=(i*l-h*n)*v,t[2]=(o*n-i*a)*v,t[3]=d*v,t[4]=(h*e-i*c)*v,t[5]=(i*r-o*e)*v,t[6]=f*v,t[7]=(n*c-l*e)*v,t[8]=(a*e-n*r)*v,this}transpose(){let t;const e=this.elements;return t=e[1],e[1]=e[3],e[3]=t,t=e[2],e[2]=e[6],e[6]=t,t=e[5],e[5]=e[7],e[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const e=this.elements;return t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8],this}setUvTransform(t,e,n,i,r,a,o){const c=Math.cos(r),l=Math.sin(r);return this.set(n*c,n*l,-n*(c*a+l*o)+a+t,-i*l,i*c,-i*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return gr("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Tc.makeScale(t,e)),this}rotate(t){return gr("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Tc.makeRotation(-t)),this}translate(t,e){return gr("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Tc.makeTranslation(t,e)),this}makeTranslation(t,e){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,e,0,0,1),this}makeRotation(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,n,e,0,0,0,1),this}makeScale(t,e){return this.set(t,0,0,0,e,0,0,0,1),this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<9;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<9;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t}clone(){return new this.constructor().fromArray(this.elements)}}const Tc=new Bt,Ad=new Bt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Td=new Bt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function k1(){const s={enabled:!0,workingColorSpace:$o,spaces:{},convert:function(i,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===se&&(i.r=Ni(i.r),i.g=Ni(i.g),i.b=Ni(i.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(i.applyMatrix3(this.spaces[r].toXYZ),i.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===se&&(i.r=vr(i.r),i.g=vr(i.g),i.b=vr(i.b))),i},workingToColorSpace:function(i,r){return this.convert(i,this.workingColorSpace,r)},colorSpaceToWorking:function(i,r){return this.convert(i,r,this.workingColorSpace)},getPrimaries:function(i){return this.spaces[i].primaries},getTransfer:function(i){return i===is?Zo:this.spaces[i].transfer},getToneMappingMode:function(i){return this.spaces[i].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(i,r=this.workingColorSpace){return i.fromArray(this.spaces[r].luminanceCoefficients)},define:function(i){Object.assign(this.spaces,i)},_getMatrix:function(i,r,a){return i.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(i){return this.spaces[i].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(i=this.workingColorSpace){return this.spaces[i].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(i,r){return gr("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),s.workingToColorSpace(i,r)},toWorkingColorSpace:function(i,r){return gr("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),s.colorSpaceToWorking(i,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return s.define({[$o]:{primaries:t,whitePoint:n,transfer:Zo,toXYZ:Ad,fromXYZ:Td,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:Rn},outputColorSpaceConfig:{drawingBufferColorSpace:Rn}},[Rn]:{primaries:t,whitePoint:n,transfer:se,toXYZ:Ad,fromXYZ:Td,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:Rn}}}),s}const Qt=k1();function Ni(s){return s<.04045?s*.0773993808:Math.pow(s*.9478672986+.0521327014,2.4)}function vr(s){return s<.0031308?s*12.92:1.055*Math.pow(s,.41666)-.055}let ks;class H1{static getDataURL(t,e="image/png"){if(/^data:/i.test(t.src)||typeof HTMLCanvasElement>"u")return t.src;let n;if(t instanceof HTMLCanvasElement)n=t;else{ks===void 0&&(ks=_a("canvas")),ks.width=t.width,ks.height=t.height;const i=ks.getContext("2d");t instanceof ImageData?i.putImageData(t,0,0):i.drawImage(t,0,0,t.width,t.height),n=ks}return n.toDataURL(e)}static sRGBToLinear(t){if(typeof HTMLImageElement<"u"&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&t instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&t instanceof ImageBitmap){const e=_a("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const i=n.getImageData(0,0,t.width,t.height),r=i.data;for(let a=0;a<r.length;a++)r[a]=Ni(r[a]/255)*255;return n.putImageData(i,0,0),e}else if(t.data){const e=t.data.slice(0);for(let n=0;n<e.length;n++)e instanceof Uint8Array||e instanceof Uint8ClampedArray?e[n]=Math.floor(Ni(e[n]/255)*255):e[n]=Ni(e[n]);return{data:e,width:t.width,height:t.height}}else return wt("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let G1=0;class mu{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:G1++}),this.uuid=$n(),this.data=t,this.dataReady=!0,this.version=0}getSize(t){const e=this.data;return typeof HTMLVideoElement<"u"&&e instanceof HTMLVideoElement?t.set(e.videoWidth,e.videoHeight,0):typeof VideoFrame<"u"&&e instanceof VideoFrame?t.set(e.displayWidth,e.displayHeight,0):e!==null?t.set(e.width,e.height,e.depth||0):t.set(0,0,0),t}set needsUpdate(t){t===!0&&this.version++}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.images[this.uuid]!==void 0)return t.images[this.uuid];const n={uuid:this.uuid,url:""},i=this.data;if(i!==null){let r;if(Array.isArray(i)){r=[];for(let a=0,o=i.length;a<o;a++)i[a].isDataTexture?r.push(Rc(i[a].image)):r.push(Rc(i[a]))}else r=Rc(i);n.url=r}return e||(t.images[this.uuid]=n),n}}function Rc(s){return typeof HTMLImageElement<"u"&&s instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&s instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&s instanceof ImageBitmap?H1.getDataURL(s):s.data?{data:Array.from(s.data),width:s.width,height:s.height,type:s.data.constructor.name}:(wt("Texture: Unable to serialize Texture."),{})}let V1=0;const Dc=new P;class $e extends Ns{constructor(t=$e.DEFAULT_IMAGE,e=$e.DEFAULT_MAPPING,n=dn,i=dn,r=ye,a=ws,o=fn,c=Dn,l=$e.DEFAULT_ANISOTROPY,h=is){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:V1++}),this.uuid=$n(),this.name="",this.source=new mu(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=i,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Pt(0,0),this.repeat=new Pt(1,1),this.center=new Pt(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new Bt,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(Dc).x}get height(){return this.source.getSize(Dc).y}get depth(){return this.source.getSize(Dc).z}get image(){return this.source.data}set image(t){this.source.data=t}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(t){return this.name=t.name,this.source=t.source,this.mipmaps=t.mipmaps.slice(0),this.mapping=t.mapping,this.channel=t.channel,this.wrapS=t.wrapS,this.wrapT=t.wrapT,this.magFilter=t.magFilter,this.minFilter=t.minFilter,this.anisotropy=t.anisotropy,this.format=t.format,this.internalFormat=t.internalFormat,this.type=t.type,this.normalized=t.normalized,this.offset.copy(t.offset),this.repeat.copy(t.repeat),this.center.copy(t.center),this.rotation=t.rotation,this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrix.copy(t.matrix),this.generateMipmaps=t.generateMipmaps,this.premultiplyAlpha=t.premultiplyAlpha,this.flipY=t.flipY,this.unpackAlignment=t.unpackAlignment,this.colorSpace=t.colorSpace,this.renderTarget=t.renderTarget,this.isRenderTargetTexture=t.isRenderTargetTexture,this.isArrayTexture=t.isArrayTexture,this.userData=JSON.parse(JSON.stringify(t.userData)),this.needsUpdate=!0,this}setValues(t){for(const e in t){const n=t[e];if(n===void 0){wt(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Texture.setValues(): property '${e}' does not exist.`);continue}i&&n&&i.isVector2&&n.isVector2||i&&n&&i.isVector3&&n.isVector3||i&&n&&i.isMatrix3&&n.isMatrix3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";if(!e&&t.textures[this.uuid]!==void 0)return t.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(t).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),e||(t.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(t){if(this.mapping!==pp)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Wo:t.x=t.x-Math.floor(t.x);break;case dn:t.x=t.x<0?0:1;break;case Yl: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 Wo:t.y=t.y-Math.floor(t.y);break;case dn:t.y=t.y<0?0:1;break;case Yl: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++}}$e.DEFAULT_IMAGE=null;$e.DEFAULT_MAPPING=pp;$e.DEFAULT_ANISOTROPY=1;class le{static{le.prototype.isVector4=!0}constructor(t=0,e=0,n=0,i=1){this.x=t,this.y=e,this.z=n,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,e,n,i){return this.x=t,this.y=e,this.z=n,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,e){switch(t){case 0:this.x=e;break;case 1:this.y=e;break;case 2:this.z=e;break;case 3:this.w=e;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w!==void 0?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this.w=t.w+e.w,this}addScaledVector(t,e){return this.x+=t.x*e,this.y+=t.y*e,this.z+=t.z*e,this.w+=t.w*e,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this.w=t.w-e.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const e=this.x,n=this.y,i=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*i+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*i+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*i+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*i+a[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const e=Math.sqrt(1-t.w*t.w);return e<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/e,this.y=t.y/e,this.z=t.z/e),this}setAxisAngleFromRotationMatrix(t){let e,n,i,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],g=c[9],v=c[2],p=c[6],m=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-v)<.01&&Math.abs(g-p)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+v)<.1&&Math.abs(g+p)<.1&&Math.abs(l+f+m-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const E=(l+1)/2,M=(f+1)/2,S=(m+1)/2,w=(h+d)/4,R=(u+v)/4,_=(g+p)/4;return E>M&&E>S?E<.01?(n=0,i=.707106781,r=.707106781):(n=Math.sqrt(E),i=w/n,r=R/n):M>S?M<.01?(n=.707106781,i=0,r=.707106781):(i=Math.sqrt(M),n=w/i,r=_/i):S<.01?(n=.707106781,i=.707106781,r=0):(r=Math.sqrt(S),n=R/r,i=_/r),this.set(n,i,r,e),this}let b=Math.sqrt((p-g)*(p-g)+(u-v)*(u-v)+(d-h)*(d-h));return Math.abs(b)<.001&&(b=1),this.x=(p-g)/b,this.y=(u-v)/b,this.z=(d-h)/b,this.w=Math.acos((l+f+m-1)/2),this}setFromMatrixPosition(t){const e=t.elements;return this.x=e[12],this.y=e[13],this.z=e[14],this.w=e[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,e){return this.x=Yt(this.x,t.x,e.x),this.y=Yt(this.y,t.y,e.y),this.z=Yt(this.z,t.z,e.z),this.w=Yt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Yt(this.x,t,e),this.y=Yt(this.y,t,e),this.z=Yt(this.z,t,e),this.w=Yt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Yt(n,t,e))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,e){return this.x+=(t.x-this.x)*e,this.y+=(t.y-this.y)*e,this.z+=(t.z-this.z)*e,this.w+=(t.w-this.w)*e,this}lerpVectors(t,e,n){return this.x=t.x+(e.x-t.x)*n,this.y=t.y+(e.y-t.y)*n,this.z=t.z+(e.z-t.z)*n,this.w=t.w+(e.w-t.w)*n,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,e=0){return this.x=t[e],this.y=t[e+1],this.z=t[e+2],this.w=t[e+3],this}toArray(t=[],e=0){return t[e]=this.x,t[e+1]=this.y,t[e+2]=this.z,t[e+3]=this.w,t}fromBufferAttribute(t,e){return this.x=t.getX(e),this.y=t.getY(e),this.z=t.getZ(e),this.w=t.getW(e),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class W1 extends Ns{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:ye,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},n),this.isRenderTarget=!0,this.width=t,this.height=e,this.depth=n.depth,this.scissor=new le(0,0,t,e),this.scissorTest=!1,this.viewport=new le(0,0,t,e),this.textures=[];const i={width:t,height:e,depth:n.depth},r=new $e(i),a=n.count;for(let o=0;o<a;o++)this.textures[o]=r.clone(),this.textures[o].isRenderTargetTexture=!0,this.textures[o].renderTarget=this;this._setTextureOptions(n),this.depthBuffer=n.depthBuffer,this.stencilBuffer=n.stencilBuffer,this.resolveDepthBuffer=n.resolveDepthBuffer,this.resolveStencilBuffer=n.resolveStencilBuffer,this._depthTexture=null,this.depthTexture=n.depthTexture,this.samples=n.samples,this.multiview=n.multiview,this.useArrayDepthTexture=n.useArrayDepthTexture}_setTextureOptions(t={}){const e={minFilter:ye,generateMipmaps:!1,flipY:!1,internalFormat:null};t.mapping!==void 0&&(e.mapping=t.mapping),t.wrapS!==void 0&&(e.wrapS=t.wrapS),t.wrapT!==void 0&&(e.wrapT=t.wrapT),t.wrapR!==void 0&&(e.wrapR=t.wrapR),t.magFilter!==void 0&&(e.magFilter=t.magFilter),t.minFilter!==void 0&&(e.minFilter=t.minFilter),t.format!==void 0&&(e.format=t.format),t.type!==void 0&&(e.type=t.type),t.anisotropy!==void 0&&(e.anisotropy=t.anisotropy),t.colorSpace!==void 0&&(e.colorSpace=t.colorSpace),t.flipY!==void 0&&(e.flipY=t.flipY),t.generateMipmaps!==void 0&&(e.generateMipmaps=t.generateMipmaps),t.internalFormat!==void 0&&(e.internalFormat=t.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(e)}get texture(){return this.textures[0]}set texture(t){this.textures[0]=t}set depthTexture(t){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),t!==null&&(t.renderTarget=this),this._depthTexture=t}get depthTexture(){return this._depthTexture}setSize(t,e,n=1){if(this.width!==t||this.height!==e||this.depth!==n){this.width=t,this.height=e,this.depth=n;for(let i=0,r=this.textures.length;i<r;i++)this.textures[i].image.width=t,this.textures[i].image.height=e,this.textures[i].image.depth=n,this.textures[i].isData3DTexture!==!0&&(this.textures[i].isArrayTexture=this.textures[i].image.depth>1);this.dispose()}this.viewport.set(0,0,t,e),this.scissor.set(0,0,t,e)}clone(){return new this.constructor().copy(this)}copy(t){this.width=t.width,this.height=t.height,this.depth=t.depth,this.scissor.copy(t.scissor),this.scissorTest=t.scissorTest,this.viewport.copy(t.viewport),this.textures.length=0;for(let e=0,n=t.textures.length;e<n;e++){this.textures[e]=t.textures[e].clone(),this.textures[e].isRenderTargetTexture=!0,this.textures[e].renderTarget=this;const i=Object.assign({},t.textures[e].image);this.textures[e].source=new mu(i)}return this.depthBuffer=t.depthBuffer,this.stencilBuffer=t.stencilBuffer,this.resolveDepthBuffer=t.resolveDepthBuffer,this.resolveStencilBuffer=t.resolveStencilBuffer,t.depthTexture!==null&&(this.depthTexture=t.depthTexture.clone()),this.samples=t.samples,this.multiview=t.multiview,this.useArrayDepthTexture=t.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Sn extends W1{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class Sp extends $e{constructor(t=null,e=1,n=1,i=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ke,this.minFilter=ke,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class X1 extends $e{constructor(t=null,e=1,n=1,i=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:i},this.magFilter=ke,this.minFilter=ke,this.wrapR=dn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class Xt{static{Xt.prototype.isMatrix4=!0}constructor(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p)}set(t,e,n,i,r,a,o,c,l,h,u,d,f,g,v,p){const m=this.elements;return m[0]=t,m[4]=e,m[8]=n,m[12]=i,m[1]=r,m[5]=a,m[9]=o,m[13]=c,m[2]=l,m[6]=h,m[10]=u,m[14]=d,m[3]=f,m[7]=g,m[11]=v,m[15]=p,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 Xt().fromArray(this.elements)}copy(t){const e=this.elements,n=t.elements;return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=n[6],e[7]=n[7],e[8]=n[8],e[9]=n[9],e[10]=n[10],e[11]=n[11],e[12]=n[12],e[13]=n[13],e[14]=n[14],e[15]=n[15],this}copyPosition(t){const e=this.elements,n=t.elements;return e[12]=n[12],e[13]=n[13],e[14]=n[14],this}setFromMatrix3(t){const e=t.elements;return this.set(e[0],e[3],e[6],0,e[1],e[4],e[7],0,e[2],e[5],e[8],0,0,0,0,1),this}extractBasis(t,e,n){return this.determinantAffine()===0?(t.set(1,0,0),e.set(0,1,0),n.set(0,0,1),this):(t.setFromMatrixColumn(this,0),e.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(t,e,n){return this.set(t.x,e.x,n.x,0,t.y,e.y,n.y,0,t.z,e.z,n.z,0,0,0,0,1),this}extractRotation(t){if(t.determinantAffine()===0)return this.identity();const e=this.elements,n=t.elements,i=1/Hs.setFromMatrixColumn(t,0).length(),r=1/Hs.setFromMatrixColumn(t,1).length(),a=1/Hs.setFromMatrixColumn(t,2).length();return e[0]=n[0]*i,e[1]=n[1]*i,e[2]=n[2]*i,e[3]=0,e[4]=n[4]*r,e[5]=n[5]*r,e[6]=n[6]*r,e[7]=0,e[8]=n[8]*a,e[9]=n[9]*a,e[10]=n[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,this}makeRotationFromEuler(t){const e=this.elements,n=t.x,i=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,v=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+g*l,e[5]=d-v*l,e[9]=-o*c,e[2]=v-d*l,e[6]=g+f*l,e[10]=a*c}else if(t.order==="YXZ"){const d=c*h,f=c*u,g=l*h,v=l*u;e[0]=d+v*o,e[4]=g*o-f,e[8]=a*l,e[1]=a*u,e[5]=a*h,e[9]=-o,e[2]=f*o-g,e[6]=v+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,g=l*h,v=l*u;e[0]=d-v*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=v-d*o,e[2]=-a*l,e[6]=o,e[10]=a*c}else if(t.order==="ZYX"){const d=a*h,f=a*u,g=o*h,v=o*u;e[0]=c*h,e[4]=g*l-f,e[8]=d*l+v,e[1]=c*u,e[5]=v*l+d,e[9]=f*l-g,e[2]=-l,e[6]=o*c,e[10]=a*c}else if(t.order==="YZX"){const d=a*c,f=a*l,g=o*c,v=o*l;e[0]=c*h,e[4]=v-d*u,e[8]=g*u+f,e[1]=u,e[5]=a*h,e[9]=-o*h,e[2]=-l*h,e[6]=f*u+g,e[10]=d-v*u}else if(t.order==="XZY"){const d=a*c,f=a*l,g=o*c,v=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+v,e[5]=a*h,e[9]=f*u-g,e[2]=g*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(q1,t,Y1)}lookAt(t,e,n){const i=this.elements;return En.subVectors(t,e),En.lengthSq()===0&&(En.z=1),En.normalize(),qi.crossVectors(n,En),qi.lengthSq()===0&&(Math.abs(n.z)===1?En.x+=1e-4:En.z+=1e-4,En.normalize(),qi.crossVectors(n,En)),qi.normalize(),Fa.crossVectors(En,qi),i[0]=qi.x,i[4]=Fa.x,i[8]=En.x,i[1]=qi.y,i[5]=Fa.y,i[9]=En.y,i[2]=qi.z,i[6]=Fa.z,i[10]=En.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,i=e.elements,r=this.elements,a=n[0],o=n[4],c=n[8],l=n[12],h=n[1],u=n[5],d=n[9],f=n[13],g=n[2],v=n[6],p=n[10],m=n[14],b=n[3],E=n[7],M=n[11],S=n[15],w=i[0],R=i[4],_=i[8],A=i[12],C=i[1],D=i[5],I=i[9],V=i[13],q=i[2],O=i[6],W=i[10],G=i[14],Z=i[3],et=i[7],j=i[11],it=i[15];return r[0]=a*w+o*C+c*q+l*Z,r[4]=a*R+o*D+c*O+l*et,r[8]=a*_+o*I+c*W+l*j,r[12]=a*A+o*V+c*G+l*it,r[1]=h*w+u*C+d*q+f*Z,r[5]=h*R+u*D+d*O+f*et,r[9]=h*_+u*I+d*W+f*j,r[13]=h*A+u*V+d*G+f*it,r[2]=g*w+v*C+p*q+m*Z,r[6]=g*R+v*D+p*O+m*et,r[10]=g*_+v*I+p*W+m*j,r[14]=g*A+v*V+p*G+m*it,r[3]=b*w+E*C+M*q+S*Z,r[7]=b*R+E*D+M*O+S*et,r[11]=b*_+E*I+M*W+S*j,r[15]=b*A+E*V+M*G+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],n=t[4],i=t[8],r=t[12],a=t[1],o=t[5],c=t[9],l=t[13],h=t[2],u=t[6],d=t[10],f=t[14],g=t[3],v=t[7],p=t[11],m=t[15],b=c*f-l*d,E=o*f-l*u,M=o*d-c*u,S=a*f-l*h,w=a*d-c*h,R=a*u-o*h;return e*(v*b-p*E+m*M)-n*(g*b-p*S+m*w)+i*(g*E-v*S+m*R)-r*(g*M-v*w+p*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],i=t[8],r=t[1],a=t[5],o=t[9],c=t[2],l=t[6],h=t[10];return e*(a*h-o*l)-n*(r*h-o*c)+i*(r*l-a*c)}transpose(){const t=this.elements;let e;return e=t[1],t[1]=t[4],t[4]=e,e=t[2],t[2]=t[8],t[8]=e,e=t[6],t[6]=t[9],t[9]=e,e=t[3],t[3]=t[12],t[12]=e,e=t[7],t[7]=t[13],t[13]=e,e=t[11],t[11]=t[14],t[14]=e,this}setPosition(t,e,n){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=e,i[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],i=t[2],r=t[3],a=t[4],o=t[5],c=t[6],l=t[7],h=t[8],u=t[9],d=t[10],f=t[11],g=t[12],v=t[13],p=t[14],m=t[15],b=e*o-n*a,E=e*c-i*a,M=e*l-r*a,S=n*c-i*o,w=n*l-r*o,R=i*l-r*c,_=h*v-u*g,A=h*p-d*g,C=h*m-f*g,D=u*p-d*v,I=u*m-f*v,V=d*m-f*p,q=b*V-E*I+M*D+S*C-w*A+R*_;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const O=1/q;return t[0]=(o*V-c*I+l*D)*O,t[1]=(i*I-n*V-r*D)*O,t[2]=(v*R-p*w+m*S)*O,t[3]=(d*w-u*R-f*S)*O,t[4]=(c*C-a*V-l*A)*O,t[5]=(e*V-i*C+r*A)*O,t[6]=(p*M-g*R-m*E)*O,t[7]=(h*R-d*M+f*E)*O,t[8]=(a*I-o*C+l*_)*O,t[9]=(n*C-e*I-r*_)*O,t[10]=(g*w-v*M+m*b)*O,t[11]=(u*M-h*w-f*b)*O,t[12]=(o*A-a*D-c*_)*O,t[13]=(e*D-n*A+i*_)*O,t[14]=(v*E-g*S-p*b)*O,t[15]=(h*S-u*E+d*b)*O,this}scale(t){const e=this.elements,n=t.x,i=t.y,r=t.z;return e[0]*=n,e[4]*=i,e[8]*=r,e[1]*=n,e[5]*=i,e[9]*=r,e[2]*=n,e[6]*=i,e[10]*=r,e[3]*=n,e[7]*=i,e[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,e=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],n=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,i))}makeTranslation(t,e,n){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,e,0,0,1,n,0,0,0,1),this}makeRotationX(t){const e=Math.cos(t),n=Math.sin(t);return this.set(1,0,0,0,0,e,-n,0,0,n,e,0,0,0,0,1),this}makeRotationY(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,0,n,0,0,1,0,0,-n,0,e,0,0,0,0,1),this}makeRotationZ(t){const e=Math.cos(t),n=Math.sin(t);return this.set(e,-n,0,0,n,e,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,e){const n=Math.cos(e),i=Math.sin(e),r=1-n,a=t.x,o=t.y,c=t.z,l=r*a,h=r*o;return this.set(l*a+n,l*o-i*c,l*c+i*o,0,l*o+i*c,h*o+n,h*c-i*a,0,l*c-i*o,h*c+i*a,r*c*c+n,0,0,0,0,1),this}makeScale(t,e,n){return this.set(t,0,0,0,0,e,0,0,0,0,n,0,0,0,0,1),this}makeShear(t,e,n,i,r,a){return this.set(1,n,r,0,t,1,a,0,e,i,1,0,0,0,0,1),this}compose(t,e,n){const i=this.elements,r=e._x,a=e._y,o=e._z,c=e._w,l=r+r,h=a+a,u=o+o,d=r*l,f=r*h,g=r*u,v=a*h,p=a*u,m=o*u,b=c*l,E=c*h,M=c*u,S=n.x,w=n.y,R=n.z;return i[0]=(1-(v+m))*S,i[1]=(f+M)*S,i[2]=(g-E)*S,i[3]=0,i[4]=(f-M)*w,i[5]=(1-(d+m))*w,i[6]=(p+b)*w,i[7]=0,i[8]=(g+E)*R,i[9]=(p-b)*R,i[10]=(1-(d+v))*R,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,e,n){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=Hs.set(i[0],i[1],i[2]).length();const o=Hs.set(i[4],i[5],i[6]).length(),c=Hs.set(i[8],i[9],i[10]).length();r<0&&(a=-a),kn.copy(this);const l=1/a,h=1/o,u=1/c;return kn.elements[0]*=l,kn.elements[1]*=l,kn.elements[2]*=l,kn.elements[4]*=h,kn.elements[5]*=h,kn.elements[6]*=h,kn.elements[8]*=u,kn.elements[9]*=u,kn.elements[10]*=u,e.setFromRotationMatrix(kn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,i,r,a,o=fi,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-i),d=(e+t)/(e-t),f=(n+i)/(n-i);let g,v;if(c)g=r/(a-r),v=a*r/(a-r);else if(o===fi)g=-(a+r)/(a-r),v=-2*a*r/(a-r);else if(o===xa)g=-a/(a-r),v=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=d,l[12]=0,l[1]=0,l[5]=u,l[9]=f,l[13]=0,l[2]=0,l[6]=0,l[10]=g,l[14]=v,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,i,r,a,o=fi,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-i),d=-(e+t)/(e-t),f=-(n+i)/(n-i);let g,v;if(c)g=1/(a-r),v=a/(a-r);else if(o===fi)g=-2/(a-r),v=-(a+r)/(a-r);else if(o===xa)g=-1/(a-r),v=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return l[0]=h,l[4]=0,l[8]=0,l[12]=d,l[1]=0,l[5]=u,l[9]=0,l[13]=f,l[2]=0,l[6]=0,l[10]=g,l[14]=v,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let i=0;i<16;i++)if(e[i]!==n[i])return!1;return!0}fromArray(t,e=0){for(let n=0;n<16;n++)this.elements[n]=t[n+e];return this}toArray(t=[],e=0){const n=this.elements;return t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+3]=n[3],t[e+4]=n[4],t[e+5]=n[5],t[e+6]=n[6],t[e+7]=n[7],t[e+8]=n[8],t[e+9]=n[9],t[e+10]=n[10],t[e+11]=n[11],t[e+12]=n[12],t[e+13]=n[13],t[e+14]=n[14],t[e+15]=n[15],t}}const Hs=new P,kn=new Xt,q1=new P(0,0,0),Y1=new P(1,1,1),qi=new P,Fa=new P,En=new P,Rd=new Xt,Dd=new hs;class Fi{constructor(t=0,e=0,n=0,i=Fi.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=i}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get order(){return this._order}set order(t){this._order=t,this._onChangeCallback()}set(t,e,n,i=this._order){return this._x=t,this._y=e,this._z=n,this._order=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(t){return this._x=t._x,this._y=t._y,this._z=t._z,this._order=t._order,this._onChangeCallback(),this}setFromRotationMatrix(t,e=this._order,n=!0){const i=t.elements,r=i[0],a=i[4],o=i[8],c=i[1],l=i[5],h=i[9],u=i[2],d=i[6],f=i[10];switch(e){case"XYZ":this._y=Math.asin(Yt(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,f),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,l),this._z=0);break;case"YXZ":this._x=Math.asin(-Yt(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,f),this._z=Math.atan2(c,l)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Yt(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,f),this._z=Math.atan2(-a,l)):(this._y=0,this._z=Math.atan2(c,r));break;case"ZYX":this._y=Math.asin(-Yt(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,f),this._z=Math.atan2(c,r)):(this._x=0,this._z=Math.atan2(-a,l));break;case"YZX":this._z=Math.asin(Yt(c,-1,1)),Math.abs(c)<.9999999?(this._x=Math.atan2(-h,l),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,f));break;case"XZY":this._z=Math.asin(-Yt(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,l),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,f),this._y=0);break;default:wt("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Rd.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Rd,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Dd.setFromEuler(this),this.setFromQuaternion(Dd,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}}Fi.DEFAULT_ORDER="XYZ";class gu{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 K1=0;const Cd=new P,Gs=new hs,Mi=new Xt,za=new P,Or=new P,$1=new P,Z1=new hs,Pd=new P(1,0,0),Id=new P(0,1,0),Ld=new P(0,0,1),Nd={type:"added"},J1={type:"removed"},Vs={type:"childadded",child:null},Cc={type:"childremoved",child:null};class _e extends Ns{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:K1++}),this.uuid=$n(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=_e.DEFAULT_UP.clone();const t=new P,e=new Fi,n=new hs,i=new P(1,1,1);function r(){n.setFromEuler(e,!1)}function a(){e.setFromQuaternion(n,void 0,!1)}e._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:t},rotation:{configurable:!0,enumerable:!0,value:e},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:i},modelViewMatrix:{value:new Xt},normalMatrix:{value:new Bt}}),this.matrix=new Xt,this.matrixWorld=new Xt,this.matrixAutoUpdate=_e.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=_e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new gu,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 Gs.setFromAxisAngle(t,e),this.quaternion.multiply(Gs),this}rotateOnWorldAxis(t,e){return Gs.setFromAxisAngle(t,e),this.quaternion.premultiply(Gs),this}rotateX(t){return this.rotateOnAxis(Pd,t)}rotateY(t){return this.rotateOnAxis(Id,t)}rotateZ(t){return this.rotateOnAxis(Ld,t)}translateOnAxis(t,e){return Cd.copy(t).applyQuaternion(this.quaternion),this.position.add(Cd.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(Pd,t)}translateY(t){return this.translateOnAxis(Id,t)}translateZ(t){return this.translateOnAxis(Ld,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Mi.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?za.copy(t):za.set(t,e,n);const i=this.parent;this.updateWorldMatrix(!0,!1),Or.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Mi.lookAt(Or,za,this.up):Mi.lookAt(za,Or,this.up),this.quaternion.setFromRotationMatrix(Mi),i&&(Mi.extractRotation(i.matrixWorld),Gs.setFromRotationMatrix(Mi),this.quaternion.premultiply(Gs.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(zt("Object3D.add: object can't be added as a child of itself.",t),this):(t&&t.isObject3D?(t.removeFromParent(),t.parent=this,this.children.push(t),t.dispatchEvent(Nd),Vs.child=t,this.dispatchEvent(Vs),Vs.child=null):zt("Object3D.add: object not an instance of THREE.Object3D.",t),this)}remove(t){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const e=this.children.indexOf(t);return e!==-1&&(t.parent=null,this.children.splice(e,1),t.dispatchEvent(J1),Cc.child=t,this.dispatchEvent(Cc),Cc.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),Mi.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Mi.multiply(t.parent.matrixWorld)),t.applyMatrix4(Mi),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Nd),Vs.child=t,this.dispatchEvent(Vs),Vs.child=null,this}getObjectById(t){return this.getObjectByProperty("id",t)}getObjectByName(t){return this.getObjectByProperty("name",t)}getObjectByProperty(t,e){if(this[t]===e)return this;for(let n=0,i=this.children.length;n<i;n++){const a=this.children[n].getObjectByProperty(t,e);if(a!==void 0)return a}}getObjectsByProperty(t,e,n=[]){this[t]===e&&n.push(this);const i=this.children;for(let r=0,a=i.length;r<a;r++)i[r].getObjectsByProperty(t,e,n);return n}getWorldPosition(t){return this.updateWorldMatrix(!0,!1),t.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Or,t,$1),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(Or,Z1,t),t}getWorldDirection(t){this.updateWorldMatrix(!0,!1);const e=this.matrixWorld.elements;return t.set(e[8],e[9],e[10]).normalize()}raycast(){}traverse(t){t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].traverseVisible(t)}traverseAncestors(t){const e=this.parent;e!==null&&(t(e),e.traverseAncestors(t))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const t=this.pivot;if(t!==null){const e=t.x,n=t.y,i=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*i,r[13]+=n-r[1]*e-r[5]*n-r[9]*i,r[14]+=i-r[2]*e-r[6]*n-r[10]*i}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(t){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||t)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,t=!0);const e=this.children;for(let n=0,i=e.length;n<i;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const i=this.parent;if(t===!0&&i!==null&&i.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||n)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,n=!0),e===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(t){const e=t===void 0||typeof t=="string",n={};e&&(t={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const i={};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.castShadow===!0&&(i.castShadow=!0),this.receiveShadow===!0&&(i.receiveShadow=!0),this.visible===!1&&(i.visible=!1),this.frustumCulled===!1&&(i.frustumCulled=!1),this.renderOrder!==0&&(i.renderOrder=this.renderOrder),this.static!==!1&&(i.static=this.static),Object.keys(this.userData).length>0&&(i.userData=this.userData),i.layers=this.layers.mask,i.matrix=this.matrix.toArray(),i.up=this.up.toArray(),this.pivot!==null&&(i.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(i.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(i.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(i.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(i.type="InstancedMesh",i.count=this.count,i.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(i.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(i.type="BatchedMesh",i.perObjectFrustumCulled=this.perObjectFrustumCulled,i.sortObjects=this.sortObjects,i.drawRanges=this._drawRanges,i.reservedRanges=this._reservedRanges,i.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),i.instanceInfo=this._instanceInfo.map(o=>({...o})),i.availableInstanceIds=this._availableInstanceIds.slice(),i.availableGeometryIds=this._availableGeometryIds.slice(),i.nextIndexStart=this._nextIndexStart,i.nextVertexStart=this._nextVertexStart,i.geometryCount=this._geometryCount,i.maxInstanceCount=this._maxInstanceCount,i.maxVertexCount=this._maxVertexCount,i.maxIndexCount=this._maxIndexCount,i.geometryInitialized=this._geometryInitialized,i.matricesTexture=this._matricesTexture.toJSON(t),i.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(i.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(i.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(i.boundingBox=this.boundingBox.toJSON()));function r(o,c){return o[c.uuid]===void 0&&(o[c.uuid]=c.toJSON(t)),c.uuid}if(this.isScene)this.background&&(this.background.isColor?i.background=this.background.toJSON():this.background.isTexture&&(i.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(i.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){i.geometry=r(t.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const c=o.shapes;if(Array.isArray(c))for(let l=0,h=c.length;l<h;l++){const u=c[l];r(t.shapes,u)}else r(t.shapes,c)}}if(this.isSkinnedMesh&&(i.bindMode=this.bindMode,i.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),i.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let c=0,l=this.material.length;c<l;c++)o.push(r(t.materials,this.material[c]));i.material=o}else i.material=r(t.materials,this.material);if(this.children.length>0){i.children=[];for(let o=0;o<this.children.length;o++)i.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){i.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];i.animations.push(r(t.animations,c))}}if(e){const o=a(t.geometries),c=a(t.materials),l=a(t.textures),h=a(t.images),u=a(t.shapes),d=a(t.skeletons),f=a(t.animations),g=a(t.nodes);o.length>0&&(n.geometries=o),c.length>0&&(n.materials=c),l.length>0&&(n.textures=l),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),f.length>0&&(n.animations=f),g.length>0&&(n.nodes=g)}return n.object=i,n;function a(o){const c=[];for(const l in o){const h=o[l];delete h.metadata,c.push(h)}return c}}clone(t){return new this.constructor().copy(this,t)}copy(t,e=!0){if(this.name=t.name,this.up.copy(t.up),this.position.copy(t.position),this.rotation.order=t.rotation.order,this.quaternion.copy(t.quaternion),this.scale.copy(t.scale),this.pivot=t.pivot!==null?t.pivot.clone():null,this.matrix.copy(t.matrix),this.matrixWorld.copy(t.matrixWorld),this.matrixAutoUpdate=t.matrixAutoUpdate,this.matrixWorldAutoUpdate=t.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=t.matrixWorldNeedsUpdate,this.layers.mask=t.layers.mask,this.visible=t.visible,this.castShadow=t.castShadow,this.receiveShadow=t.receiveShadow,this.frustumCulled=t.frustumCulled,this.renderOrder=t.renderOrder,this.static=t.static,this.animations=t.animations.slice(),this.userData=JSON.parse(JSON.stringify(t.userData)),e===!0)for(let n=0;n<t.children.length;n++){const i=t.children[n];this.add(i.clone())}return this}}_e.DEFAULT_UP=new P(0,1,0);_e.DEFAULT_MATRIX_AUTO_UPDATE=!0;_e.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class en extends _e{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Q1={type:"move"};class Pc{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new en,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 en,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new P,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new P),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new en,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new P,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new P,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(t){return this._targetRay!==null&&this._targetRay.dispatchEvent(t),this._grip!==null&&this._grip.dispatchEvent(t),this._hand!==null&&this._hand.dispatchEvent(t),this}connect(t){if(t&&t.hand){const e=this._hand;if(e)for(const n of t.hand.values())this._getHandJoint(e,n)}return this.dispatchEvent({type:"connected",data:t}),this}disconnect(t){return this.dispatchEvent({type:"disconnected",data:t}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(t,e,n){let i=null,r=null,a=null;const o=this._targetRay,c=this._grip,l=this._hand;if(t&&e.session.visibilityState!=="visible-blurred"){if(l&&t.hand){a=!0;for(const v of t.hand.values()){const p=e.getJointPose(v,n),m=this._getHandJoint(l,v);p!==null&&(m.matrix.fromArray(p.transform.matrix),m.matrix.decompose(m.position,m.rotation,m.scale),m.matrixWorldNeedsUpdate=!0,m.jointRadius=p.radius),m.visible=p!==null}const h=l.joints["index-finger-tip"],u=l.joints["thumb-tip"],d=h.position.distanceTo(u.position),f=.02,g=.005;l.inputState.pinching&&d>f+g?(l.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:t.handedness,target:this})):!l.inputState.pinching&&d<=f-g&&(l.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:t.handedness,target:this}))}else c!==null&&t.gripSpace&&(r=e.getPose(t.gripSpace,n),r!==null&&(c.matrix.fromArray(r.transform.matrix),c.matrix.decompose(c.position,c.rotation,c.scale),c.matrixWorldNeedsUpdate=!0,r.linearVelocity?(c.hasLinearVelocity=!0,c.linearVelocity.copy(r.linearVelocity)):c.hasLinearVelocity=!1,r.angularVelocity?(c.hasAngularVelocity=!0,c.angularVelocity.copy(r.angularVelocity)):c.hasAngularVelocity=!1,c.eventsEnabled&&c.dispatchEvent({type:"gripUpdated",data:t,target:this})));o!==null&&(i=e.getPose(t.targetRaySpace,n),i===null&&r!==null&&(i=r),i!==null&&(o.matrix.fromArray(i.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,i.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(i.linearVelocity)):o.hasLinearVelocity=!1,i.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(i.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Q1)))}return o!==null&&(o.visible=i!==null),c!==null&&(c.visible=r!==null),l!==null&&(l.visible=a!==null),this}_getHandJoint(t,e){if(t.joints[e.jointName]===void 0){const n=new en;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const bp={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},Yi={h:0,s:0,l:0},Ba={h:0,s:0,l:0};function Ic(s,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?s+(t-s)*6*e:e<1/2?t:e<2/3?s+(t-s)*6*(2/3-e):s}class vt{constructor(t,e,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(t,e,n)}set(t,e,n){if(e===void 0&&n===void 0){const i=t;i&&i.isColor?this.copy(i):typeof i=="number"?this.setHex(i):typeof i=="string"&&this.setStyle(i)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=Rn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Qt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,i=Qt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Qt.colorSpaceToWorking(this,i),this}setHSL(t,e,n,i=Qt.workingColorSpace){if(t=pu(t,1),e=Yt(e,0,1),n=Yt(n,0,1),e===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+e):n+e-n*e,a=2*n-r;this.r=Ic(a,r,t+1/3),this.g=Ic(a,r,t),this.b=Ic(a,r,t-1/3)}return Qt.colorSpaceToWorking(this,i),this}setStyle(t,e=Rn){function n(r){r!==void 0&&parseFloat(r)<1&&wt("Color: Alpha component of "+t+" will be ignored.")}let i;if(i=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=i[1],o=i[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,e);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,e);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,e);break;default:wt("Color: Unknown color model "+t)}}else if(i=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=i[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,e);if(a===6)return this.setHex(parseInt(r,16),e);wt("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=Rn){const n=bp[t.toLowerCase()];return n!==void 0?this.setHex(n,e):wt("Color: Unknown color "+t),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(t){return this.r=t.r,this.g=t.g,this.b=t.b,this}copySRGBToLinear(t){return this.r=Ni(t.r),this.g=Ni(t.g),this.b=Ni(t.b),this}copyLinearToSRGB(t){return this.r=vr(t.r),this.g=vr(t.g),this.b=vr(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=Rn){return Qt.workingToColorSpace(Qe.copy(this),t),Math.round(Yt(Qe.r*255,0,255))*65536+Math.round(Yt(Qe.g*255,0,255))*256+Math.round(Yt(Qe.b*255,0,255))}getHexString(t=Rn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Qt.workingColorSpace){Qt.workingToColorSpace(Qe.copy(this),e);const n=Qe.r,i=Qe.g,r=Qe.b,a=Math.max(n,i,r),o=Math.min(n,i,r);let c,l;const h=(o+a)/2;if(o===a)c=0,l=0;else{const u=a-o;switch(l=h<=.5?u/(a+o):u/(2-a-o),a){case n:c=(i-r)/u+(i<r?6:0);break;case i:c=(r-n)/u+2;break;case r:c=(n-i)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Qt.workingColorSpace){return Qt.workingToColorSpace(Qe.copy(this),e),t.r=Qe.r,t.g=Qe.g,t.b=Qe.b,t}getStyle(t=Rn){Qt.workingToColorSpace(Qe.copy(this),t);const e=Qe.r,n=Qe.g,i=Qe.b;return t!==Rn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${i.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(i*255)})`}offsetHSL(t,e,n){return this.getHSL(Yi),this.setHSL(Yi.h+t,Yi.s+e,Yi.l+n)}add(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this}addColors(t,e){return this.r=t.r+e.r,this.g=t.g+e.g,this.b=t.b+e.b,this}addScalar(t){return this.r+=t,this.g+=t,this.b+=t,this}sub(t){return this.r=Math.max(0,this.r-t.r),this.g=Math.max(0,this.g-t.g),this.b=Math.max(0,this.b-t.b),this}multiply(t){return this.r*=t.r,this.g*=t.g,this.b*=t.b,this}multiplyScalar(t){return this.r*=t,this.g*=t,this.b*=t,this}lerp(t,e){return this.r+=(t.r-this.r)*e,this.g+=(t.g-this.g)*e,this.b+=(t.b-this.b)*e,this}lerpColors(t,e,n){return this.r=t.r+(e.r-t.r)*n,this.g=t.g+(e.g-t.g)*n,this.b=t.b+(e.b-t.b)*n,this}lerpHSL(t,e){this.getHSL(Yi),t.getHSL(Ba);const n=oa(Yi.h,Ba.h,e),i=oa(Yi.s,Ba.s,e),r=oa(Yi.l,Ba.l,e);return this.setHSL(n,i,r),this}setFromVector3(t){return this.r=t.x,this.g=t.y,this.b=t.z,this}applyMatrix3(t){const e=this.r,n=this.g,i=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*i,this.g=r[1]*e+r[4]*n+r[7]*i,this.b=r[2]*e+r[5]*n+r[8]*i,this}equals(t){return t.r===this.r&&t.g===this.g&&t.b===this.b}fromArray(t,e=0){return this.r=t[e],this.g=t[e+1],this.b=t[e+2],this}toArray(t=[],e=0){return t[e]=this.r,t[e+1]=this.g,t[e+2]=this.b,t}fromBufferAttribute(t,e){return this.r=t.getX(e),this.g=t.getY(e),this.b=t.getZ(e),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Qe=new vt;vt.NAMES=bp;class vu{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new vt(t),this.near=e,this.far=n}clone(){return new vu(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class uc extends _e{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 Fi,this.environmentIntensity=1,this.environmentRotation=new Fi,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 Hn=new P,yi=new P,Lc=new P,Si=new P,Ws=new P,Xs=new P,Od=new P,Nc=new P,Oc=new P,Uc=new P,Fc=new le,zc=new le,Bc=new le;class Fn{constructor(t=new P,e=new P,n=new P){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,i){i.subVectors(n,e),Hn.subVectors(t,e),i.cross(Hn);const r=i.lengthSq();return r>0?i.multiplyScalar(1/Math.sqrt(r)):i.set(0,0,0)}static getBarycoord(t,e,n,i,r){Hn.subVectors(i,e),yi.subVectors(n,e),Lc.subVectors(t,e);const a=Hn.dot(Hn),o=Hn.dot(yi),c=Hn.dot(Lc),l=yi.dot(yi),h=yi.dot(Lc),u=a*l-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,f=(l*c-o*h)*d,g=(a*h-o*c)*d;return r.set(1-f-g,g,f)}static containsPoint(t,e,n,i){return this.getBarycoord(t,e,n,i,Si)===null?!1:Si.x>=0&&Si.y>=0&&Si.x+Si.y<=1}static getInterpolation(t,e,n,i,r,a,o,c){return this.getBarycoord(t,e,n,i,Si)===null?(c.x=0,c.y=0,"z"in c&&(c.z=0),"w"in c&&(c.w=0),null):(c.setScalar(0),c.addScaledVector(r,Si.x),c.addScaledVector(a,Si.y),c.addScaledVector(o,Si.z),c)}static getInterpolatedAttribute(t,e,n,i,r,a){return Fc.setScalar(0),zc.setScalar(0),Bc.setScalar(0),Fc.fromBufferAttribute(t,e),zc.fromBufferAttribute(t,n),Bc.fromBufferAttribute(t,i),a.setScalar(0),a.addScaledVector(Fc,r.x),a.addScaledVector(zc,r.y),a.addScaledVector(Bc,r.z),a}static isFrontFacing(t,e,n,i){return Hn.subVectors(n,e),yi.subVectors(t,e),Hn.cross(yi).dot(i)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,i){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[i]),this}setFromAttributeAndIndices(t,e,n,i){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,i),this}clone(){return new this.constructor().copy(this)}copy(t){return this.a.copy(t.a),this.b.copy(t.b),this.c.copy(t.c),this}getArea(){return Hn.subVectors(this.c,this.b),yi.subVectors(this.a,this.b),Hn.cross(yi).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return Fn.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return Fn.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,i,r){return Fn.getInterpolation(t,this.a,this.b,this.c,e,n,i,r)}containsPoint(t){return Fn.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return Fn.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,i=this.b,r=this.c;let a,o;Ws.subVectors(i,n),Xs.subVectors(r,n),Nc.subVectors(t,n);const c=Ws.dot(Nc),l=Xs.dot(Nc);if(c<=0&&l<=0)return e.copy(n);Oc.subVectors(t,i);const h=Ws.dot(Oc),u=Xs.dot(Oc);if(h>=0&&u<=h)return e.copy(i);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(Ws,a);Uc.subVectors(t,r);const f=Ws.dot(Uc),g=Xs.dot(Uc);if(g>=0&&f<=g)return e.copy(r);const v=f*l-c*g;if(v<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(Xs,o);const p=h*g-f*u;if(p<=0&&u-h>=0&&f-g>=0)return Od.subVectors(r,i),o=(u-h)/(u-h+(f-g)),e.copy(i).addScaledVector(Od,o);const m=1/(p+v+d);return a=v*m,o=d*m,e.copy(n).addScaledVector(Ws,a).addScaledVector(Xs,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class xi{constructor(t=new P(1/0,1/0,1/0),e=new P(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=t,this.max=e}set(t,e){return this.min.copy(t),this.max.copy(e),this}setFromArray(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e+=3)this.expandByPoint(Gn.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(Gn.fromBufferAttribute(t,e));return this}setFromPoints(t){this.makeEmpty();for(let e=0,n=t.length;e<n;e++)this.expandByPoint(t[e]);return this}setFromCenterAndSize(t,e){const n=Gn.copy(e).multiplyScalar(.5);return this.min.copy(t).sub(n),this.max.copy(t).add(n),this}setFromObject(t,e=!1){return this.makeEmpty(),this.expandByObject(t,e)}clone(){return new this.constructor().copy(this)}copy(t){return this.min.copy(t.min),this.max.copy(t.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(t){return this.isEmpty()?t.set(0,0,0):t.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(t){return this.isEmpty()?t.set(0,0,0):t.subVectors(this.max,this.min)}expandByPoint(t){return this.min.min(t),this.max.max(t),this}expandByVector(t){return this.min.sub(t),this.max.add(t),this}expandByScalar(t){return this.min.addScalar(-t),this.max.addScalar(t),this}expandByObject(t,e=!1){t.updateWorldMatrix(!1,!1);const n=t.geometry;if(n!==void 0){const r=n.getAttribute("position");if(e===!0&&r!==void 0&&t.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)t.isMesh===!0?t.getVertexPosition(a,Gn):Gn.fromBufferAttribute(r,a),Gn.applyMatrix4(t.matrixWorld),this.expandByPoint(Gn);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),ka.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),ka.copy(n.boundingBox)),ka.applyMatrix4(t.matrixWorld),this.union(ka)}const i=t.children;for(let r=0,a=i.length;r<a;r++)this.expandByObject(i[r],e);return this}containsPoint(t){return t.x>=this.min.x&&t.x<=this.max.x&&t.y>=this.min.y&&t.y<=this.max.y&&t.z>=this.min.z&&t.z<=this.max.z}containsBox(t){return this.min.x<=t.min.x&&t.max.x<=this.max.x&&this.min.y<=t.min.y&&t.max.y<=this.max.y&&this.min.z<=t.min.z&&t.max.z<=this.max.z}getParameter(t,e){return e.set((t.x-this.min.x)/(this.max.x-this.min.x),(t.y-this.min.y)/(this.max.y-this.min.y),(t.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(t){return t.max.x>=this.min.x&&t.min.x<=this.max.x&&t.max.y>=this.min.y&&t.min.y<=this.max.y&&t.max.z>=this.min.z&&t.min.z<=this.max.z}intersectsSphere(t){return this.clampPoint(t.center,Gn),Gn.distanceToSquared(t.center)<=t.radius*t.radius}intersectsPlane(t){let e,n;return t.normal.x>0?(e=t.normal.x*this.min.x,n=t.normal.x*this.max.x):(e=t.normal.x*this.max.x,n=t.normal.x*this.min.x),t.normal.y>0?(e+=t.normal.y*this.min.y,n+=t.normal.y*this.max.y):(e+=t.normal.y*this.max.y,n+=t.normal.y*this.min.y),t.normal.z>0?(e+=t.normal.z*this.min.z,n+=t.normal.z*this.max.z):(e+=t.normal.z*this.max.z,n+=t.normal.z*this.min.z),e<=-t.constant&&n>=-t.constant}intersectsTriangle(t){if(this.isEmpty())return!1;this.getCenter(Ur),Ha.subVectors(this.max,Ur),qs.subVectors(t.a,Ur),Ys.subVectors(t.b,Ur),Ks.subVectors(t.c,Ur),Ki.subVectors(Ys,qs),$i.subVectors(Ks,Ys),ds.subVectors(qs,Ks);let e=[0,-Ki.z,Ki.y,0,-$i.z,$i.y,0,-ds.z,ds.y,Ki.z,0,-Ki.x,$i.z,0,-$i.x,ds.z,0,-ds.x,-Ki.y,Ki.x,0,-$i.y,$i.x,0,-ds.y,ds.x,0];return!kc(e,qs,Ys,Ks,Ha)||(e=[1,0,0,0,1,0,0,0,1],!kc(e,qs,Ys,Ks,Ha))?!1:(Ga.crossVectors(Ki,$i),e=[Ga.x,Ga.y,Ga.z],kc(e,qs,Ys,Ks,Ha))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,Gn).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(Gn).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:(bi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),bi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),bi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),bi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),bi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),bi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),bi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),bi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(bi),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 bi=[new P,new P,new P,new P,new P,new P,new P,new P],Gn=new P,ka=new xi,qs=new P,Ys=new P,Ks=new P,Ki=new P,$i=new P,ds=new P,Ur=new P,Ha=new P,Ga=new P,fs=new P;function kc(s,t,e,n,i){for(let r=0,a=s.length-3;r<=a;r+=3){fs.fromArray(s,r);const o=i.x*Math.abs(fs.x)+i.y*Math.abs(fs.y)+i.z*Math.abs(fs.z),c=t.dot(fs),l=e.dot(fs),h=n.dot(fs);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const Ci=j1();function j1(){const s=new ArrayBuffer(4),t=new Float32Array(s),e=new Uint32Array(s),n=new Uint32Array(512),i=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,i[c]=24,i[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,i[c]=-l-1,i[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,i[c]=13,i[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,i[c]=24,i[c|256]=24):(n[c]=31744,n[c|256]=64512,i[c]=13,i[c|256]=13)}const r=new Uint32Array(2048),a=new Uint32Array(64),o=new Uint32Array(64);for(let c=1;c<1024;++c){let l=c<<13,h=0;for(;(l&8388608)===0;)l<<=1,h-=8388608;l&=-8388609,h+=947912704,r[c]=l|h}for(let c=1024;c<2048;++c)r[c]=939524096+(c-1024<<13);for(let c=1;c<31;++c)a[c]=c<<23;a[31]=1199570944,a[32]=2147483648;for(let c=33;c<63;++c)a[c]=2147483648+(c-32<<23);a[63]=3347054592;for(let c=1;c<64;++c)c!==32&&(o[c]=1024);return{floatView:t,uint32View:e,baseTable:n,shiftTable:i,mantissaTable:r,exponentTable:a,offsetTable:o}}function t2(s){Math.abs(s)>65504&&wt("DataUtils.toHalfFloat(): Value out of range."),s=Yt(s,-65504,65504),Ci.floatView[0]=s;const t=Ci.uint32View[0],e=t>>23&511;return Ci.baseTable[e]+((t&8388607)>>Ci.shiftTable[e])}function e2(s){const t=s>>10;return Ci.uint32View[0]=Ci.mantissaTable[Ci.offsetTable[t]+(s&1023)]+Ci.exponentTable[t],Ci.floatView[0]}class as{static toHalfFloat(t){return t2(t)}static fromHalfFloat(t){return e2(t)}}const Ue=new P,Va=new Pt;let n2=0;class de extends Ns{constructor(t,e,n=!1){if(super(),Array.isArray(t))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:n2++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=wh,this.updateRanges=[],this.gpuType=zn,this.version=0}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.name=t.name,this.array=new t.array.constructor(t.array),this.itemSize=t.itemSize,this.count=t.count,this.normalized=t.normalized,this.usage=t.usage,this.gpuType=t.gpuType,this}copyAt(t,e,n){t*=this.itemSize,n*=e.itemSize;for(let i=0,r=this.itemSize;i<r;i++)this.array[t+i]=e.array[n+i];return this}copyArray(t){return this.array.set(t),this}applyMatrix3(t){if(this.itemSize===2)for(let e=0,n=this.count;e<n;e++)Va.fromBufferAttribute(this,e),Va.applyMatrix3(t),this.setXY(e,Va.x,Va.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.applyMatrix3(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.applyMatrix4(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.applyNormalMatrix(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ue.fromBufferAttribute(this,e),Ue.transformDirection(t),this.setXYZ(e,Ue.x,Ue.y,Ue.z);return this}set(t,e=0){return this.array.set(t,e),this}getComponent(t,e){let n=this.array[t*this.itemSize+e];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Yn(e,this.array)),e}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Yn(e,this.array)),e}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+1]=e,this}getZ(t){let e=this.array[t*this.itemSize+2];return this.normalized&&(e=Yn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+2]=e,this}getW(t){let e=this.array[t*this.itemSize+3];return this.normalized&&(e=Yn(e,this.array)),e}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,i){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t*=this.itemSize,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=i,this.array[t+3]=r,this}onUpload(t){return this.onUploadCallback=t,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const t={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(t.name=this.name),this.usage!==wh&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class Ep extends de{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class xu extends de{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class Se extends de{constructor(t,e,n){super(new Float32Array(t),e,n)}}const i2=new xi,Fr=new P,Hc=new P;class zi{constructor(t=new P,e=-1){this.isSphere=!0,this.center=t,this.radius=e}set(t,e){return this.center.copy(t),this.radius=e,this}setFromPoints(t,e){const n=this.center;e!==void 0?n.copy(e):i2.setFromPoints(t).getCenter(n);let i=0;for(let r=0,a=t.length;r<a;r++)i=Math.max(i,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(i),this}copy(t){return this.center.copy(t.center),this.radius=t.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(t){return t.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(t){return t.distanceTo(this.center)-this.radius}intersectsSphere(t){const e=this.radius+t.radius;return t.center.distanceToSquared(this.center)<=e*e}intersectsBox(t){return t.intersectsSphere(this)}intersectsPlane(t){return Math.abs(t.distanceToPoint(this.center))<=this.radius}clampPoint(t,e){const n=this.center.distanceToSquared(t);return e.copy(t),n>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center)),e}getBoundingBox(t){return this.isEmpty()?(t.makeEmpty(),t):(t.set(this.center,this.center),t.expandByScalar(this.radius),t)}applyMatrix4(t){return this.center.applyMatrix4(t),this.radius=this.radius*t.getMaxScaleOnAxis(),this}translate(t){return this.center.add(t),this}expandByPoint(t){if(this.isEmpty())return this.center.copy(t),this.radius=0,this;Fr.subVectors(t,this.center);const e=Fr.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),i=(n-this.radius)*.5;this.center.addScaledVector(Fr,i/n),this.radius+=i}return this}union(t){return t.isEmpty()?this:this.isEmpty()?(this.copy(t),this):(this.center.equals(t.center)===!0?this.radius=Math.max(this.radius,t.radius):(Hc.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Fr.copy(t.center).add(Hc)),this.expandByPoint(Fr.copy(t.center).sub(Hc))),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 s2=0;const In=new Xt,Gc=new _e,$s=new P,wn=new xi,zr=new xi,We=new P;class be extends Ns{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:s2++}),this.uuid=$n(),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(_1(t)?xu:Ep)(t,1):this.index=t,this}setIndirect(t,e=0){return this.indirect=t,this.indirectOffset=e,this}getIndirect(){return this.indirect}getAttribute(t){return this.attributes[t]}setAttribute(t,e){return this.attributes[t]=e,this}deleteAttribute(t){return delete this.attributes[t],this}hasAttribute(t){return this.attributes[t]!==void 0}addGroup(t,e,n=0){this.groups.push({start:t,count:e,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(t,e){this.drawRange.start=t,this.drawRange.count=e}applyMatrix4(t){const e=this.attributes.position;e!==void 0&&(e.applyMatrix4(t),e.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new Bt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const i=this.attributes.tangent;return i!==void 0&&(i.transformDirection(t),i.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return In.makeRotationFromQuaternion(t),this.applyMatrix4(In),this}rotateX(t){return In.makeRotationX(t),this.applyMatrix4(In),this}rotateY(t){return In.makeRotationY(t),this.applyMatrix4(In),this}rotateZ(t){return In.makeRotationZ(t),this.applyMatrix4(In),this}translate(t,e,n){return In.makeTranslation(t,e,n),this.applyMatrix4(In),this}scale(t,e,n){return In.makeScale(t,e,n),this.applyMatrix4(In),this}lookAt(t){return Gc.lookAt(t),Gc.updateMatrix(),this.applyMatrix4(Gc.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter($s).negate(),this.translate($s.x,$s.y,$s.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let i=0,r=t.length;i<r;i++){const a=t[i];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new Se(n,3))}else{const n=Math.min(t.length,e.count);for(let i=0;i<n;i++){const r=t[i];e.setXYZ(i,r.x,r.y,r.z||0)}t.length>e.count&&wt("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),e.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new xi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new P(-1/0,-1/0,-1/0),new P(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,i=e.length;n<i;n++){const r=e[n];wn.setFromBufferAttribute(r),this.morphTargetsRelative?(We.addVectors(this.boundingBox.min,wn.min),this.boundingBox.expandByPoint(We),We.addVectors(this.boundingBox.max,wn.max),this.boundingBox.expandByPoint(We)):(this.boundingBox.expandByPoint(wn.min),this.boundingBox.expandByPoint(wn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&zt('BufferGeometry.computeBoundingBox(): Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new zi);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){zt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new P,1/0);return}if(t){const n=this.boundingSphere.center;if(wn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];zr.setFromBufferAttribute(o),this.morphTargetsRelative?(We.addVectors(wn.min,zr.min),wn.expandByPoint(We),We.addVectors(wn.max,zr.max),wn.expandByPoint(We)):(wn.expandByPoint(zr.min),wn.expandByPoint(zr.max))}wn.getCenter(n);let i=0;for(let r=0,a=t.count;r<a;r++)We.fromBufferAttribute(t,r),i=Math.max(i,n.distanceToSquared(We));if(e)for(let r=0,a=e.length;r<a;r++){const o=e[r],c=this.morphTargetsRelative;for(let l=0,h=o.count;l<h;l++)We.fromBufferAttribute(o,l),c&&($s.fromBufferAttribute(t,l),We.add($s)),i=Math.max(i,n.distanceToSquared(We))}this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&zt('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const t=this.index,e=this.attributes;if(t===null||e.position===void 0||e.normal===void 0||e.uv===void 0){zt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,i=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new de(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let _=0;_<n.count;_++)o[_]=new P,c[_]=new P;const l=new P,h=new P,u=new P,d=new Pt,f=new Pt,g=new Pt,v=new P,p=new P;function m(_,A,C){l.fromBufferAttribute(n,_),h.fromBufferAttribute(n,A),u.fromBufferAttribute(n,C),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,A),g.fromBufferAttribute(r,C),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const D=1/(f.x*g.y-g.x*f.y);isFinite(D)&&(v.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(D),p.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(D),o[_].add(v),o[A].add(v),o[C].add(v),c[_].add(p),c[A].add(p),c[C].add(p))}let b=this.groups;b.length===0&&(b=[{start:0,count:t.count}]);for(let _=0,A=b.length;_<A;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)m(t.getX(V+0),t.getX(V+1),t.getX(V+2))}const E=new P,M=new P,S=new P,w=new P;function R(_){S.fromBufferAttribute(i,_),w.copy(S);const A=o[_];E.copy(A),E.sub(S.multiplyScalar(S.dot(A))).normalize(),M.crossVectors(w,A);const D=M.dot(c[_])<0?-1:1;a.setXYZW(_,E.x,E.y,E.z,D)}for(let _=0,A=b.length;_<A;++_){const C=b[_],D=C.start,I=C.count;for(let V=D,q=D+I;V<q;V+=3)R(t.getX(V+0)),R(t.getX(V+1)),R(t.getX(V+2))}this._transformed=!0}computeVertexNormals(){const t=this.index,e=this.getAttribute("position");if(e!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==e.count)n=new de(new Float32Array(e.count*3),3),this.setAttribute("normal",n);else for(let d=0,f=n.count;d<f;d++)n.setXYZ(d,0,0,0);const i=new P,r=new P,a=new P,o=new P,c=new P,l=new P,h=new P,u=new P;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),v=t.getX(d+1),p=t.getX(d+2);i.fromBufferAttribute(e,g),r.fromBufferAttribute(e,v),a.fromBufferAttribute(e,p),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,v),l.fromBufferAttribute(n,p),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(v,c.x,c.y,c.z),n.setXYZ(p,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)i.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(i,r),h.cross(u),n.setXYZ(d+0,h.x,h.y,h.z),n.setXYZ(d+1,h.x,h.y,h.z),n.setXYZ(d+2,h.x,h.y,h.z);this.normalizeNormals(),n.needsUpdate=!0}}normalizeNormals(){const t=this.attributes.normal;for(let e=0,n=t.count;e<n;e++)We.fromBufferAttribute(t,e),We.normalize(),t.setXYZ(e,We.x,We.y,We.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,g=0;for(let v=0,p=c.length;v<p;v++){o.isInterleavedBufferAttribute?f=c[v]*o.data.stride+o.offset:f=c[v]*h;for(let m=0;m<h;m++)d[g++]=l[f++]}return new de(d,h,u)}if(this.index===null)return wt("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new be,n=this.index.array,i=this.attributes;for(const o in i){const c=i[o],l=t(c,n);e.setAttribute(o,l)}const r=this.morphAttributes;for(const o in r){const c=[],l=r[o];for(let h=0,u=l.length;h<u;h++){const d=l[h],f=t(d,n);c.push(f)}e.morphAttributes[o]=c}e.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,c=a.length;o<c;o++){const l=a[o];e.addGroup(l.start,l.count,l.materialIndex)}return e}toJSON(){const t={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(t.uuid=this.uuid,t.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(t.name=this.name),Object.keys(this.userData).length>0&&(t.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const c=this.parameters;for(const l in c)c[l]!==void 0&&(t[l]=c[l]);return t}t.data={attributes:{}};const e=this.index;e!==null&&(t.data.index={type:e.array.constructor.name,array:Array.prototype.slice.call(e.array)});const n=this.attributes;for(const c in n){const l=n[c];t.data.attributes[c]=l.toJSON(t.data)}const i={};let r=!1;for(const c in this.morphAttributes){const l=this.morphAttributes[c],h=[];for(let u=0,d=l.length;u<d;u++){const f=l[u];h.push(f.toJSON(t.data))}h.length>0&&(i[c]=h,r=!0)}r&&(t.data.morphAttributes=i,t.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(t.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(t.data.boundingSphere=o.toJSON()),t}clone(){return new this.constructor().copy(this)}copy(t){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const e={};this.name=t.name;const n=t.index;n!==null&&this.setIndex(n.clone());const i=t.attributes;for(const l in i){const h=i[l];this.setAttribute(l,h.clone(e))}const r=t.morphAttributes;for(const l in r){const h=[],u=r[l];for(let d=0,f=u.length;d<f;d++)h.push(u[d].clone(e));this.morphAttributes[l]=h}this.morphTargetsRelative=t.morphTargetsRelative;const a=t.groups;for(let l=0,h=a.length;l<h;l++){const u=a[l];this.addGroup(u.start,u.count,u.materialIndex)}const o=t.boundingBox;o!==null&&(this.boundingBox=o.clone());const c=t.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.drawRange.start=t.drawRange.start,this.drawRange.count=t.drawRange.count,this.userData=t.userData,this._transformed=t._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class r2{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=wh,this.updateRanges=[],this.version=0,this.uuid=$n()}onUploadCallback(){}set needsUpdate(t){t===!0&&this.version++}setUsage(t){return this.usage=t,this}addUpdateRange(t,e){this.updateRanges.push({start:t,count:e})}clearUpdateRanges(){this.updateRanges.length=0}copy(t){return this.array=new t.array.constructor(t.array),this.count=t.count,this.stride=t.stride,this.usage=t.usage,this}copyAt(t,e,n){t*=this.stride,n*=e.stride;for(let i=0,r=this.stride;i<r;i++)this.array[t+i]=e.array[n+i];return this}set(t,e=0){return this.array.set(t,e),this}clone(t){t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$n()),t.arrayBuffers[this.array.buffer._uuid]===void 0&&(t.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const e=new this.array.constructor(t.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(e,this.stride);return n.setUsage(this.usage),n}onUpload(t){return this.onUploadCallback=t,this}toJSON(t){return t.arrayBuffers===void 0&&(t.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=$n()),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 sn=new P;class Qo{constructor(t,e,n,i=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=i}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(t){this.data.needsUpdate=t}applyMatrix4(t){for(let e=0,n=this.data.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyMatrix4(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.applyNormalMatrix(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)sn.fromBufferAttribute(this,e),sn.transformDirection(t),this.setXYZ(e,sn.x,sn.y,sn.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Yn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=re(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=re(e,this.array)),this.data.array[t*this.data.stride+this.offset+3]=e,this}getX(t){let e=this.data.array[t*this.data.stride+this.offset];return this.normalized&&(e=Yn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Yn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Yn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Yn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,i){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this}setXYZW(t,e,n,i,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=re(e,this.array),n=re(n,this.array),i=re(i,this.array),r=re(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=i,this.data.array[t+3]=r,this}clone(t){if(t===void 0){Jo("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return new de(new this.array.constructor(e),this.itemSize,this.normalized)}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.clone(t)),new Qo(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Jo("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const i=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[i+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:e,normalized:this.normalized}}else return t.interleavedBuffers===void 0&&(t.interleavedBuffers={}),t.interleavedBuffers[this.data.uuid]===void 0&&(t.interleavedBuffers[this.data.uuid]=this.data.toJSON(t)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let a2=0;class Bi extends Ns{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:a2++}),this.uuid=$n(),this.name="",this.type="Material",this.blending=mr,this.side=cs,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=zl,this.blendDst=Bl,this.blendEquation=ys,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new vt(0,0,0),this.blendAlpha=0,this.depthFunc=br,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=yd,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Bs,this.stencilZFail=Bs,this.stencilZPass=Bs,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(t){this._alphaTest>0!=t>0&&this.version++,this._alphaTest=t}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(t){if(t!==void 0)for(const e in t){const n=t[e];if(n===void 0){wt(`Material: parameter '${e}' has value of undefined.`);continue}const i=this[e];if(i===void 0){wt(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}i&&i.isColor?i.set(n):i&&i.isVector2&&n&&n.isVector2||i&&i.isEuler&&n&&n.isEuler||i&&i.isVector3&&n&&n.isVector3?i.copy(n):this[e]=n}}toJSON(t){const e=t===void 0||typeof t=="string";e&&(t={textures:{},images:{}});const n={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.color&&this.color.isColor&&(n.color=this.color.getHex()),this.roughness!==void 0&&(n.roughness=this.roughness),this.metalness!==void 0&&(n.metalness=this.metalness),this.sheen!==void 0&&(n.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(n.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(n.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(n.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(n.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(n.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(n.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(n.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(n.shininess=this.shininess),this.clearcoat!==void 0&&(n.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(n.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(n.clearcoatMap=this.clearcoatMap.toJSON(t).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(t).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(t).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(t).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(t).uuid),this.dispersion!==void 0&&(n.dispersion=this.dispersion),this.iridescence!==void 0&&(n.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(n.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(n.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(n.iridescenceMap=this.iridescenceMap.toJSON(t).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(t).uuid),this.anisotropy!==void 0&&(n.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(n.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(n.anisotropyMap=this.anisotropyMap.toJSON(t).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(t).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(t).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(t).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(t).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(t).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(t).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(t).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(t).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(t).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(t).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(t).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(t).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(t).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(t).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(t).uuid,this.combine!==void 0&&(n.combine=this.combine)),this.envMapRotation!==void 0&&(n.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(n.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(n.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(n.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(n.gradientMap=this.gradientMap.toJSON(t).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(t).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(t).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(n.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(n.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(n.size=this.size),this.shadowSide!==null&&(n.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(n.sizeAttenuation=this.sizeAttenuation),this.blending!==mr&&(n.blending=this.blending),this.side!==cs&&(n.side=this.side),this.vertexColors===!0&&(n.vertexColors=!0),this.opacity<1&&(n.opacity=this.opacity),this.transparent===!0&&(n.transparent=!0),this.blendSrc!==zl&&(n.blendSrc=this.blendSrc),this.blendDst!==Bl&&(n.blendDst=this.blendDst),this.blendEquation!==ys&&(n.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(n.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(n.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(n.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(n.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(n.blendAlpha=this.blendAlpha),this.depthFunc!==br&&(n.depthFunc=this.depthFunc),this.depthTest===!1&&(n.depthTest=this.depthTest),this.depthWrite===!1&&(n.depthWrite=this.depthWrite),this.colorWrite===!1&&(n.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(n.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yd&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Bs&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Bs&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Bs&&(n.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(n.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(n.rotation=this.rotation),this.polygonOffset===!0&&(n.polygonOffset=!0),this.polygonOffsetFactor!==0&&(n.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(n.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(n.linewidth=this.linewidth),this.dashSize!==void 0&&(n.dashSize=this.dashSize),this.gapSize!==void 0&&(n.gapSize=this.gapSize),this.scale!==void 0&&(n.scale=this.scale),this.dithering===!0&&(n.dithering=!0),this.alphaTest>0&&(n.alphaTest=this.alphaTest),this.alphaHash===!0&&(n.alphaHash=!0),this.alphaToCoverage===!0&&(n.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(n.premultipliedAlpha=!0),this.forceSinglePass===!0&&(n.forceSinglePass=!0),this.allowOverride===!1&&(n.allowOverride=!1),this.wireframe===!0&&(n.wireframe=!0),this.wireframeLinewidth>1&&(n.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(n.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(n.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(n.flatShading=!0),this.visible===!1&&(n.visible=!1),this.toneMapped===!1&&(n.toneMapped=!1),this.fog===!1&&(n.fog=!1),Object.keys(this.userData).length>0&&(n.userData=this.userData);function i(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=i(t.textures),a=i(t.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(t,e){if(t.uuid!==void 0&&(this.uuid=t.uuid),t.name!==void 0&&(this.name=t.name),t.color!==void 0&&this.color!==void 0&&this.color.setHex(t.color),t.roughness!==void 0&&(this.roughness=t.roughness),t.metalness!==void 0&&(this.metalness=t.metalness),t.sheen!==void 0&&(this.sheen=t.sheen),t.sheenColor!==void 0&&(this.sheenColor=new vt().setHex(t.sheenColor)),t.sheenRoughness!==void 0&&(this.sheenRoughness=t.sheenRoughness),t.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(t.emissive),t.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(t.specular),t.specularIntensity!==void 0&&(this.specularIntensity=t.specularIntensity),t.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(t.specularColor),t.shininess!==void 0&&(this.shininess=t.shininess),t.clearcoat!==void 0&&(this.clearcoat=t.clearcoat),t.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=t.clearcoatRoughness),t.dispersion!==void 0&&(this.dispersion=t.dispersion),t.iridescence!==void 0&&(this.iridescence=t.iridescence),t.iridescenceIOR!==void 0&&(this.iridescenceIOR=t.iridescenceIOR),t.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=t.iridescenceThicknessRange),t.transmission!==void 0&&(this.transmission=t.transmission),t.thickness!==void 0&&(this.thickness=t.thickness),t.attenuationDistance!==void 0&&(this.attenuationDistance=t.attenuationDistance),t.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(t.attenuationColor),t.anisotropy!==void 0&&(this.anisotropy=t.anisotropy),t.anisotropyRotation!==void 0&&(this.anisotropyRotation=t.anisotropyRotation),t.fog!==void 0&&(this.fog=t.fog),t.flatShading!==void 0&&(this.flatShading=t.flatShading),t.blending!==void 0&&(this.blending=t.blending),t.combine!==void 0&&(this.combine=t.combine),t.side!==void 0&&(this.side=t.side),t.shadowSide!==void 0&&(this.shadowSide=t.shadowSide),t.opacity!==void 0&&(this.opacity=t.opacity),t.transparent!==void 0&&(this.transparent=t.transparent),t.alphaTest!==void 0&&(this.alphaTest=t.alphaTest),t.alphaHash!==void 0&&(this.alphaHash=t.alphaHash),t.depthFunc!==void 0&&(this.depthFunc=t.depthFunc),t.depthTest!==void 0&&(this.depthTest=t.depthTest),t.depthWrite!==void 0&&(this.depthWrite=t.depthWrite),t.colorWrite!==void 0&&(this.colorWrite=t.colorWrite),t.blendSrc!==void 0&&(this.blendSrc=t.blendSrc),t.blendDst!==void 0&&(this.blendDst=t.blendDst),t.blendEquation!==void 0&&(this.blendEquation=t.blendEquation),t.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=t.blendSrcAlpha),t.blendDstAlpha!==void 0&&(this.blendDstAlpha=t.blendDstAlpha),t.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=t.blendEquationAlpha),t.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(t.blendColor),t.blendAlpha!==void 0&&(this.blendAlpha=t.blendAlpha),t.stencilWriteMask!==void 0&&(this.stencilWriteMask=t.stencilWriteMask),t.stencilFunc!==void 0&&(this.stencilFunc=t.stencilFunc),t.stencilRef!==void 0&&(this.stencilRef=t.stencilRef),t.stencilFuncMask!==void 0&&(this.stencilFuncMask=t.stencilFuncMask),t.stencilFail!==void 0&&(this.stencilFail=t.stencilFail),t.stencilZFail!==void 0&&(this.stencilZFail=t.stencilZFail),t.stencilZPass!==void 0&&(this.stencilZPass=t.stencilZPass),t.stencilWrite!==void 0&&(this.stencilWrite=t.stencilWrite),t.wireframe!==void 0&&(this.wireframe=t.wireframe),t.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=t.wireframeLinewidth),t.wireframeLinecap!==void 0&&(this.wireframeLinecap=t.wireframeLinecap),t.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=t.wireframeLinejoin),t.rotation!==void 0&&(this.rotation=t.rotation),t.linewidth!==void 0&&(this.linewidth=t.linewidth),t.dashSize!==void 0&&(this.dashSize=t.dashSize),t.gapSize!==void 0&&(this.gapSize=t.gapSize),t.scale!==void 0&&(this.scale=t.scale),t.polygonOffset!==void 0&&(this.polygonOffset=t.polygonOffset),t.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=t.polygonOffsetFactor),t.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=t.polygonOffsetUnits),t.dithering!==void 0&&(this.dithering=t.dithering),t.alphaToCoverage!==void 0&&(this.alphaToCoverage=t.alphaToCoverage),t.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=t.premultipliedAlpha),t.forceSinglePass!==void 0&&(this.forceSinglePass=t.forceSinglePass),t.allowOverride!==void 0&&(this.allowOverride=t.allowOverride),t.visible!==void 0&&(this.visible=t.visible),t.toneMapped!==void 0&&(this.toneMapped=t.toneMapped),t.userData!==void 0&&(this.userData=t.userData),t.vertexColors!==void 0&&(typeof t.vertexColors=="number"?this.vertexColors=t.vertexColors>0:this.vertexColors=t.vertexColors),t.size!==void 0&&(this.size=t.size),t.sizeAttenuation!==void 0&&(this.sizeAttenuation=t.sizeAttenuation),t.map!==void 0&&(this.map=e[t.map]||null),t.matcap!==void 0&&(this.matcap=e[t.matcap]||null),t.alphaMap!==void 0&&(this.alphaMap=e[t.alphaMap]||null),t.bumpMap!==void 0&&(this.bumpMap=e[t.bumpMap]||null),t.bumpScale!==void 0&&(this.bumpScale=t.bumpScale),t.normalMap!==void 0&&(this.normalMap=e[t.normalMap]||null),t.normalMapType!==void 0&&(this.normalMapType=t.normalMapType),t.normalScale!==void 0){let n=t.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Pt().fromArray(n)}return t.displacementMap!==void 0&&(this.displacementMap=e[t.displacementMap]||null),t.displacementScale!==void 0&&(this.displacementScale=t.displacementScale),t.displacementBias!==void 0&&(this.displacementBias=t.displacementBias),t.roughnessMap!==void 0&&(this.roughnessMap=e[t.roughnessMap]||null),t.metalnessMap!==void 0&&(this.metalnessMap=e[t.metalnessMap]||null),t.emissiveMap!==void 0&&(this.emissiveMap=e[t.emissiveMap]||null),t.emissiveIntensity!==void 0&&(this.emissiveIntensity=t.emissiveIntensity),t.specularMap!==void 0&&(this.specularMap=e[t.specularMap]||null),t.specularIntensityMap!==void 0&&(this.specularIntensityMap=e[t.specularIntensityMap]||null),t.specularColorMap!==void 0&&(this.specularColorMap=e[t.specularColorMap]||null),t.envMap!==void 0&&(this.envMap=e[t.envMap]||null),t.envMapRotation!==void 0&&this.envMapRotation.fromArray(t.envMapRotation),t.envMapIntensity!==void 0&&(this.envMapIntensity=t.envMapIntensity),t.reflectivity!==void 0&&(this.reflectivity=t.reflectivity),t.refractionRatio!==void 0&&(this.refractionRatio=t.refractionRatio),t.lightMap!==void 0&&(this.lightMap=e[t.lightMap]||null),t.lightMapIntensity!==void 0&&(this.lightMapIntensity=t.lightMapIntensity),t.aoMap!==void 0&&(this.aoMap=e[t.aoMap]||null),t.aoMapIntensity!==void 0&&(this.aoMapIntensity=t.aoMapIntensity),t.gradientMap!==void 0&&(this.gradientMap=e[t.gradientMap]||null),t.clearcoatMap!==void 0&&(this.clearcoatMap=e[t.clearcoatMap]||null),t.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=e[t.clearcoatRoughnessMap]||null),t.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=e[t.clearcoatNormalMap]||null),t.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Pt().fromArray(t.clearcoatNormalScale)),t.iridescenceMap!==void 0&&(this.iridescenceMap=e[t.iridescenceMap]||null),t.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=e[t.iridescenceThicknessMap]||null),t.transmissionMap!==void 0&&(this.transmissionMap=e[t.transmissionMap]||null),t.thicknessMap!==void 0&&(this.thicknessMap=e[t.thicknessMap]||null),t.anisotropyMap!==void 0&&(this.anisotropyMap=e[t.anisotropyMap]||null),t.sheenColorMap!==void 0&&(this.sheenColorMap=e[t.sheenColorMap]||null),t.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=e[t.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(t){this.name=t.name,this.blending=t.blending,this.side=t.side,this.vertexColors=t.vertexColors,this.opacity=t.opacity,this.transparent=t.transparent,this.blendSrc=t.blendSrc,this.blendDst=t.blendDst,this.blendEquation=t.blendEquation,this.blendSrcAlpha=t.blendSrcAlpha,this.blendDstAlpha=t.blendDstAlpha,this.blendEquationAlpha=t.blendEquationAlpha,this.blendColor.copy(t.blendColor),this.blendAlpha=t.blendAlpha,this.depthFunc=t.depthFunc,this.depthTest=t.depthTest,this.depthWrite=t.depthWrite,this.stencilWriteMask=t.stencilWriteMask,this.stencilFunc=t.stencilFunc,this.stencilRef=t.stencilRef,this.stencilFuncMask=t.stencilFuncMask,this.stencilFail=t.stencilFail,this.stencilZFail=t.stencilZFail,this.stencilZPass=t.stencilZPass,this.stencilWrite=t.stencilWrite;const e=t.clippingPlanes;let n=null;if(e!==null){const i=e.length;n=new Array(i);for(let r=0;r!==i;++r)n[r]=e[r].clone()}return this.clippingPlanes=n,this.clipIntersection=t.clipIntersection,this.clipShadows=t.clipShadows,this.shadowSide=t.shadowSide,this.colorWrite=t.colorWrite,this.precision=t.precision,this.polygonOffset=t.polygonOffset,this.polygonOffsetFactor=t.polygonOffsetFactor,this.polygonOffsetUnits=t.polygonOffsetUnits,this.dithering=t.dithering,this.alphaTest=t.alphaTest,this.alphaHash=t.alphaHash,this.alphaToCoverage=t.alphaToCoverage,this.premultipliedAlpha=t.premultipliedAlpha,this.forceSinglePass=t.forceSinglePass,this.allowOverride=t.allowOverride,this.visible=t.visible,this.toneMapped=t.toneMapped,this.userData=JSON.parse(JSON.stringify(t.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(t){t===!0&&this.version++}}class ta extends Bi{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new vt(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 Zs;const Br=new P,Js=new P,Qs=new P,js=new Pt,kr=new Pt,wp=new Xt,Wa=new P,Hr=new P,Xa=new P,Ud=new Pt,Vc=new Pt,Fd=new Pt;class qa extends _e{constructor(t=new ta){if(super(),this.isSprite=!0,this.type="Sprite",Zs===void 0){Zs=new be;const e=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new r2(e,5);Zs.setIndex([0,1,2,0,2,3]),Zs.setAttribute("position",new Qo(n,3,0,!1)),Zs.setAttribute("uv",new Qo(n,2,3,!1))}this.geometry=Zs,this.material=t,this.center=new Pt(.5,.5),this.count=1}raycast(t,e){t.camera===null&&zt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Js.setFromMatrixScale(this.matrixWorld),wp.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),Qs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Js.multiplyScalar(-Qs.z);const n=this.material.rotation;let i,r;n!==0&&(r=Math.cos(n),i=Math.sin(n));const a=this.center;Ya(Wa.set(-.5,-.5,0),Qs,a,Js,i,r),Ya(Hr.set(.5,-.5,0),Qs,a,Js,i,r),Ya(Xa.set(.5,.5,0),Qs,a,Js,i,r),Ud.set(0,0),Vc.set(1,0),Fd.set(1,1);let o=t.ray.intersectTriangle(Wa,Hr,Xa,!1,Br);if(o===null&&(Ya(Hr.set(-.5,.5,0),Qs,a,Js,i,r),Vc.set(0,1),o=t.ray.intersectTriangle(Wa,Xa,Hr,!1,Br),o===null))return;const c=t.ray.origin.distanceTo(Br);c<t.near||c>t.far||e.push({distance:c,point:Br.clone(),uv:Fn.getInterpolation(Br,Wa,Hr,Xa,Ud,Vc,Fd,new Pt),face:null,object:this})}copy(t,e){return super.copy(t,e),t.center!==void 0&&this.center.copy(t.center),this.material=t.material,this}}function Ya(s,t,e,n,i,r){js.subVectors(s,e).addScalar(.5).multiply(n),i!==void 0?(kr.x=r*js.x-i*js.y,kr.y=i*js.x+r*js.y):kr.copy(js),s.copy(t),s.x+=kr.x,s.y+=kr.y,s.applyMatrix4(wp)}const Ei=new P,Wc=new P,Ka=new P,Zi=new P,Xc=new P,$a=new P,qc=new P;class ya{constructor(t=new P,e=new P(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,Ei)),this}closestPointToPoint(t,e){e.subVectors(t,this.origin);const n=e.dot(this.direction);return n<0?e.copy(this.origin):e.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(t){return Math.sqrt(this.distanceSqToPoint(t))}distanceSqToPoint(t){const e=Ei.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(Ei.copy(this.origin).addScaledVector(this.direction,e),Ei.distanceToSquared(t))}distanceSqToSegment(t,e,n,i){Wc.copy(t).add(e).multiplyScalar(.5),Ka.copy(e).sub(t).normalize(),Zi.copy(this.origin).sub(Wc);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Ka),o=Zi.dot(this.direction),c=-Zi.dot(Ka),l=Zi.lengthSq(),h=Math.abs(1-a*a);let u,d,f,g;if(h>0)if(u=a*c-o,d=a*o-c,g=r*h,u>=0)if(d>=-g)if(d<=g){const v=1/h;u*=v,d*=v,f=u*(u+a*d+2*o)+d*(a*u+d+2*c)+l}else d=r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d=-r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l):d<=g?(u=0,d=Math.min(Math.max(-r,-c),r),f=d*(d+2*c)+l):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-c),r),f=-u*u+d*(d+2*c)+l);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),f=-u*u+d*(d+2*c)+l;return n&&n.copy(this.origin).addScaledVector(this.direction,u),i&&i.copy(Wc).addScaledVector(Ka,d),f}intersectSphere(t,e){Ei.subVectors(t.center,this.origin);const n=Ei.dot(this.direction),i=Ei.dot(Ei)-n*n,r=t.radius*t.radius;if(i>r)return null;const a=Math.sqrt(r-i),o=n-a,c=n+a;return c<0?null:o<0?this.at(c,e):this.at(o,e)}intersectsSphere(t){return t.radius<0?!1:this.distanceSqToPoint(t.center)<=t.radius*t.radius}distanceToPlane(t){const e=t.normal.dot(this.direction);if(e===0)return t.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(t.normal)+t.constant)/e;return n>=0?n:null}intersectPlane(t,e){const n=this.distanceToPlane(t);return n===null?null:this.at(n,e)}intersectsPlane(t){const e=t.distanceToPoint(this.origin);return e===0||t.normal.dot(this.direction)*e<0}intersectBox(t,e){let n,i,r,a,o,c;const l=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return l>=0?(n=(t.min.x-d.x)*l,i=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,i=(t.min.x-d.x)*l),h>=0?(r=(t.min.y-d.y)*h,a=(t.max.y-d.y)*h):(r=(t.max.y-d.y)*h,a=(t.min.y-d.y)*h),n>a||r>i||((r>n||isNaN(n))&&(n=r),(a<i||isNaN(i))&&(i=a),u>=0?(o=(t.min.z-d.z)*u,c=(t.max.z-d.z)*u):(o=(t.max.z-d.z)*u,c=(t.min.z-d.z)*u),n>c||o>i)||((o>n||n!==n)&&(n=o),(c<i||i!==i)&&(i=c),i<0)?null:this.at(n>=0?n:i,e)}intersectsBox(t){return this.intersectBox(t,Ei)!==null}intersectTriangle(t,e,n,i,r){Xc.subVectors(e,t),$a.subVectors(n,t),qc.crossVectors(Xc,$a);let a=this.direction.dot(qc),o;if(a>0){if(i)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Zi.subVectors(this.origin,t);const c=o*this.direction.dot($a.crossVectors(Zi,$a));if(c<0)return null;const l=o*this.direction.dot(Xc.cross(Zi));if(l<0||c+l>a)return null;const h=-o*Zi.dot(qc);return h<0?null:this.at(h/a,r)}applyMatrix4(t){return this.origin.applyMatrix4(t),this.direction.transformDirection(t),this}equals(t){return t.origin.equals(this.origin)&&t.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Oi extends Bi{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new vt(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 Fi,this.combine=su,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 zd=new Xt,ps=new ya,Za=new zi,Bd=new P,Ja=new P,Qa=new P,ja=new P,Yc=new P,to=new P,kd=new P,eo=new P;class $t extends _e{constructor(t=new be,e=new Oi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),t.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=t.morphTargetInfluences.slice()),t.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},t.morphTargetDictionary)),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,i=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(i,t);const o=this.morphTargetInfluences;if(r&&o){to.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Yc.fromBufferAttribute(u,t),a?to.addScaledVector(Yc,h):to.addScaledVector(Yc.sub(e),h))}e.add(to)}return e}raycast(t,e){const n=this.geometry,i=this.material,r=this.matrixWorld;i!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),Za.copy(n.boundingSphere),Za.applyMatrix4(r),ps.copy(t.ray).recast(t.near),!(Za.containsPoint(ps.origin)===!1&&(ps.intersectSphere(Za,Bd)===null||ps.origin.distanceToSquared(Bd)>(t.far-t.near)**2))&&(zd.copy(r).invert(),ps.copy(t.ray).applyMatrix4(zd),!(n.boundingBox!==null&&ps.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,ps)))}_computeIntersections(t,e,n){let i;const r=this.geometry,a=this.material,o=r.index,c=r.attributes.position,l=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const p=d[g],m=a[p.materialIndex],b=Math.max(p.start,f.start),E=Math.min(o.count,Math.min(p.start+p.count,f.start+f.count));for(let M=b,S=E;M<S;M+=3){const w=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);i=no(this,m,t,n,l,h,u,w,R,_),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=p.materialIndex,e.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(o.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const b=o.getX(p),E=o.getX(p+1),M=o.getX(p+2);i=no(this,a,t,n,l,h,u,b,E,M),i&&(i.faceIndex=Math.floor(p/3),e.push(i))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,v=d.length;g<v;g++){const p=d[g],m=a[p.materialIndex],b=Math.max(p.start,f.start),E=Math.min(c.count,Math.min(p.start+p.count,f.start+f.count));for(let M=b,S=E;M<S;M+=3){const w=M,R=M+1,_=M+2;i=no(this,m,t,n,l,h,u,w,R,_),i&&(i.faceIndex=Math.floor(M/3),i.face.materialIndex=p.materialIndex,e.push(i))}}else{const g=Math.max(0,f.start),v=Math.min(c.count,f.start+f.count);for(let p=g,m=v;p<m;p+=3){const b=p,E=p+1,M=p+2;i=no(this,a,t,n,l,h,u,b,E,M),i&&(i.faceIndex=Math.floor(p/3),e.push(i))}}}}function o2(s,t,e,n,i,r,a,o){let c;if(t.side===Be?c=n.intersectTriangle(a,r,i,!0,o):c=n.intersectTriangle(i,r,a,t.side===cs,o),c===null)return null;eo.copy(o),eo.applyMatrix4(s.matrixWorld);const l=e.ray.origin.distanceTo(eo);return l<e.near||l>e.far?null:{distance:l,point:eo.clone(),object:s}}function no(s,t,e,n,i,r,a,o,c,l){s.getVertexPosition(o,Ja),s.getVertexPosition(c,Qa),s.getVertexPosition(l,ja);const h=o2(s,t,e,n,Ja,Qa,ja,kd);if(h){const u=new P;Fn.getBarycoord(kd,Ja,Qa,ja,u),i&&(h.uv=Fn.getInterpolatedAttribute(i,o,c,l,u,new Pt)),r&&(h.uv1=Fn.getInterpolatedAttribute(r,o,c,l,u,new Pt)),a&&(h.normal=Fn.getInterpolatedAttribute(a,o,c,l,u,new P),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new P,materialIndex:0};Fn.getNormal(Ja,Qa,ja,d.normal),h.face=d,h.barycoord=u}return h}const Gr=new le,Hd=new le,Gd=new le,c2=new le,Vd=new Xt,io=new P,Kc=new zi,Wd=new Xt,$c=new ya;class WE extends $t{constructor(t,e){super(t,e),this.isSkinnedMesh=!0,this.type="SkinnedMesh",this.bindMode=gd,this.bindMatrix=new Xt,this.bindMatrixInverse=new Xt,this.boundingBox=null,this.boundingSphere=null}computeBoundingBox(){const t=this.geometry;this.boundingBox===null&&(this.boundingBox=new xi),this.boundingBox.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,io),this.boundingBox.expandByPoint(io)}computeBoundingSphere(){const t=this.geometry;this.boundingSphere===null&&(this.boundingSphere=new zi),this.boundingSphere.makeEmpty();const e=t.getAttribute("position");for(let n=0;n<e.count;n++)this.getVertexPosition(n,io),this.boundingSphere.expandByPoint(io)}copy(t,e){return super.copy(t,e),this.bindMode=t.bindMode,this.bindMatrix.copy(t.bindMatrix),this.bindMatrixInverse.copy(t.bindMatrixInverse),this.skeleton=t.skeleton,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}raycast(t,e){const n=this.material,i=this.matrixWorld;n!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Kc.copy(this.boundingSphere),Kc.applyMatrix4(i),t.ray.intersectsSphere(Kc)!==!1&&(Wd.copy(i).invert(),$c.copy(t.ray).applyMatrix4(Wd),!(this.boundingBox!==null&&$c.intersectsBox(this.boundingBox)===!1)&&this._computeIntersections(t,e,$c)))}getVertexPosition(t,e){return super.getVertexPosition(t,e),this.applyBoneTransform(t,e),e}bind(t,e){this.skeleton=t,e===void 0&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),e=this.matrixWorld),this.bindMatrix.copy(e),this.bindMatrixInverse.copy(e).invert()}pose(){this.skeleton.pose()}normalizeSkinWeights(){const t=new le,e=this.geometry.attributes.skinWeight;for(let n=0,i=e.count;n<i;n++){t.fromBufferAttribute(e,n);const r=1/t.manhattanLength();r!==1/0?t.multiplyScalar(r):t.set(1,0,0,0),e.setXYZW(n,t.x,t.y,t.z,t.w)}}updateMatrixWorld(t){super.updateMatrixWorld(t),this.bindMode===gd?this.bindMatrixInverse.copy(this.matrixWorld).invert():this.bindMode===c1?this.bindMatrixInverse.copy(this.bindMatrix).invert():wt("SkinnedMesh: Unrecognized bindMode: "+this.bindMode)}applyBoneTransform(t,e){const n=this.skeleton,i=this.geometry;Hd.fromBufferAttribute(i.attributes.skinIndex,t),Gd.fromBufferAttribute(i.attributes.skinWeight,t),e.isVector4?(Gr.copy(e),e.set(0,0,0,0)):(Gr.set(...e,1),e.set(0,0,0)),Gr.applyMatrix4(this.bindMatrix);for(let r=0;r<4;r++){const a=Gd.getComponent(r);if(a!==0){const o=Hd.getComponent(r);Vd.multiplyMatrices(n.bones[o].matrixWorld,n.boneInverses[o]),e.addScaledVector(c2.copy(Gr).applyMatrix4(Vd),a)}}return e.isVector4&&(e.w=Gr.w),e.applyMatrix4(this.bindMatrixInverse)}}class l2 extends _e{constructor(){super(),this.isBone=!0,this.type="Bone"}}class Dr extends $e{constructor(t=null,e=1,n=1,i,r,a,o,c,l=ke,h=ke,u,d){super(null,a,o,c,l,h,i,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Xd=new Xt,h2=new Xt;class Ap{constructor(t=[],e=[]){this.uuid=$n(),this.bones=t.slice(0),this.boneInverses=e,this.boneMatrices=null,this.boneTexture=null,this.init()}init(){const t=this.bones,e=this.boneInverses;if(this.boneMatrices=new Float32Array(t.length*16),e.length===0)this.calculateInverses();else if(t.length!==e.length){wt("Skeleton: Number of inverse bone matrices does not match amount of bones."),this.boneInverses=[];for(let n=0,i=this.bones.length;n<i;n++)this.boneInverses.push(new Xt)}}calculateInverses(){this.boneInverses.length=0;for(let t=0,e=this.bones.length;t<e;t++){const n=new Xt;this.bones[t]&&n.copy(this.bones[t].matrixWorld).invert(),this.boneInverses.push(n)}}pose(){for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&n.matrixWorld.copy(this.boneInverses[t]).invert()}for(let t=0,e=this.bones.length;t<e;t++){const n=this.bones[t];n&&(n.parent&&n.parent.isBone?(n.matrix.copy(n.parent.matrixWorld).invert(),n.matrix.multiply(n.matrixWorld)):n.matrix.copy(n.matrixWorld),n.matrix.decompose(n.position,n.quaternion,n.scale))}}update(){const t=this.bones,e=this.boneInverses,n=this.boneMatrices,i=this.boneTexture;for(let r=0,a=t.length;r<a;r++){const o=t[r]?t[r].matrixWorld:h2;Xd.multiplyMatrices(o,e[r]),Xd.toArray(n,r*16)}i!==null&&(i.needsUpdate=!0)}clone(){return new Ap(this.bones,this.boneInverses)}computeBoneTexture(){let t=Math.sqrt(this.bones.length*4);t=Math.ceil(t/4)*4,t=Math.max(t,4);const e=new Float32Array(t*t*4);e.set(this.boneMatrices);const n=new Dr(e,t,t,fn,zn);return n.needsUpdate=!0,this.boneMatrices=e,this.boneTexture=n,this}getBoneByName(t){for(let e=0,n=this.bones.length;e<n;e++){const i=this.bones[e];if(i.name===t)return i}}dispose(){this.boneTexture!==null&&(this.boneTexture.dispose(),this.boneTexture=null)}fromJSON(t,e){this.uuid=t.uuid;for(let n=0,i=t.bones.length;n<i;n++){const r=t.bones[n];let a=e[r];a===void 0&&(wt("Skeleton: No bone found with UUID:",r),a=new l2),this.bones.push(a),this.boneInverses.push(new Xt().fromArray(t.boneInverses[n]))}return this.init(),this}toJSON(){const t={metadata:{version:4.7,type:"Skeleton",generator:"Skeleton.toJSON"},bones:[],boneInverses:[]};t.uuid=this.uuid;const e=this.bones,n=this.boneInverses;for(let i=0,r=e.length;i<r;i++){const a=e[i];t.bones.push(a.uuid);const o=n[i];t.boneInverses.push(o.toArray())}return t}}class qd extends de{constructor(t,e,n,i=1){super(t,e,n),this.isInstancedBufferAttribute=!0,this.meshPerAttribute=i}copy(t){return super.copy(t),this.meshPerAttribute=t.meshPerAttribute,this}toJSON(){const t=super.toJSON();return t.meshPerAttribute=this.meshPerAttribute,t.isInstancedBufferAttribute=!0,t}}const tr=new Xt,Yd=new Xt,so=[],Kd=new xi,u2=new Xt,Vr=new $t,Wr=new zi;class XE extends $t{constructor(t,e,n){super(t,e),this.isInstancedMesh=!0,this.instanceMatrix=new qd(new Float32Array(n*16),16),this.instanceColor=null,this.morphTexture=null,this.count=n,this.boundingBox=null,this.boundingSphere=null;for(let i=0;i<n;i++)this.setMatrixAt(i,u2)}computeBoundingBox(){const t=this.geometry,e=this.count;this.boundingBox===null&&(this.boundingBox=new xi),t.boundingBox===null&&t.computeBoundingBox(),this.boundingBox.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,tr),Kd.copy(t.boundingBox).applyMatrix4(tr),this.boundingBox.union(Kd)}computeBoundingSphere(){const t=this.geometry,e=this.count;this.boundingSphere===null&&(this.boundingSphere=new zi),t.boundingSphere===null&&t.computeBoundingSphere(),this.boundingSphere.makeEmpty();for(let n=0;n<e;n++)this.getMatrixAt(n,tr),Wr.copy(t.boundingSphere).applyMatrix4(tr),this.boundingSphere.union(Wr)}copy(t,e){return super.copy(t,e),this.instanceMatrix.copy(t.instanceMatrix),t.morphTexture!==null&&(this.morphTexture=t.morphTexture.clone()),t.instanceColor!==null&&(this.instanceColor=t.instanceColor.clone()),this.count=t.count,t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this}getColorAt(t,e){return this.instanceColor===null?e.setRGB(1,1,1):e.fromArray(this.instanceColor.array,t*3)}getMatrixAt(t,e){return e.fromArray(this.instanceMatrix.array,t*16)}getMorphAt(t,e){const n=e.morphTargetInfluences,i=this.morphTexture.source.data.data,r=n.length+1,a=t*r+1;for(let o=0;o<n.length;o++)n[o]=i[a+o]}raycast(t,e){const n=this.matrixWorld,i=this.count;if(Vr.geometry=this.geometry,Vr.material=this.material,Vr.material!==void 0&&(this.boundingSphere===null&&this.computeBoundingSphere(),Wr.copy(this.boundingSphere),Wr.applyMatrix4(n),t.ray.intersectsSphere(Wr)!==!1))for(let r=0;r<i;r++){this.getMatrixAt(r,tr),Yd.multiplyMatrices(n,tr),Vr.matrixWorld=Yd,Vr.raycast(t,so);for(let a=0,o=so.length;a<o;a++){const c=so[a];c.instanceId=r,c.object=this,e.push(c)}so.length=0}}setColorAt(t,e){return this.instanceColor===null&&(this.instanceColor=new qd(new Float32Array(this.instanceMatrix.count*3).fill(1),3)),e.toArray(this.instanceColor.array,t*3),this}setMatrixAt(t,e){return e.toArray(this.instanceMatrix.array,t*16),this}setMorphAt(t,e){const n=e.morphTargetInfluences,i=n.length+1;this.morphTexture===null&&(this.morphTexture=new Dr(new Float32Array(i*this.count),i,this.count,cu,zn));const r=this.morphTexture.source.data.data;let a=0;for(let l=0;l<n.length;l++)a+=n[l];const o=this.geometry.morphTargetsRelative?1:1-a,c=i*t;return r[c]=o,r.set(n,c+1),this}updateMorphTargets(){}dispose(){this.dispatchEvent({type:"dispose"}),this.morphTexture!==null&&(this.morphTexture.dispose(),this.morphTexture=null)}}const Zc=new P,d2=new P,f2=new Bt;class _s{constructor(t=new P(1,0,0),e=0){this.isPlane=!0,this.normal=t,this.constant=e}set(t,e){return this.normal.copy(t),this.constant=e,this}setComponents(t,e,n,i){return this.normal.set(t,e,n),this.constant=i,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const i=Zc.subVectors(n,e).cross(d2.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(i,t),this}copy(t){return this.normal.copy(t.normal),this.constant=t.constant,this}normalize(){const t=1/this.normal.length();return this.normal.multiplyScalar(t),this.constant*=t,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(t){return this.normal.dot(t)+this.constant}distanceToSphere(t){return this.distanceToPoint(t.center)-t.radius}projectPoint(t,e){return e.copy(t).addScaledVector(this.normal,-this.distanceToPoint(t))}intersectLine(t,e,n=!0){const i=t.delta(Zc),r=this.normal.dot(i);if(r===0)return this.distanceToPoint(t.start)===0?e.copy(t.start):null;const a=-(t.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:e.copy(t.start).addScaledVector(i,a)}intersectsLine(t){const e=this.distanceToPoint(t.start),n=this.distanceToPoint(t.end);return e<0&&n>0||n<0&&e>0}intersectsBox(t){return t.intersectsPlane(this)}intersectsSphere(t){return t.intersectsPlane(this)}coplanarPoint(t){return t.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(t,e){const n=e||f2.getNormalMatrix(t),i=this.coplanarPoint(Zc).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-i.dot(r),this}translate(t){return this.constant-=t.dot(this.normal),this}equals(t){return t.normal.equals(this.normal)&&t.constant===this.constant}clone(){return new this.constructor().copy(this)}}const ms=new zi,p2=new Pt(.5,.5),ro=new P;class _u{constructor(t=new _s,e=new _s,n=new _s,i=new _s,r=new _s,a=new _s){this.planes=[t,e,n,i,r,a]}set(t,e,n,i,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(i),o[4].copy(r),o[5].copy(a),this}copy(t){const e=this.planes;for(let n=0;n<6;n++)e[n].copy(t.planes[n]);return this}setFromProjectionMatrix(t,e=fi,n=!1){const i=this.planes,r=t.elements,a=r[0],o=r[1],c=r[2],l=r[3],h=r[4],u=r[5],d=r[6],f=r[7],g=r[8],v=r[9],p=r[10],m=r[11],b=r[12],E=r[13],M=r[14],S=r[15];if(i[0].setComponents(l-a,f-h,m-g,S-b).normalize(),i[1].setComponents(l+a,f+h,m+g,S+b).normalize(),i[2].setComponents(l+o,f+u,m+v,S+E).normalize(),i[3].setComponents(l-o,f-u,m-v,S-E).normalize(),n)i[4].setComponents(c,d,p,M).normalize(),i[5].setComponents(l-c,f-d,m-p,S-M).normalize();else if(i[4].setComponents(l-c,f-d,m-p,S-M).normalize(),e===fi)i[5].setComponents(l+c,f+d,m+p,S+M).normalize();else if(e===xa)i[5].setComponents(c,d,p,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(),ms.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),ms.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(ms)}intersectsSprite(t){ms.center.set(0,0,0);const e=p2.distanceTo(t.center);return ms.radius=.7071067811865476+e,ms.applyMatrix4(t.matrixWorld),this.intersectsSphere(ms)}intersectsSphere(t){const e=this.planes,n=t.center,i=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<i)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const i=e[n];if(ro.x=i.normal.x>0?t.max.x:t.min.x,ro.y=i.normal.y>0?t.max.y:t.min.y,ro.z=i.normal.z>0?t.max.z:t.min.z,i.distanceToPoint(ro)<0)return!1}return!0}containsPoint(t){const e=this.planes;for(let n=0;n<6;n++)if(e[n].distanceToPoint(t)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class m2 extends Bi{constructor(t){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new vt(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 jo=new P,tc=new P,$d=new Xt,Xr=new ya,ao=new zi,Jc=new P,Zd=new P;class Tp extends _e{constructor(t=new be,e=new m2){super(),this.isLine=!0,this.type="Line",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[0];for(let i=1,r=e.count;i<r;i++)jo.fromBufferAttribute(e,i-1),tc.fromBufferAttribute(e,i),n[i]=n[i-1],n[i]+=jo.distanceTo(tc);t.setAttribute("lineDistance",new Se(n,1))}else wt("Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Line.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),ao.copy(n.boundingSphere),ao.applyMatrix4(i),ao.radius+=r,t.ray.intersectsSphere(ao)===!1)return;$d.copy(i).invert(),Xr.copy(t.ray).applyMatrix4($d);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=this.isLineSegments?2:1,h=n.index,d=n.attributes.position;if(h!==null){const f=Math.max(0,a.start),g=Math.min(h.count,a.start+a.count);for(let v=f,p=g-1;v<p;v+=l){const m=h.getX(v),b=h.getX(v+1),E=oo(this,t,Xr,c,m,b,v);E&&e.push(E)}if(this.isLineLoop){const v=h.getX(g-1),p=h.getX(f),m=oo(this,t,Xr,c,v,p,g-1);m&&e.push(m)}}else{const f=Math.max(0,a.start),g=Math.min(d.count,a.start+a.count);for(let v=f,p=g-1;v<p;v+=l){const m=oo(this,t,Xr,c,v,v+1,v);m&&e.push(m)}if(this.isLineLoop){const v=oo(this,t,Xr,c,g-1,f,g-1);v&&e.push(v)}}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function oo(s,t,e,n,i,r,a){const o=s.geometry.attributes.position;if(jo.fromBufferAttribute(o,i),tc.fromBufferAttribute(o,r),e.distanceSqToSegment(jo,tc,Jc,Zd)>n)return;Jc.applyMatrix4(s.matrixWorld);const l=t.ray.origin.distanceTo(Jc);if(!(l<t.near||l>t.far))return{distance:l,point:Zd.clone().applyMatrix4(s.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:s}}const Jd=new P,Qd=new P;class qE extends Tp{constructor(t,e){super(t,e),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const t=this.geometry;if(t.index===null){const e=t.attributes.position,n=[];for(let i=0,r=e.count;i<r;i+=2)Jd.fromBufferAttribute(e,i),Qd.fromBufferAttribute(e,i+1),n[i]=i===0?0:n[i-1],n[i+1]=n[i]+Jd.distanceTo(Qd);t.setAttribute("lineDistance",new Se(n,1))}else wt("LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");return this}}class YE extends Tp{constructor(t,e){super(t,e),this.isLineLoop=!0,this.type="LineLoop"}}class Rp extends Bi{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new vt(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 jd=new Xt,Ah=new ya,co=new zi,lo=new P;class Fo extends _e{constructor(t=new be,e=new Rp){super(),this.isPoints=!0,this.type="Points",this.geometry=t,this.material=e,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(t,e){return super.copy(t,e),this.material=Array.isArray(t.material)?t.material.slice():t.material,this.geometry=t.geometry,this}raycast(t,e){const n=this.geometry,i=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),co.copy(n.boundingSphere),co.applyMatrix4(i),co.radius+=r,t.ray.intersectsSphere(co)===!1)return;jd.copy(i).invert(),Ah.copy(t.ray).applyMatrix4(jd);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),c=o*o,l=n.index,u=n.attributes.position;if(l!==null){const d=Math.max(0,a.start),f=Math.min(l.count,a.start+a.count);for(let g=d,v=f;g<v;g++){const p=l.getX(g);lo.fromBufferAttribute(u,p),t0(lo,p,c,i,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,v=f;g<v;g++)lo.fromBufferAttribute(u,g),t0(lo,g,c,i,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const i=e[n[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=i.length;r<a;r++){const o=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function t0(s,t,e,n,i,r,a){const o=Ah.distanceSqToPoint(s);if(o<e){const c=new P;Ah.closestPointToPoint(s,c),c.applyMatrix4(n);const l=i.ray.origin.distanceTo(c);if(l<i.near||l>i.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class Dp extends $e{constructor(t=[],e=Ds,n,i,r,a,o,c,l,h){super(t,e,n,i,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class _i extends $e{constructor(t,e,n,i,r,a,o,c,l){super(t,e,n,i,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Ps extends $e{constructor(t,e,n=Jn,i,r,a,o=ke,c=ke,l,h=Ui,u=1){if(h!==Ui&&h!==As)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,i,r,a,o,c,h,n,l),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(t){return super.copy(t),this.source=new mu(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 g2 extends Ps{constructor(t,e=Jn,n=Ds,i,r,a=ke,o=ke,c,l=Ui){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,i,r,a,o,c,l),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(t){this.image=t}}class Cp extends $e{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Bn extends be{constructor(t=1,e=1,n=1,i=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:i,heightSegments:r,depthSegments:a};const o=this;i=Math.floor(i),r=Math.floor(r),a=Math.floor(a);const c=[],l=[],h=[],u=[];let d=0,f=0;g("z","y","x",-1,-1,n,e,t,a,r,0),g("z","y","x",1,-1,n,e,-t,a,r,1),g("x","z","y",1,1,t,n,e,i,a,2),g("x","z","y",1,-1,t,n,-e,i,a,3),g("x","y","z",1,-1,t,e,n,i,r,4),g("x","y","z",-1,-1,t,e,-n,i,r,5),this.setIndex(c),this.setAttribute("position",new Se(l,3)),this.setAttribute("normal",new Se(h,3)),this.setAttribute("uv",new Se(u,2));function g(v,p,m,b,E,M,S,w,R,_,A){const C=M/R,D=S/_,I=M/2,V=S/2,q=w/2,O=R+1,W=_+1;let G=0,Z=0;const et=new P;for(let j=0;j<W;j++){const it=j*D-V;for(let ut=0;ut<O;ut++){const Ht=ut*C-I;et[v]=Ht*b,et[p]=it*E,et[m]=q,l.push(et.x,et.y,et.z),et[v]=0,et[p]=0,et[m]=w>0?1:-1,h.push(et.x,et.y,et.z),u.push(ut/R),u.push(1-j/_),G+=1}}for(let j=0;j<_;j++)for(let it=0;it<R;it++){const ut=d+it+O*j,Ht=d+it+O*(j+1),Jt=d+(it+1)+O*(j+1),kt=d+(it+1)+O*j;c.push(ut,Ht,kt),c.push(Ht,Jt,kt),Z+=6}o.addGroup(f,Z,A),f+=Z,d+=G}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Bn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class Mu extends be{constructor(t=1,e=32,n=0,i=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:i},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new P,h=new Pt;a.push(0,0,0),o.push(0,0,1),c.push(.5,.5);for(let u=0,d=3;u<=e;u++,d+=3){const f=n+u/e*i;l.x=t*Math.cos(f),l.y=t*Math.sin(f),a.push(l.x,l.y,l.z),o.push(0,0,1),h.x=(a[d]/t+1)/2,h.y=(a[d+1]/t+1)/2,c.push(h.x,h.y)}for(let u=1;u<=e;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new Se(a,3)),this.setAttribute("normal",new Se(o,3)),this.setAttribute("uv",new Se(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mu(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class ki extends be{constructor(t=1,e=1,n=1,i=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:i,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;i=Math.floor(i),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const v=[],p=n/2;let m=0;b(),a===!1&&(t>0&&E(!0),e>0&&E(!1)),this.setIndex(h),this.setAttribute("position",new Se(u,3)),this.setAttribute("normal",new Se(d,3)),this.setAttribute("uv",new Se(f,2));function b(){const M=new P,S=new P;let w=0;const R=(e-t)/n;for(let _=0;_<=r;_++){const A=[],C=_/r,D=C*(e-t)+t;for(let I=0;I<=i;I++){const V=I/i,q=V*c+o,O=Math.sin(q),W=Math.cos(q);S.x=D*O,S.y=-C*n+p,S.z=D*W,u.push(S.x,S.y,S.z),M.set(O,R,W).normalize(),d.push(M.x,M.y,M.z),f.push(V,1-C),A.push(g++)}v.push(A)}for(let _=0;_<i;_++)for(let A=0;A<r;A++){const C=v[A][_],D=v[A+1][_],I=v[A+1][_+1],V=v[A][_+1];(t>0||A!==0)&&(h.push(C,D,V),w+=3),(e>0||A!==r-1)&&(h.push(D,I,V),w+=3)}l.addGroup(m,w,0),m+=w}function E(M){const S=g,w=new Pt,R=new P;let _=0;const A=M===!0?t:e,C=M===!0?1:-1;for(let I=1;I<=i;I++)u.push(0,p*C,0),d.push(0,C,0),f.push(.5,.5),g++;const D=g;for(let I=0;I<=i;I++){const q=I/i*c+o,O=Math.cos(q),W=Math.sin(q);R.x=A*W,R.y=p*C,R.z=A*O,u.push(R.x,R.y,R.z),d.push(0,C,0),w.x=O*.5+.5,w.y=W*.5*C+.5,f.push(w.x,w.y),g++}for(let I=0;I<i;I++){const V=S+I,q=D+I;M===!0?h.push(q,q+1,V):h.push(q+1,q,V),_+=3}l.addGroup(m,_,M===!0?1:2),m+=_}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new ki(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Sa extends ki{constructor(t=1,e=1,n=32,i=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,i,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:i,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new Sa(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class Hi extends be{constructor(t=1,e=1,n=1,i=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:i};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(i),l=o+1,h=c+1,u=t/o,d=e/c,f=[],g=[],v=[],p=[];for(let m=0;m<h;m++){const b=m*d-a;for(let E=0;E<l;E++){const M=E*u-r;g.push(M,-b,0),v.push(0,0,1),p.push(E/o),p.push(1-m/c)}}for(let m=0;m<c;m++)for(let b=0;b<o;b++){const E=b+l*m,M=b+l*(m+1),S=b+1+l*(m+1),w=b+1+l*m;f.push(E,M,w),f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new Se(g,3)),this.setAttribute("normal",new Se(v,3)),this.setAttribute("uv",new Se(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Hi(t.width,t.height,t.widthSegments,t.heightSegments)}}class pn extends be{constructor(t=1,e=32,n=16,i=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:i,phiLength:r,thetaStart:a,thetaLength:o},e=Math.max(3,Math.floor(e)),n=Math.max(2,Math.floor(n));const c=Math.min(a+o,Math.PI);let l=0;const h=[],u=new P,d=new P,f=[],g=[],v=[],p=[];for(let m=0;m<=n;m++){const b=[],E=m/n,M=a+E*o,S=t*Math.cos(M),w=Math.sqrt(t*t-S*S);let R=0;m===0&&a===0?R=.5/e:m===n&&c===Math.PI&&(R=-.5/e);for(let _=0;_<=e;_++){const A=_/e,C=i+A*r;u.x=-w*Math.cos(C),u.y=S,u.z=w*Math.sin(C),g.push(u.x,u.y,u.z),d.copy(u).normalize(),v.push(d.x,d.y,d.z),p.push(A+R,1-E),b.push(l++)}h.push(b)}for(let m=0;m<n;m++)for(let b=0;b<e;b++){const E=h[m][b+1],M=h[m][b],S=h[m+1][b],w=h[m+1][b+1];(m!==0||a>0)&&f.push(E,M,w),(m!==n-1||c<Math.PI)&&f.push(M,S,w)}this.setIndex(f),this.setAttribute("position",new Se(g,3)),this.setAttribute("normal",new Se(v,3)),this.setAttribute("uv",new Se(p,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new pn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Ar(s){const t={};for(const e in s){t[e]={};for(const n in s[e]){const i=s[e][n];if(e0(i))i.isRenderTargetTexture?(wt("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=i.clone();else if(Array.isArray(i))if(e0(i[0])){const r=[];for(let a=0,o=i.length;a<o;a++)r[a]=i[a].clone();t[e][n]=r}else t[e][n]=i.slice();else t[e][n]=i}}return t}function rn(s){const t={};for(let e=0;e<s.length;e++){const n=Ar(s[e]);for(const i in n)t[i]=n[i]}return t}function e0(s){return s&&(s.isColor||s.isMatrix3||s.isMatrix4||s.isVector2||s.isVector3||s.isVector4||s.isTexture||s.isQuaternion)}function v2(s){const t=[];for(let e=0;e<s.length;e++)t.push(s[e].clone());return t}function Pp(s){const t=s.getRenderTarget();return t===null?s.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Qt.workingColorSpace}const x2={clone:Ar,merge:rn};var _2=`void main() {
|
|
515
515
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
516
|
-
}`,
|
|
516
|
+
}`,M2=`void main() {
|
|
517
517
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
518
|
-
}`;class De extends Bi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=v2,this.fragmentShader=x2,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=Ar(t.uniforms),this.uniformsGroups=m2(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new vt().setHex(i.value);break;case"v2":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new P().fromArray(i.value);break;case"v4":this.uniforms[n].value=new le().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Bt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class _2 extends De{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class M2 extends Bi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new vt(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 vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ko,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fi,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 WE extends M2{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Yt(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 vt(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 vt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new vt(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 ba extends Bi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ko,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fi,this.combine=su,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 y2 extends Bi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=l1,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 S2 extends Bi{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 ho(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function b2(s){function t(i,r){return s[i]-s[r]}const e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function n0(s,t,e){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function E2(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}class Ea{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break t}a=e.length;break e}if(!(t>=r)){const o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let a=0;a!==i;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class w2 extends Ea{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xd,endingEnd:xd}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case _d:r=t,o=2*e-n;break;case Md:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case _d:a=t,c=2*n-e;break;case Md:a=1,c=n+i[1]-i[0];break;default:a=t-1,c=e}const l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-e)/(i-e),v=g*g,p=v*g,m=-d*p+2*d*v-d*g,b=(1+d)*p+(-1.5-2*d)*v+(-.5+d)*g+1,E=(-1-f)*p+(1.5+f)*v+.5*g,M=f*p-f*v;for(let S=0;S!==o;++S)r[S]=m*a[h+S]+b*a[l+S]+E*a[c+S]+M*a[u+S];return r}}class A2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class T2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class R2 extends Ea{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const g=(n-e)/(i-e),v=1-g;for(let p=0;p!==o;++p)r[p]=a[l+p]*v+a[c+p]*g;return r}const d=o*2,f=t-1;for(let g=0;g!==o;++g){const v=a[l+g],p=a[c+g],m=f*d+g*2,b=u[m],E=u[m+1],M=t*d+g*2,S=h[M],w=h[M+1];let R=(n-e)/(i-e),_,A,C,D,I;for(let V=0;V<8;V++){_=R*R,A=_*R,C=1-R,D=C*C,I=D*C;const O=I*e+3*D*R*b+3*C*_*S+A*i-n;if(Math.abs(O)<1e-10)break;const W=3*D*(b-e)+6*C*R*(S-b)+3*_*(i-S);if(Math.abs(W)<1e-10)break;R=R-O/W,R=Math.max(0,Math.min(1,R))}r[g]=I*v+3*D*R*E+3*C*_*w+A*p}return r}}class Qn{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ho(e,this.TimeBufferType),this.values=ho(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ho(t.times,Array),values:ho(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new T2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new A2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new w2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new R2(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 Yo:e=this.InterpolantFactoryMethodDiscrete;break;case Eh:e=this.InterpolantFactoryMethodLinear;break;case wc:e=this.InterpolantFactoryMethodSmooth;break;case vd:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return wt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Yo;case this.InterpolantFactoryMethodLinear:return Eh;case this.InterpolantFactoryMethodSmooth:return wc;case this.InterpolantFactoryMethodBezier:return vd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(zt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;r===0&&(zt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){zt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){zt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(i!==void 0&&x1(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){zt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===wc,r=t.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let g=0;g!==n;++g){const v=e[u+g];if(v!==e[d+g]||v!==e[f+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}Qn.prototype.ValueTypeName="";Qn.prototype.TimeBufferType=Float32Array;Qn.prototype.ValueBufferType=Float32Array;Qn.prototype.DefaultInterpolation=Eh;class Cr extends Qn{constructor(t,e,n){super(t,e,n)}}Cr.prototype.ValueTypeName="bool";Cr.prototype.ValueBufferType=Array;Cr.prototype.DefaultInterpolation=Yo;Cr.prototype.InterpolantFactoryMethodLinear=void 0;Cr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ip extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}Ip.prototype.ValueTypeName="color";class yu extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}yu.prototype.ValueTypeName="number";class D2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e);let l=t*o;for(let h=l+o;l!==h;l+=4)hs.slerpFlat(r,0,a,l-o,a,l,c);return r}}class Su extends Qn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new D2(this.times,this.values,this.getValueSize(),t)}}Su.prototype.ValueTypeName="quaternion";Su.prototype.InterpolantFactoryMethodSmooth=void 0;class Pr extends Qn{constructor(t,e,n){super(t,e,n)}}Pr.prototype.ValueTypeName="string";Pr.prototype.ValueBufferType=Array;Pr.prototype.DefaultInterpolation=Yo;Pr.prototype.InterpolantFactoryMethodLinear=void 0;Pr.prototype.InterpolantFactoryMethodSmooth=void 0;class Lp extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}Lp.prototype.ValueTypeName="vector";class XE{constructor(t="",e=-1,n=[],i=c1){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=$n(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(P2(n[a]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,a=n.length;r!==a;++r)e.push(Qn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=b2(c);c=n0(c,1,h),l=n0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new yu(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function C2(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yu;case"vector":case"vector2":case"vector3":case"vector4":return Lp;case"color":return Ip;case"quaternion":return Su;case"bool":case"boolean":return Cr;case"string":return Pr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function P2(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=C2(s.type);if(s.times===void 0){const e=[],n=[];E2(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}const Li={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(i0(s)||(this.files[s]=t))},get:function(s){if(this.enabled!==!1&&!i0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function i0(s){try{const t=s.slice(s.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class I2{constructor(t,e,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],g=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}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 L2=new I2;class wa{constructor(t){this.manager=t!==void 0?t:L2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}wa.DEFAULT_MATERIAL_NAME="__DEFAULT";const wi={};class N2 extends Error{constructor(t,e){super(t),this.response=e}}class qE extends wa{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Li.get(`file:${t}`);if(r!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0);return}if(wi[t]!==void 0){wi[t].push({onLoad:e,onProgress:n,onError:i});return}wi[t]=[],wi[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&wt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=wi[t],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let v=0;const p=new ReadableStream({start(m){b();function b(){u.read().then(({done:E,value:M})=>{if(E)m.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const _=h[w];_.onProgress&&_.onProgress(S)}m.enqueue(M),b()}},E=>{m.error(E)})}}});return new Response(p)}else throw new N2(`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(g=>f.decode(g))}}}).then(l=>{Li.add(`file:${t}`,l);const h=wi[t];delete wi[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=wi[t];if(h===void 0)throw this.manager.itemError(t),l;delete wi[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 er=new WeakMap;class O2 extends wa{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Li.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);else{let u=er.get(a);u===void 0&&(u=[],er.set(a,u)),u.push({onLoad:e,onError:i})}return a}const o=_a("img");function c(){h(),e&&e(this);const u=er.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}er.delete(this),r.manager.itemEnd(t)}function l(u){h(),i&&i(u),Li.remove(`image:${t}`);const d=er.get(this)||[];for(let f=0;f<d.length;f++){const g=d[f];g.onError&&g.onError(u)}er.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Li.add(`image:${t}`,o),r.manager.itemStart(t),o.src=t,o}}class YE extends wa{constructor(t){super(t)}load(t,e,n,i){const r=new $e,a=new O2(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}}class dc extends _e{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new vt(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 U2 extends dc{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.groundColor=new vt(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 Qc=new Xt,s0=new P,r0=new P;class bu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pt(512,512),this.mapType=Dn,this.map=null,this.mapPass=null,this.matrix=new Xt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _u,this._frameExtents=new Pt(1,1),this._viewportCount=1,this._viewports=[new le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;s0.setFromMatrixPosition(t.matrixWorld),e.position.copy(s0),r0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(r0),e.updateMatrixWorld(),Qc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qc,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===xa||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Qc)}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 uo=new P,fo=new hs,ni=new P;class Np extends _e{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xt,this.projectionMatrix=new Xt,this.projectionMatrixInverse=new Xt,this.coordinateSystem=fi,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(uo,fo,ni),ni.x===1&&ni.y===1&&ni.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uo,fo,ni.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(uo,fo,ni),ni.x===1&&ni.y===1&&ni.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uo,fo,ni.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ji=new P,a0=new Pt,o0=new Pt;class yn extends Np{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=wr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(aa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return wr*2*Math.atan(Math.tan(aa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Ji.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ji.x,Ji.y).multiplyScalar(-t/Ji.z),Ji.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ji.x,Ji.y).multiplyScalar(-t/Ji.z)}getViewSize(t,e){return this.getViewBounds(t,a0,o0),e.subVectors(o0,a0)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(aa*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class F2 extends bu{constructor(){super(new yn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=wr*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class KE extends dc{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.target=new _e,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new F2}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 z2 extends bu{constructor(){super(new yn(90,1,.5,500)),this.isPointLightShadow=!0}}class B2 extends dc{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new z2}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 Ir extends Np{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,c=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class k2 extends bu{constructor(){super(new Ir(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class H2 extends dc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.target=new _e,this.shadow=new k2}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 $E{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 jc=new WeakMap;class ZE extends wa{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&wt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&wt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Li.get(`image-bitmap:${t}`);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(l=>{jc.has(a)===!0?(i&&i(jc.get(a)),r.manager.itemError(t),r.manager.itemEnd(t)):(e&&e(l),r.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Li.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t)}).catch(function(l){i&&i(l),jc.set(c,l),Li.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Li.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const nr=-90,ir=1;class G2 extends _e{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new yn(nr,ir,t,e);i.layers=this.layers,this.add(i);const r=new yn(nr,ir,t,e);r.layers=this.layers,this.add(r);const a=new yn(nr,ir,t,e);a.layers=this.layers,this.add(a);const o=new yn(nr,ir,t,e);o.layers=this.layers,this.add(o);const c=new yn(nr,ir,t,e);c.layers=this.layers,this.add(c);const l=new yn(nr,ir,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===fi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===xa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;t.isWebGLRenderer===!0?p=t.state.buffers.depth.getReversed():p=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class V2 extends yn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Eu="\\[\\]\\.:\\/",W2=new RegExp("["+Eu+"]","g"),wu="[^"+Eu+"]",X2="[^"+Eu.replace("\\.","")+"]",q2=/((?:WC+[\/:])*)/.source.replace("WC",wu),Y2=/(WCOD+)?/.source.replace("WCOD",X2),K2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wu),$2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wu),Z2=new RegExp("^"+q2+Y2+K2+$2+"$"),J2=["material","materials","bones","map"];class Q2{constructor(t,e,n){const i=n||ce.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class ce{constructor(t,e,n){this.path=e,this.parsedPath=n||ce.parseTrackName(e),this.node=ce.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new ce.Composite(t,e,n):new ce(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(W2,"")}static parseTrackName(t){const e=Z2.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);J2.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===e||o.uuid===e)return o;const c=n(o.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=ce.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){wt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){zt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){zt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){zt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){zt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){zt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[i];if(a===void 0){const l=e.nodeName;zt("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ce.Composite=Q2;ce.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ce.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ce.prototype.GetterByBindingType=[ce.prototype._getValue_direct,ce.prototype._getValue_array,ce.prototype._getValue_arrayElement,ce.prototype._getValue_toArray];ce.prototype.SetterByBindingTypeAndVersioning=[[ce.prototype._setValue_direct,ce.prototype._setValue_direct_setNeedsUpdate,ce.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_array,ce.prototype._setValue_array_setNeedsUpdate,ce.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_arrayElement,ce.prototype._setValue_arrayElement_setNeedsUpdate,ce.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_fromArray,ce.prototype._setValue_fromArray_setNeedsUpdate,ce.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const c0=new Xt;class tl{constructor(t,e,n=0,i=1/0){this.ray=new ya(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):zt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return c0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(c0),this}intersectObject(t,e=!0,n=[]){return Th(t,this,n,e),n.sort(l0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Th(t[i],this,n,e);return n.sort(l0),n}}function l0(s,t){return s.distance-t.distance}function Th(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)Th(r[a],t,e,!0)}}class Op{static{Op.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function h0(s,t,e,n){const i=j2(n);switch(e){case _p:return s*t;case cu:return s*t/i.components*i.byteLength;case lu:return s*t/i.components*i.byteLength;case Cs:return s*t*2/i.components*i.byteLength;case hu:return s*t*2/i.components*i.byteLength;case Mp:return s*t*3/i.components*i.byteLength;case fn:return s*t*4/i.components*i.byteLength;case uu:return s*t*4/i.components*i.byteLength;case Lo:case No:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Oo:case Uo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case $l:case Jl:return Math.max(s,16)*Math.max(t,8)/4;case Kl:case Zl:return Math.max(s,8)*Math.max(t,8)/2;case Ql:case jl:case eh:case nh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case th:case Xo:case ih:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case sh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case rh:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case ah:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case oh:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case ch:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case lh:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case hh:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case uh:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case dh:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case fh:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case ph:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case mh:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case gh:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case vh:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case xh:case _h:case Mh:return Math.ceil(s/4)*Math.ceil(t/4)*16;case yh:case Sh:return Math.ceil(s/4)*Math.ceil(t/4)*8;case qo:case bh:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function j2(s){switch(s){case Dn:case mp:return{byteLength:1,components:1};case ga:case gp:case nn:return{byteLength:2,components:1};case au:case ou:return{byteLength:2,components:4};case Jn:case ru:case zn:return{byteLength:4,components:1};case vp:case xp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:iu}}));typeof window<"u"&&(window.__THREE__?wt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=iu);/**
|
|
518
|
+
}`;class De extends Bi{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=_2,this.fragmentShader=M2,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=Ar(t.uniforms),this.uniformsGroups=v2(t.uniformsGroups),this.defines=Object.assign({},t.defines),this.wireframe=t.wireframe,this.wireframeLinewidth=t.wireframeLinewidth,this.fog=t.fog,this.lights=t.lights,this.clipping=t.clipping,this.extensions=Object.assign({},t.extensions),this.glslVersion=t.glslVersion,this.defaultAttributeValues=Object.assign({},t.defaultAttributeValues),this.index0AttributeName=t.index0AttributeName,this.uniformsNeedUpdate=t.uniformsNeedUpdate,this}toJSON(t){const e=super.toJSON(t);e.glslVersion=this.glslVersion,e.uniforms={};for(const i in this.uniforms){const a=this.uniforms[i].value;a&&a.isTexture?e.uniforms[i]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[i]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[i]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[i]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[i]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[i]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[i]={type:"m4",value:a.toArray()}:e.uniforms[i]={value:a}}Object.keys(this.defines).length>0&&(e.defines=this.defines),e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.lights=this.lights,e.clipping=this.clipping;const n={};for(const i in this.extensions)this.extensions[i]===!0&&(n[i]=!0);return Object.keys(n).length>0&&(e.extensions=n),e}fromJSON(t,e){if(super.fromJSON(t,e),t.uniforms!==void 0)for(const n in t.uniforms){const i=t.uniforms[n];switch(this.uniforms[n]={},i.type){case"t":this.uniforms[n].value=e[i.value]||null;break;case"c":this.uniforms[n].value=new vt().setHex(i.value);break;case"v2":this.uniforms[n].value=new Pt().fromArray(i.value);break;case"v3":this.uniforms[n].value=new P().fromArray(i.value);break;case"v4":this.uniforms[n].value=new le().fromArray(i.value);break;case"m3":this.uniforms[n].value=new Bt().fromArray(i.value);break;case"m4":this.uniforms[n].value=new Xt().fromArray(i.value);break;default:this.uniforms[n].value=i.value}}if(t.defines!==void 0&&(this.defines=t.defines),t.vertexShader!==void 0&&(this.vertexShader=t.vertexShader),t.fragmentShader!==void 0&&(this.fragmentShader=t.fragmentShader),t.glslVersion!==void 0&&(this.glslVersion=t.glslVersion),t.extensions!==void 0)for(const n in t.extensions)this.extensions[n]=t.extensions[n];return t.lights!==void 0&&(this.lights=t.lights),t.clipping!==void 0&&(this.clipping=t.clipping),this}}class y2 extends De{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class S2 extends Bi{constructor(t){super(),this.isMeshStandardMaterial=!0,this.type="MeshStandardMaterial",this.defines={STANDARD:""},this.color=new vt(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 vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ko,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.roughnessMap=null,this.metalnessMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fi,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 KE extends S2{constructor(t){super(),this.isMeshPhysicalMaterial=!0,this.defines={STANDARD:"",PHYSICAL:""},this.type="MeshPhysicalMaterial",this.anisotropyRotation=0,this.anisotropyMap=null,this.clearcoatMap=null,this.clearcoatRoughness=0,this.clearcoatRoughnessMap=null,this.clearcoatNormalScale=new Pt(1,1),this.clearcoatNormalMap=null,this.ior=1.5,Object.defineProperty(this,"reflectivity",{get:function(){return Yt(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 vt(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 vt(1,1,1),this.specularIntensity=1,this.specularIntensityMap=null,this.specularColor=new vt(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 ba extends Bi{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new vt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new vt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=Ko,this.normalScale=new Pt(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Fi,this.combine=su,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 b2 extends Bi{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=u1,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 E2 extends Bi{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 ho(s,t){return!s||s.constructor===t?s:typeof t.BYTES_PER_ELEMENT=="number"?new t(s):Array.prototype.slice.call(s)}function w2(s){function t(i,r){return s[i]-s[r]}const e=s.length,n=new Array(e);for(let i=0;i!==e;++i)n[i]=i;return n.sort(t),n}function n0(s,t,e){const n=s.length,i=new s.constructor(n);for(let r=0,a=0;a!==n;++r){const o=e[r]*t;for(let c=0;c!==t;++c)i[a++]=s[o+c]}return i}function A2(s,t,e,n){let i=1,r=s[0];for(;r!==void 0&&r[n]===void 0;)r=s[i++];if(r===void 0)return;let a=r[n];if(a!==void 0)if(Array.isArray(a))do a=r[n],a!==void 0&&(t.push(r.time),e.push(...a)),r=s[i++];while(r!==void 0);else if(a.toArray!==void 0)do a=r[n],a!==void 0&&(t.push(r.time),a.toArray(e,e.length)),r=s[i++];while(r!==void 0);else do a=r[n],a!==void 0&&(t.push(r.time),e.push(a)),r=s[i++];while(r!==void 0)}class Ea{constructor(t,e,n,i){this.parameterPositions=t,this._cachedIndex=0,this.resultBuffer=i!==void 0?i:new e.constructor(n),this.sampleValues=e,this.valueSize=n,this.settings=null,this.DefaultSettings_={}}evaluate(t){const e=this.parameterPositions;let n=this._cachedIndex,i=e[n],r=e[n-1];n:{t:{let a;e:{i:if(!(t<i)){for(let o=n+2;;){if(i===void 0){if(t<r)break i;return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}if(n===o)break;if(r=i,i=e[++n],t<i)break t}a=e.length;break e}if(!(t>=r)){const o=e[1];t<o&&(n=2,r=o);for(let c=n-2;;){if(r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(n===c)break;if(i=r,r=e[--n-1],t>=r)break t}a=n,n=0;break e}break n}for(;n<a;){const o=n+a>>>1;t<e[o]?a=o:n=o+1}if(i=e[n],r=e[n-1],r===void 0)return this._cachedIndex=0,this.copySampleValue_(0);if(i===void 0)return n=e.length,this._cachedIndex=n,this.copySampleValue_(n-1)}this._cachedIndex=n,this.intervalChanged_(n,r,i)}return this.interpolate_(n,r,t,i)}getSettings_(){return this.settings||this.DefaultSettings_}copySampleValue_(t){const e=this.resultBuffer,n=this.sampleValues,i=this.valueSize,r=t*i;for(let a=0;a!==i;++a)e[a]=n[r+a];return e}interpolate_(){throw new Error("THREE.Interpolant: Call to abstract method.")}intervalChanged_(){}}class T2 extends Ea{constructor(t,e,n,i){super(t,e,n,i),this._weightPrev=-0,this._offsetPrev=-0,this._weightNext=-0,this._offsetNext=-0,this.DefaultSettings_={endingStart:xd,endingEnd:xd}}intervalChanged_(t,e,n){const i=this.parameterPositions;let r=t-2,a=t+1,o=i[r],c=i[a];if(o===void 0)switch(this.getSettings_().endingStart){case _d:r=t,o=2*e-n;break;case Md:r=i.length-2,o=e+i[r]-i[r+1];break;default:r=t,o=n}if(c===void 0)switch(this.getSettings_().endingEnd){case _d:a=t,c=2*n-e;break;case Md:a=1,c=n+i[1]-i[0];break;default:a=t-1,c=e}const l=(n-e)*.5,h=this.valueSize;this._weightPrev=l/(e-o),this._weightNext=l/(c-n),this._offsetPrev=r*h,this._offsetNext=a*h}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this._offsetPrev,u=this._offsetNext,d=this._weightPrev,f=this._weightNext,g=(n-e)/(i-e),v=g*g,p=v*g,m=-d*p+2*d*v-d*g,b=(1+d)*p+(-1.5-2*d)*v+(-.5+d)*g+1,E=(-1-f)*p+(1.5+f)*v+.5*g,M=f*p-f*v;for(let S=0;S!==o;++S)r[S]=m*a[h+S]+b*a[l+S]+E*a[c+S]+M*a[u+S];return r}}class R2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=(n-e)/(i-e),u=1-h;for(let d=0;d!==o;++d)r[d]=a[l+d]*u+a[c+d]*h;return r}}class D2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t){return this.copySampleValue_(t-1)}}class C2 extends Ea{interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=t*o,l=c-o,h=this.inTangents,u=this.outTangents;if(!h||!u){const g=(n-e)/(i-e),v=1-g;for(let p=0;p!==o;++p)r[p]=a[l+p]*v+a[c+p]*g;return r}const d=o*2,f=t-1;for(let g=0;g!==o;++g){const v=a[l+g],p=a[c+g],m=f*d+g*2,b=u[m],E=u[m+1],M=t*d+g*2,S=h[M],w=h[M+1];let R=(n-e)/(i-e),_,A,C,D,I;for(let V=0;V<8;V++){_=R*R,A=_*R,C=1-R,D=C*C,I=D*C;const O=I*e+3*D*R*b+3*C*_*S+A*i-n;if(Math.abs(O)<1e-10)break;const W=3*D*(b-e)+6*C*R*(S-b)+3*_*(i-S);if(Math.abs(W)<1e-10)break;R=R-O/W,R=Math.max(0,Math.min(1,R))}r[g]=I*v+3*D*R*E+3*C*_*w+A*p}return r}}class Qn{constructor(t,e,n,i){if(t===void 0)throw new Error("THREE.KeyframeTrack: track name is undefined");if(e===void 0||e.length===0)throw new Error("THREE.KeyframeTrack: no keyframes in track named "+t);this.name=t,this.times=ho(e,this.TimeBufferType),this.values=ho(n,this.ValueBufferType),this.setInterpolation(i||this.DefaultInterpolation)}static toJSON(t){const e=t.constructor;let n;if(e.toJSON!==this.toJSON)n=e.toJSON(t);else{n={name:t.name,times:ho(t.times,Array),values:ho(t.values,Array)};const i=t.getInterpolation();i!==t.DefaultInterpolation&&(n.interpolation=i)}return n.type=t.ValueTypeName,n}InterpolantFactoryMethodDiscrete(t){return new D2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodLinear(t){return new R2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodSmooth(t){return new T2(this.times,this.values,this.getValueSize(),t)}InterpolantFactoryMethodBezier(t){const e=new C2(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 Yo:e=this.InterpolantFactoryMethodDiscrete;break;case Eh:e=this.InterpolantFactoryMethodLinear;break;case wc:e=this.InterpolantFactoryMethodSmooth;break;case vd:e=this.InterpolantFactoryMethodBezier;break}if(e===void 0){const n="unsupported interpolation for "+this.ValueTypeName+" keyframe track named "+this.name;if(this.createInterpolant===void 0)if(t!==this.DefaultInterpolation)this.setInterpolation(this.DefaultInterpolation);else throw new Error(n);return wt("KeyframeTrack:",n),this}return this.createInterpolant=e,this}getInterpolation(){switch(this.createInterpolant){case this.InterpolantFactoryMethodDiscrete:return Yo;case this.InterpolantFactoryMethodLinear:return Eh;case this.InterpolantFactoryMethodSmooth:return wc;case this.InterpolantFactoryMethodBezier:return vd}}getValueSize(){return this.values.length/this.times.length}shift(t){if(t!==0){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]+=t}return this}scale(t){if(t!==1){const e=this.times;for(let n=0,i=e.length;n!==i;++n)e[n]*=t}return this}trim(t,e){const n=this.times,i=n.length;let r=0,a=i-1;for(;r!==i&&n[r]<t;)++r;for(;a!==-1&&n[a]>e;)--a;if(++a,r!==0||a!==i){r>=a&&(a=Math.max(a,1),r=a-1);const o=this.getValueSize();this.times=n.slice(r,a),this.values=this.values.slice(r*o,a*o)}return this}validate(){let t=!0;const e=this.getValueSize();e-Math.floor(e)!==0&&(zt("KeyframeTrack: Invalid value size in track.",this),t=!1);const n=this.times,i=this.values,r=n.length;r===0&&(zt("KeyframeTrack: Track is empty.",this),t=!1);let a=null;for(let o=0;o!==r;o++){const c=n[o];if(typeof c=="number"&&isNaN(c)){zt("KeyframeTrack: Time is not a valid number.",this,o,c),t=!1;break}if(a!==null&&a>c){zt("KeyframeTrack: Out of order keys.",this,o,c,a),t=!1;break}a=c}if(i!==void 0&&M1(i))for(let o=0,c=i.length;o!==c;++o){const l=i[o];if(isNaN(l)){zt("KeyframeTrack: Value is not a valid number.",this,o,l),t=!1;break}}return t}optimize(){const t=this.times.slice(),e=this.values.slice(),n=this.getValueSize(),i=this.getInterpolation()===wc,r=t.length-1;let a=1;for(let o=1;o<r;++o){let c=!1;const l=t[o],h=t[o+1];if(l!==h&&(o!==1||l!==t[0]))if(i)c=!0;else{const u=o*n,d=u-n,f=u+n;for(let g=0;g!==n;++g){const v=e[u+g];if(v!==e[d+g]||v!==e[f+g]){c=!0;break}}}if(c){if(o!==a){t[a]=t[o];const u=o*n,d=a*n;for(let f=0;f!==n;++f)e[d+f]=e[u+f]}++a}}if(r>0){t[a]=t[r];for(let o=r*n,c=a*n,l=0;l!==n;++l)e[c+l]=e[o+l];++a}return a!==t.length?(this.times=t.slice(0,a),this.values=e.slice(0,a*n)):(this.times=t,this.values=e),this}clone(){const t=this.times.slice(),e=this.values.slice(),n=this.constructor,i=new n(this.name,t,e);return i.createInterpolant=this.createInterpolant,i}}Qn.prototype.ValueTypeName="";Qn.prototype.TimeBufferType=Float32Array;Qn.prototype.ValueBufferType=Float32Array;Qn.prototype.DefaultInterpolation=Eh;class Cr extends Qn{constructor(t,e,n){super(t,e,n)}}Cr.prototype.ValueTypeName="bool";Cr.prototype.ValueBufferType=Array;Cr.prototype.DefaultInterpolation=Yo;Cr.prototype.InterpolantFactoryMethodLinear=void 0;Cr.prototype.InterpolantFactoryMethodSmooth=void 0;class Ip extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}Ip.prototype.ValueTypeName="color";class yu extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}yu.prototype.ValueTypeName="number";class P2 extends Ea{constructor(t,e,n,i){super(t,e,n,i)}interpolate_(t,e,n,i){const r=this.resultBuffer,a=this.sampleValues,o=this.valueSize,c=(n-e)/(i-e);let l=t*o;for(let h=l+o;l!==h;l+=4)hs.slerpFlat(r,0,a,l-o,a,l,c);return r}}class Su extends Qn{constructor(t,e,n,i){super(t,e,n,i)}InterpolantFactoryMethodLinear(t){return new P2(this.times,this.values,this.getValueSize(),t)}}Su.prototype.ValueTypeName="quaternion";Su.prototype.InterpolantFactoryMethodSmooth=void 0;class Pr extends Qn{constructor(t,e,n){super(t,e,n)}}Pr.prototype.ValueTypeName="string";Pr.prototype.ValueBufferType=Array;Pr.prototype.DefaultInterpolation=Yo;Pr.prototype.InterpolantFactoryMethodLinear=void 0;Pr.prototype.InterpolantFactoryMethodSmooth=void 0;class Lp extends Qn{constructor(t,e,n,i){super(t,e,n,i)}}Lp.prototype.ValueTypeName="vector";class $E{constructor(t="",e=-1,n=[],i=h1){this.name=t,this.tracks=n,this.duration=e,this.blendMode=i,this.uuid=$n(),this.userData={},this.duration<0&&this.resetDuration()}static parse(t){const e=[],n=t.tracks,i=1/(t.fps||1);for(let a=0,o=n.length;a!==o;++a)e.push(L2(n[a]).scale(i));const r=new this(t.name,t.duration,e,t.blendMode);return r.uuid=t.uuid,r.userData=JSON.parse(t.userData||"{}"),r}static toJSON(t){const e=[],n=t.tracks,i={name:t.name,duration:t.duration,tracks:e,uuid:t.uuid,blendMode:t.blendMode,userData:JSON.stringify(t.userData)};for(let r=0,a=n.length;r!==a;++r)e.push(Qn.toJSON(n[r]));return i}static CreateFromMorphTargetSequence(t,e,n,i){const r=e.length,a=[];for(let o=0;o<r;o++){let c=[],l=[];c.push((o+r-1)%r,o,(o+1)%r),l.push(0,1,0);const h=w2(c);c=n0(c,1,h),l=n0(l,1,h),!i&&c[0]===0&&(c.push(r),l.push(l[0])),a.push(new yu(".morphTargetInfluences["+e[o].name+"]",c,l).scale(1/n))}return new this(t,-1,a)}static findByName(t,e){let n=t;if(!Array.isArray(t)){const i=t;n=i.geometry&&i.geometry.animations||i.animations}for(let i=0;i<n.length;i++)if(n[i].name===e)return n[i];return null}static CreateClipsFromMorphTargetSequences(t,e,n){const i={},r=/^([\w-]*?)([\d]+)$/;for(let o=0,c=t.length;o<c;o++){const l=t[o],h=l.name.match(r);if(h&&h.length>1){const u=h[1];let d=i[u];d||(i[u]=d=[]),d.push(l)}}const a=[];for(const o in i)a.push(this.CreateFromMorphTargetSequence(o,i[o],e,n));return a}resetDuration(){const t=this.tracks;let e=0;for(let n=0,i=t.length;n!==i;++n){const r=this.tracks[n];e=Math.max(e,r.times[r.times.length-1])}return this.duration=e,this}trim(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].trim(0,this.duration);return this}validate(){let t=!0;for(let e=0;e<this.tracks.length;e++)t=t&&this.tracks[e].validate();return t}optimize(){for(let t=0;t<this.tracks.length;t++)this.tracks[t].optimize();return this}clone(){const t=[];for(let n=0;n<this.tracks.length;n++)t.push(this.tracks[n].clone());const e=new this.constructor(this.name,this.duration,t,this.blendMode);return e.userData=JSON.parse(JSON.stringify(this.userData)),e}toJSON(){return this.constructor.toJSON(this)}}function I2(s){switch(s.toLowerCase()){case"scalar":case"double":case"float":case"number":case"integer":return yu;case"vector":case"vector2":case"vector3":case"vector4":return Lp;case"color":return Ip;case"quaternion":return Su;case"bool":case"boolean":return Cr;case"string":return Pr}throw new Error("THREE.KeyframeTrack: Unsupported typeName: "+s)}function L2(s){if(s.type===void 0)throw new Error("THREE.KeyframeTrack: track type undefined, can not parse");const t=I2(s.type);if(s.times===void 0){const e=[],n=[];A2(s.keys,e,n,"value"),s.times=e,s.values=n}return t.parse!==void 0?t.parse(s):new t(s.name,s.times,s.values,s.interpolation)}const Li={enabled:!1,files:{},add:function(s,t){this.enabled!==!1&&(i0(s)||(this.files[s]=t))},get:function(s){if(this.enabled!==!1&&!i0(s))return this.files[s]},remove:function(s){delete this.files[s]},clear:function(){this.files={}}};function i0(s){try{const t=s.slice(s.indexOf(":")+1);return new URL(t).protocol==="blob:"}catch{return!1}}class N2{constructor(t,e,n){const i=this;let r=!1,a=0,o=0,c;const l=[];this.onStart=void 0,this.onLoad=t,this.onProgress=e,this.onError=n,this._abortController=null,this.itemStart=function(h){o++,r===!1&&i.onStart!==void 0&&i.onStart(h,a,o),r=!0},this.itemEnd=function(h){a++,i.onProgress!==void 0&&i.onProgress(h,a,o),a===o&&(r=!1,i.onLoad!==void 0&&i.onLoad())},this.itemError=function(h){i.onError!==void 0&&i.onError(h)},this.resolveURL=function(h){return h=h.normalize("NFC"),c?c(h):h},this.setURLModifier=function(h){return c=h,this},this.addHandler=function(h,u){return l.push(h,u),this},this.removeHandler=function(h){const u=l.indexOf(h);return u!==-1&&l.splice(u,2),this},this.getHandler=function(h){for(let u=0,d=l.length;u<d;u+=2){const f=l[u],g=l[u+1];if(f.global&&(f.lastIndex=0),f.test(h))return g}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 O2=new N2;class wa{constructor(t){this.manager=t!==void 0?t:O2,this.crossOrigin="anonymous",this.withCredentials=!1,this.path="",this.resourcePath="",this.requestHeader={},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}load(){}loadAsync(t,e){const n=this;return new Promise(function(i,r){n.load(t,i,e,r)})}parse(){}setCrossOrigin(t){return this.crossOrigin=t,this}setWithCredentials(t){return this.withCredentials=t,this}setPath(t){return this.path=t,this}setResourcePath(t){return this.resourcePath=t,this}setRequestHeader(t){return this.requestHeader=t,this}abort(){return this}}wa.DEFAULT_MATERIAL_NAME="__DEFAULT";const wi={};class U2 extends Error{constructor(t,e){super(t),this.response=e}}class ZE extends wa{constructor(t){super(t),this.mimeType="",this.responseType="",this._abortController=new AbortController}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=Li.get(`file:${t}`);if(r!==void 0){this.manager.itemStart(t),setTimeout(()=>{e&&e(r),this.manager.itemEnd(t)},0);return}if(wi[t]!==void 0){wi[t].push({onLoad:e,onProgress:n,onError:i});return}wi[t]=[],wi[t].push({onLoad:e,onProgress:n,onError:i});const a=new Request(t,{headers:new Headers(this.requestHeader),credentials:this.withCredentials?"include":"same-origin",signal:typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal}),o=this.mimeType,c=this.responseType;fetch(a).then(l=>{if(l.status===200||l.status===0){if(l.status===0&&wt("FileLoader: HTTP Status 0 received."),typeof ReadableStream>"u"||l.body===void 0||l.body.getReader===void 0)return l;const h=wi[t],u=l.body.getReader(),d=l.headers.get("X-File-Size")||l.headers.get("Content-Length"),f=d?parseInt(d):0,g=f!==0;let v=0;const p=new ReadableStream({start(m){b();function b(){u.read().then(({done:E,value:M})=>{if(E)m.close();else{v+=M.byteLength;const S=new ProgressEvent("progress",{lengthComputable:g,loaded:v,total:f});for(let w=0,R=h.length;w<R;w++){const _=h[w];_.onProgress&&_.onProgress(S)}m.enqueue(M),b()}},E=>{m.error(E)})}}});return new Response(p)}else throw new U2(`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(g=>f.decode(g))}}}).then(l=>{Li.add(`file:${t}`,l);const h=wi[t];delete wi[t];for(let u=0,d=h.length;u<d;u++){const f=h[u];f.onLoad&&f.onLoad(l)}}).catch(l=>{const h=wi[t];if(h===void 0)throw this.manager.itemError(t),l;delete wi[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 er=new WeakMap;class F2 extends wa{constructor(t){super(t)}load(t,e,n,i){this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Li.get(`image:${t}`);if(a!==void 0){if(a.complete===!0)r.manager.itemStart(t),setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);else{let u=er.get(a);u===void 0&&(u=[],er.set(a,u)),u.push({onLoad:e,onError:i})}return a}const o=_a("img");function c(){h(),e&&e(this);const u=er.get(this)||[];for(let d=0;d<u.length;d++){const f=u[d];f.onLoad&&f.onLoad(this)}er.delete(this),r.manager.itemEnd(t)}function l(u){h(),i&&i(u),Li.remove(`image:${t}`);const d=er.get(this)||[];for(let f=0;f<d.length;f++){const g=d[f];g.onError&&g.onError(u)}er.delete(this),r.manager.itemError(t),r.manager.itemEnd(t)}function h(){o.removeEventListener("load",c,!1),o.removeEventListener("error",l,!1)}return o.addEventListener("load",c,!1),o.addEventListener("error",l,!1),t.slice(0,5)!=="data:"&&this.crossOrigin!==void 0&&(o.crossOrigin=this.crossOrigin),Li.add(`image:${t}`,o),r.manager.itemStart(t),o.src=t,o}}class JE extends wa{constructor(t){super(t)}load(t,e,n,i){const r=new $e,a=new F2(this.manager);return a.setCrossOrigin(this.crossOrigin),a.setPath(this.path),a.load(t,function(o){r.image=o,r.needsUpdate=!0,e!==void 0&&e(r)},n,i),r}}class dc extends _e{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new vt(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 z2 extends dc{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.groundColor=new vt(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 Qc=new Xt,s0=new P,r0=new P;class bu{constructor(t){this.camera=t,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Pt(512,512),this.mapType=Dn,this.map=null,this.mapPass=null,this.matrix=new Xt,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new _u,this._frameExtents=new Pt(1,1),this._viewportCount=1,this._viewports=[new le(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;s0.setFromMatrixPosition(t.matrixWorld),e.position.copy(s0),r0.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(r0),e.updateMatrixWorld(),Qc.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Qc,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===xa||e.reversedDepth?n.set(.5,0,0,.5,0,.5,0,.5,0,0,1,0,0,0,0,1):n.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1),n.multiply(Qc)}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 uo=new P,fo=new hs,ni=new P;class Np extends _e{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Xt,this.projectionMatrix=new Xt,this.projectionMatrixInverse=new Xt,this.coordinateSystem=fi,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(uo,fo,ni),ni.x===1&&ni.y===1&&ni.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uo,fo,ni.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(uo,fo,ni),ni.x===1&&ni.y===1&&ni.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(uo,fo,ni.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ji=new P,a0=new Pt,o0=new Pt;class yn extends Np{constructor(t=50,e=1,n=.1,i=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=i,this.focus=10,this.aspect=e,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.fov=t.fov,this.zoom=t.zoom,this.near=t.near,this.far=t.far,this.focus=t.focus,this.aspect=t.aspect,this.view=t.view===null?null:Object.assign({},t.view),this.filmGauge=t.filmGauge,this.filmOffset=t.filmOffset,this}setFocalLength(t){const e=.5*this.getFilmHeight()/t;this.fov=wr*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(aa*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return wr*2*Math.atan(Math.tan(aa*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(t,e,n){Ji.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(Ji.x,Ji.y).multiplyScalar(-t/Ji.z),Ji.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(Ji.x,Ji.y).multiplyScalar(-t/Ji.z)}getViewSize(t,e){return this.getViewBounds(t,a0,o0),e.subVectors(o0,a0)}setViewOffset(t,e,n,i,r,a){this.aspect=t/e,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=this.near;let e=t*Math.tan(aa*.5*this.fov)/this.zoom,n=2*e,i=this.aspect*n,r=-.5*i;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*i/c,e-=a.offsetY*n/l,i*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+i,e,e-n,t,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.fov=this.fov,e.object.zoom=this.zoom,e.object.near=this.near,e.object.far=this.far,e.object.focus=this.focus,e.object.aspect=this.aspect,this.view!==null&&(e.object.view=Object.assign({},this.view)),e.object.filmGauge=this.filmGauge,e.object.filmOffset=this.filmOffset,e}}class B2 extends bu{constructor(){super(new yn(50,1,.5,500)),this.isSpotLightShadow=!0,this.focus=1,this.aspect=1}updateMatrices(t){const e=this.camera,n=wr*2*t.angle*this.focus,i=this.mapSize.width/this.mapSize.height*this.aspect,r=t.distance||e.far;(n!==e.fov||i!==e.aspect||r!==e.far)&&(e.fov=n,e.aspect=i,e.far=r,e.updateProjectionMatrix()),super.updateMatrices(t)}copy(t){return super.copy(t),this.focus=t.focus,this}}class QE extends dc{constructor(t,e,n=0,i=Math.PI/3,r=0,a=2){super(t,e),this.isSpotLight=!0,this.type="SpotLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.target=new _e,this.distance=n,this.angle=i,this.penumbra=r,this.decay=a,this.map=null,this.shadow=new B2}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 k2 extends bu{constructor(){super(new yn(90,1,.5,500)),this.isPointLightShadow=!0}}class H2 extends dc{constructor(t,e,n=0,i=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=i,this.shadow=new k2}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 Ir extends Np{constructor(t=-1,e=1,n=1,i=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=t,this.right=e,this.top=n,this.bottom=i,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(t,e){return super.copy(t,e),this.left=t.left,this.right=t.right,this.top=t.top,this.bottom=t.bottom,this.near=t.near,this.far=t.far,this.zoom=t.zoom,this.view=t.view===null?null:Object.assign({},t.view),this}setViewOffset(t,e,n,i,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=t,this.view.fullHeight=e,this.view.offsetX=n,this.view.offsetY=i,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const t=(this.right-this.left)/(2*this.zoom),e=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,i=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=i+e,c=i-e;if(this.view!==null&&this.view.enabled){const l=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=l*this.view.offsetX,a=r+l*this.view.width,o-=h*this.view.offsetY,c=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,c,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(t){const e=super.toJSON(t);return e.object.zoom=this.zoom,e.object.left=this.left,e.object.right=this.right,e.object.top=this.top,e.object.bottom=this.bottom,e.object.near=this.near,e.object.far=this.far,this.view!==null&&(e.object.view=Object.assign({},this.view)),e}}class G2 extends bu{constructor(){super(new Ir(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class V2 extends dc{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(_e.DEFAULT_UP),this.updateMatrix(),this.target=new _e,this.shadow=new G2}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 jE{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 jc=new WeakMap;class tw extends wa{constructor(t){super(t),this.isImageBitmapLoader=!0,typeof createImageBitmap>"u"&&wt("ImageBitmapLoader: createImageBitmap() not supported."),typeof fetch>"u"&&wt("ImageBitmapLoader: fetch() not supported."),this.options={premultiplyAlpha:"none"},this._abortController=new AbortController}setOptions(t){return this.options=t,this}load(t,e,n,i){t===void 0&&(t=""),this.path!==void 0&&(t=this.path+t),t=this.manager.resolveURL(t);const r=this,a=Li.get(`image-bitmap:${t}`);if(a!==void 0){if(r.manager.itemStart(t),a.then){a.then(l=>{jc.has(a)===!0?(i&&i(jc.get(a)),r.manager.itemError(t),r.manager.itemEnd(t)):(e&&e(l),r.manager.itemEnd(t))});return}setTimeout(function(){e&&e(a),r.manager.itemEnd(t)},0);return}const o={};o.credentials=this.crossOrigin==="anonymous"?"same-origin":"include",o.headers=this.requestHeader,o.signal=typeof AbortSignal.any=="function"?AbortSignal.any([this._abortController.signal,this.manager.abortController.signal]):this._abortController.signal;const c=fetch(t,o).then(function(l){return l.blob()}).then(function(l){return createImageBitmap(l,Object.assign(r.options,{colorSpaceConversion:"none"}))}).then(function(l){Li.add(`image-bitmap:${t}`,l),e&&e(l),r.manager.itemEnd(t)}).catch(function(l){i&&i(l),jc.set(c,l),Li.remove(`image-bitmap:${t}`),r.manager.itemError(t),r.manager.itemEnd(t)});Li.add(`image-bitmap:${t}`,c),r.manager.itemStart(t)}abort(){return this._abortController.abort(),this._abortController=new AbortController,this}}const nr=-90,ir=1;class W2 extends _e{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const i=new yn(nr,ir,t,e);i.layers=this.layers,this.add(i);const r=new yn(nr,ir,t,e);r.layers=this.layers,this.add(r);const a=new yn(nr,ir,t,e);a.layers=this.layers,this.add(a);const o=new yn(nr,ir,t,e);o.layers=this.layers,this.add(o);const c=new yn(nr,ir,t,e);c.layers=this.layers,this.add(c);const l=new yn(nr,ir,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,i,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===fi)n.up.set(0,1,0),n.lookAt(1,0,0),i.up.set(0,1,0),i.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),c.up.set(0,1,0),c.lookAt(0,0,-1);else if(t===xa)n.up.set(0,-1,0),n.lookAt(-1,0,0),i.up.set(0,-1,0),i.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),c.up.set(0,-1,0),c.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+t);for(const l of e)this.add(l),l.updateMatrixWorld()}update(t,e){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:i}=this;this.coordinateSystem!==t.coordinateSystem&&(this.coordinateSystem=t.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,c,l,h]=this.children,u=t.getRenderTarget(),d=t.getActiveCubeFace(),f=t.getActiveMipmapLevel(),g=t.xr.enabled;t.xr.enabled=!1;const v=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let p=!1;t.isWebGLRenderer===!0?p=t.state.buffers.depth.getReversed():p=t.reversedDepthBuffer,t.setRenderTarget(n,0,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=v,t.setRenderTarget(n,5,i),p&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class X2 extends yn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const Eu="\\[\\]\\.:\\/",q2=new RegExp("["+Eu+"]","g"),wu="[^"+Eu+"]",Y2="[^"+Eu.replace("\\.","")+"]",K2=/((?:WC+[\/:])*)/.source.replace("WC",wu),$2=/(WCOD+)?/.source.replace("WCOD",Y2),Z2=/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",wu),J2=/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",wu),Q2=new RegExp("^"+K2+$2+Z2+J2+"$"),j2=["material","materials","bones","map"];class tv{constructor(t,e,n){const i=n||ce.parseTrackName(e);this._targetGroup=t,this._bindings=t.subscribe_(e,i)}getValue(t,e){this.bind();const n=this._targetGroup.nCachedObjects_,i=this._bindings[n];i!==void 0&&i.getValue(t,e)}setValue(t,e){const n=this._bindings;for(let i=this._targetGroup.nCachedObjects_,r=n.length;i!==r;++i)n[i].setValue(t,e)}bind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].bind()}unbind(){const t=this._bindings;for(let e=this._targetGroup.nCachedObjects_,n=t.length;e!==n;++e)t[e].unbind()}}class ce{constructor(t,e,n){this.path=e,this.parsedPath=n||ce.parseTrackName(e),this.node=ce.findNode(t,this.parsedPath.nodeName),this.rootNode=t,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}static create(t,e,n){return t&&t.isAnimationObjectGroup?new ce.Composite(t,e,n):new ce(t,e,n)}static sanitizeNodeName(t){return t.replace(/\s/g,"_").replace(q2,"")}static parseTrackName(t){const e=Q2.exec(t);if(e===null)throw new Error("THREE.PropertyBinding: Cannot parse trackName: "+t);const n={nodeName:e[2],objectName:e[3],objectIndex:e[4],propertyName:e[5],propertyIndex:e[6]},i=n.nodeName&&n.nodeName.lastIndexOf(".");if(i!==void 0&&i!==-1){const r=n.nodeName.substring(i+1);j2.indexOf(r)!==-1&&(n.nodeName=n.nodeName.substring(0,i),n.objectName=r)}if(n.propertyName===null||n.propertyName.length===0)throw new Error("THREE.PropertyBinding: can not parse propertyName from trackName: "+t);return n}static findNode(t,e){if(e===void 0||e===""||e==="."||e===-1||e===t.name||e===t.uuid)return t;if(t.skeleton){const n=t.skeleton.getBoneByName(e);if(n!==void 0)return n}if(t.children){const n=function(r){for(let a=0;a<r.length;a++){const o=r[a];if(o.name===e||o.uuid===e)return o;const c=n(o.children);if(c)return c}return null},i=n(t.children);if(i)return i}return null}_getValue_unavailable(){}_setValue_unavailable(){}_getValue_direct(t,e){t[e]=this.targetObject[this.propertyName]}_getValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)t[e++]=n[i]}_getValue_arrayElement(t,e){t[e]=this.resolvedProperty[this.propertyIndex]}_getValue_toArray(t,e){this.resolvedProperty.toArray(t,e)}_setValue_direct(t,e){this.targetObject[this.propertyName]=t[e]}_setValue_direct_setNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.needsUpdate=!0}_setValue_direct_setMatrixWorldNeedsUpdate(t,e){this.targetObject[this.propertyName]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_array(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++]}_setValue_array_setNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.needsUpdate=!0}_setValue_array_setMatrixWorldNeedsUpdate(t,e){const n=this.resolvedProperty;for(let i=0,r=n.length;i!==r;++i)n[i]=t[e++];this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_arrayElement(t,e){this.resolvedProperty[this.propertyIndex]=t[e]}_setValue_arrayElement_setNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.needsUpdate=!0}_setValue_arrayElement_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty[this.propertyIndex]=t[e],this.targetObject.matrixWorldNeedsUpdate=!0}_setValue_fromArray(t,e){this.resolvedProperty.fromArray(t,e)}_setValue_fromArray_setNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.needsUpdate=!0}_setValue_fromArray_setMatrixWorldNeedsUpdate(t,e){this.resolvedProperty.fromArray(t,e),this.targetObject.matrixWorldNeedsUpdate=!0}_getValue_unbound(t,e){this.bind(),this.getValue(t,e)}_setValue_unbound(t,e){this.bind(),this.setValue(t,e)}bind(){let t=this.node;const e=this.parsedPath,n=e.objectName,i=e.propertyName;let r=e.propertyIndex;if(t||(t=ce.findNode(this.rootNode,e.nodeName),this.node=t),this.getValue=this._getValue_unavailable,this.setValue=this._setValue_unavailable,!t){wt("PropertyBinding: No target node found for track: "+this.path+".");return}if(n){let l=e.objectIndex;switch(n){case"materials":if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.materials){zt("PropertyBinding: Can not bind to material.materials as node.material does not have a materials array.",this);return}t=t.material.materials;break;case"bones":if(!t.skeleton){zt("PropertyBinding: Can not bind to bones as node does not have a skeleton.",this);return}t=t.skeleton.bones;for(let h=0;h<t.length;h++)if(t[h].name===l){l=h;break}break;case"map":if("map"in t){t=t.map;break}if(!t.material){zt("PropertyBinding: Can not bind to material as node does not have a material.",this);return}if(!t.material.map){zt("PropertyBinding: Can not bind to material.map as node.material does not have a map.",this);return}t=t.material.map;break;default:if(t[n]===void 0){zt("PropertyBinding: Can not bind to objectName of node undefined.",this);return}t=t[n]}if(l!==void 0){if(t[l]===void 0){zt("PropertyBinding: Trying to bind to objectIndex of objectName, but is undefined.",this,t);return}t=t[l]}}const a=t[i];if(a===void 0){const l=e.nodeName;zt("PropertyBinding: Trying to update property for track: "+l+"."+i+" but it wasn't found.",t);return}let o=this.Versioning.None;this.targetObject=t,t.isMaterial===!0?o=this.Versioning.NeedsUpdate:t.isObject3D===!0&&(o=this.Versioning.MatrixWorldNeedsUpdate);let c=this.BindingType.Direct;if(r!==void 0){if(i==="morphTargetInfluences"){if(!t.geometry){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.",this);return}if(!t.geometry.morphAttributes){zt("PropertyBinding: Can not bind to morphTargetInfluences because node does not have a geometry.morphAttributes.",this);return}t.morphTargetDictionary[r]!==void 0&&(r=t.morphTargetDictionary[r])}c=this.BindingType.ArrayElement,this.resolvedProperty=a,this.propertyIndex=r}else a.fromArray!==void 0&&a.toArray!==void 0?(c=this.BindingType.HasFromToArray,this.resolvedProperty=a):Array.isArray(a)?(c=this.BindingType.EntireArray,this.resolvedProperty=a):this.propertyName=i;this.getValue=this.GetterByBindingType[c],this.setValue=this.SetterByBindingTypeAndVersioning[c][o]}unbind(){this.node=null,this.getValue=this._getValue_unbound,this.setValue=this._setValue_unbound}}ce.Composite=tv;ce.prototype.BindingType={Direct:0,EntireArray:1,ArrayElement:2,HasFromToArray:3};ce.prototype.Versioning={None:0,NeedsUpdate:1,MatrixWorldNeedsUpdate:2};ce.prototype.GetterByBindingType=[ce.prototype._getValue_direct,ce.prototype._getValue_array,ce.prototype._getValue_arrayElement,ce.prototype._getValue_toArray];ce.prototype.SetterByBindingTypeAndVersioning=[[ce.prototype._setValue_direct,ce.prototype._setValue_direct_setNeedsUpdate,ce.prototype._setValue_direct_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_array,ce.prototype._setValue_array_setNeedsUpdate,ce.prototype._setValue_array_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_arrayElement,ce.prototype._setValue_arrayElement_setNeedsUpdate,ce.prototype._setValue_arrayElement_setMatrixWorldNeedsUpdate],[ce.prototype._setValue_fromArray,ce.prototype._setValue_fromArray_setNeedsUpdate,ce.prototype._setValue_fromArray_setMatrixWorldNeedsUpdate]];const c0=new Xt;class tl{constructor(t,e,n=0,i=1/0){this.ray=new ya(t,e),this.near=n,this.far=i,this.camera=null,this.layers=new gu,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(t,e){this.ray.set(t,e)}setFromCamera(t,e){e.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(t.x,t.y,.5).unproject(e).sub(this.ray.origin).normalize(),this.camera=e):e.isOrthographicCamera?(this.ray.origin.set(t.x,t.y,e.projectionMatrix.elements[14]).unproject(e),this.ray.direction.set(0,0,-1).transformDirection(e.matrixWorld),this.camera=e):zt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return c0.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(c0),this}intersectObject(t,e=!0,n=[]){return Th(t,this,n,e),n.sort(l0),n}intersectObjects(t,e=!0,n=[]){for(let i=0,r=t.length;i<r;i++)Th(t[i],this,n,e);return n.sort(l0),n}}function l0(s,t){return s.distance-t.distance}function Th(s,t,e,n){let i=!0;if(s.layers.test(t.layers)&&s.raycast(t,e)===!1&&(i=!1),i===!0&&n===!0){const r=s.children;for(let a=0,o=r.length;a<o;a++)Th(r[a],t,e,!0)}}class Op{static{Op.prototype.isMatrix2=!0}constructor(t,e,n,i){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,e=0){for(let n=0;n<4;n++)this.elements[n]=t[n+e];return this}set(t,e,n,i){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=i,this}}function h0(s,t,e,n){const i=ev(n);switch(e){case _p:return s*t;case cu:return s*t/i.components*i.byteLength;case lu:return s*t/i.components*i.byteLength;case Cs:return s*t*2/i.components*i.byteLength;case hu:return s*t*2/i.components*i.byteLength;case Mp:return s*t*3/i.components*i.byteLength;case fn:return s*t*4/i.components*i.byteLength;case uu:return s*t*4/i.components*i.byteLength;case Lo:case No:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case Oo:case Uo:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case $l:case Jl:return Math.max(s,16)*Math.max(t,8)/4;case Kl:case Zl:return Math.max(s,8)*Math.max(t,8)/2;case Ql:case jl:case eh:case nh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*8;case th:case Xo:case ih:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case sh:return Math.floor((s+3)/4)*Math.floor((t+3)/4)*16;case rh:return Math.floor((s+4)/5)*Math.floor((t+3)/4)*16;case ah:return Math.floor((s+4)/5)*Math.floor((t+4)/5)*16;case oh:return Math.floor((s+5)/6)*Math.floor((t+4)/5)*16;case ch:return Math.floor((s+5)/6)*Math.floor((t+5)/6)*16;case lh:return Math.floor((s+7)/8)*Math.floor((t+4)/5)*16;case hh:return Math.floor((s+7)/8)*Math.floor((t+5)/6)*16;case uh:return Math.floor((s+7)/8)*Math.floor((t+7)/8)*16;case dh:return Math.floor((s+9)/10)*Math.floor((t+4)/5)*16;case fh:return Math.floor((s+9)/10)*Math.floor((t+5)/6)*16;case ph:return Math.floor((s+9)/10)*Math.floor((t+7)/8)*16;case mh:return Math.floor((s+9)/10)*Math.floor((t+9)/10)*16;case gh:return Math.floor((s+11)/12)*Math.floor((t+9)/10)*16;case vh:return Math.floor((s+11)/12)*Math.floor((t+11)/12)*16;case xh:case _h:case Mh:return Math.ceil(s/4)*Math.ceil(t/4)*16;case yh:case Sh:return Math.ceil(s/4)*Math.ceil(t/4)*8;case qo:case bh:return Math.ceil(s/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function ev(s){switch(s){case Dn:case mp:return{byteLength:1,components:1};case ga:case gp:case nn:return{byteLength:2,components:1};case au:case ou:return{byteLength:2,components:4};case Jn:case ru:case zn:return{byteLength:4,components:1};case vp:case xp:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${s}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:iu}}));typeof window<"u"&&(window.__THREE__?wt("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=iu);/**
|
|
519
519
|
* @license
|
|
520
520
|
* Copyright 2010-2026 Three.js Authors
|
|
521
521
|
* SPDX-License-Identifier: MIT
|
|
522
|
-
*/function Up(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&s!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function
|
|
522
|
+
*/function Up(){let s=null,t=!1,e=null,n=null;function i(r,a){e(r,a),n=s.requestAnimationFrame(i)}return{start:function(){t!==!0&&e!==null&&s!==null&&(n=s.requestAnimationFrame(i),t=!0)},stop:function(){s!==null&&s.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){s=r}}}function nv(s){const t=new WeakMap;function e(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=s.createBuffer();s.bindBuffer(c,d),s.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=s.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=s.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=s.HALF_FLOAT:f=s.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=s.SHORT;else if(l instanceof Uint32Array)f=s.UNSIGNED_INT;else if(l instanceof Int32Array)f=s.INT;else if(l instanceof Int8Array)f=s.BYTE;else if(l instanceof Uint8Array)f=s.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=s.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+l);return{buffer:d,type:f,bytesPerElement:l.BYTES_PER_ELEMENT,version:o.version,size:u}}function n(o,c,l){const h=c.array,u=c.updateRanges;if(s.bindBuffer(l,o),u.length===0)s.bufferSubData(l,0,h);else{u.sort((f,g)=>f.start-g.start);let d=0;for(let f=1;f<u.length;f++){const g=u[d],v=u[f];v.start<=g.start+g.count+1?g.count=Math.max(g.count,v.start+v.count-g.start):(++d,u[d]=v)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const v=u[f];s.bufferSubData(l,v.start*h.BYTES_PER_ELEMENT,h,v.start,v.count)}c.clearUpdateRanges()}c.onUploadCallback()}function i(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=t.get(o);c&&(s.deleteBuffer(c.buffer),t.delete(o))}function a(o,c){if(o.isInterleavedBufferAttribute&&(o=o.data),o.isGLBufferAttribute){const h=t.get(o);(!h||h.version<o.version)&&t.set(o,{buffer:o.buffer,type:o.type,bytesPerElement:o.elementSize,version:o.version});return}const l=t.get(o);if(l===void 0)t.set(o,e(o,c));else if(l.version<o.version){if(l.size!==o.array.byteLength)throw new Error("THREE.WebGLAttributes: The size of the buffer attribute's array buffer does not match the original size. Resizing buffer attributes is not supported.");n(l.buffer,o,c),l.version=o.version}}return{get:i,remove:r,update:a}}var iv=`#ifdef USE_ALPHAHASH
|
|
523
523
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
524
|
-
#endif`,
|
|
524
|
+
#endif`,sv=`#ifdef USE_ALPHAHASH
|
|
525
525
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
526
526
|
float hash2D( vec2 value ) {
|
|
527
527
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -556,20 +556,20 @@ input[type=range] {
|
|
|
556
556
|
: cases.z;
|
|
557
557
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
558
558
|
}
|
|
559
|
-
#endif`,
|
|
559
|
+
#endif`,rv=`#ifdef USE_ALPHAMAP
|
|
560
560
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
561
|
-
#endif`,
|
|
561
|
+
#endif`,av=`#ifdef USE_ALPHAMAP
|
|
562
562
|
uniform sampler2D alphaMap;
|
|
563
|
-
#endif`,
|
|
563
|
+
#endif`,ov=`#ifdef USE_ALPHATEST
|
|
564
564
|
#ifdef ALPHA_TO_COVERAGE
|
|
565
565
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
566
566
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
567
567
|
#else
|
|
568
568
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
569
569
|
#endif
|
|
570
|
-
#endif`,
|
|
570
|
+
#endif`,cv=`#ifdef USE_ALPHATEST
|
|
571
571
|
uniform float alphaTest;
|
|
572
|
-
#endif`,
|
|
572
|
+
#endif`,lv=`#ifdef USE_AOMAP
|
|
573
573
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
574
574
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
575
575
|
#if defined( USE_CLEARCOAT )
|
|
@@ -582,10 +582,10 @@ input[type=range] {
|
|
|
582
582
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
583
583
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
584
584
|
#endif
|
|
585
|
-
#endif`,
|
|
585
|
+
#endif`,hv=`#ifdef USE_AOMAP
|
|
586
586
|
uniform sampler2D aoMap;
|
|
587
587
|
uniform float aoMapIntensity;
|
|
588
|
-
#endif`,
|
|
588
|
+
#endif`,uv=`#ifdef USE_BATCHING
|
|
589
589
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
590
590
|
#define gl_DrawID _gl_DrawID
|
|
591
591
|
uniform int _gl_DrawID;
|
|
@@ -619,15 +619,15 @@ input[type=range] {
|
|
|
619
619
|
int y = j / size;
|
|
620
620
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
621
621
|
}
|
|
622
|
-
#endif`,
|
|
622
|
+
#endif`,dv=`#ifdef USE_BATCHING
|
|
623
623
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
624
|
-
#endif`,
|
|
624
|
+
#endif`,fv=`vec3 transformed = vec3( position );
|
|
625
625
|
#ifdef USE_ALPHAHASH
|
|
626
626
|
vPosition = vec3( position );
|
|
627
|
-
#endif`,
|
|
627
|
+
#endif`,pv=`vec3 objectNormal = vec3( normal );
|
|
628
628
|
#ifdef USE_TANGENT
|
|
629
629
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
630
|
-
#endif`,
|
|
630
|
+
#endif`,mv=`float G_BlinnPhong_Implicit( ) {
|
|
631
631
|
return 0.25;
|
|
632
632
|
}
|
|
633
633
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -641,7 +641,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
641
641
|
float G = G_BlinnPhong_Implicit( );
|
|
642
642
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
643
643
|
return F * ( G * D );
|
|
644
|
-
} // validated`,
|
|
644
|
+
} // validated`,gv=`#ifdef USE_IRIDESCENCE
|
|
645
645
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
646
646
|
3.2404542, -0.9692660, 0.0556434,
|
|
647
647
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -704,7 +704,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
704
704
|
}
|
|
705
705
|
return max( I, vec3( 0.0 ) );
|
|
706
706
|
}
|
|
707
|
-
#endif`,
|
|
707
|
+
#endif`,vv=`#ifdef USE_BUMPMAP
|
|
708
708
|
uniform sampler2D bumpMap;
|
|
709
709
|
uniform float bumpScale;
|
|
710
710
|
vec2 dHdxy_fwd() {
|
|
@@ -725,7 +725,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
725
725
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
726
726
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
727
727
|
}
|
|
728
|
-
#endif`,
|
|
728
|
+
#endif`,xv=`#if NUM_CLIPPING_PLANES > 0
|
|
729
729
|
vec4 plane;
|
|
730
730
|
#ifdef ALPHA_TO_COVERAGE
|
|
731
731
|
float distanceToPlane, distanceGradient;
|
|
@@ -771,20 +771,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
771
771
|
if ( clipped ) discard;
|
|
772
772
|
#endif
|
|
773
773
|
#endif
|
|
774
|
-
#endif`,
|
|
774
|
+
#endif`,_v=`#if NUM_CLIPPING_PLANES > 0
|
|
775
775
|
varying vec3 vClipPosition;
|
|
776
776
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
777
|
-
#endif`,
|
|
777
|
+
#endif`,Mv=`#if NUM_CLIPPING_PLANES > 0
|
|
778
778
|
varying vec3 vClipPosition;
|
|
779
|
-
#endif`,
|
|
779
|
+
#endif`,yv=`#if NUM_CLIPPING_PLANES > 0
|
|
780
780
|
vClipPosition = - mvPosition.xyz;
|
|
781
|
-
#endif`,
|
|
781
|
+
#endif`,Sv=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
782
782
|
diffuseColor *= vColor;
|
|
783
|
-
#endif`,
|
|
783
|
+
#endif`,bv=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
784
784
|
varying vec4 vColor;
|
|
785
|
-
#endif`,
|
|
785
|
+
#endif`,Ev=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
786
786
|
varying vec4 vColor;
|
|
787
|
-
#endif`,
|
|
787
|
+
#endif`,wv=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
788
788
|
vColor = vec4( 1.0 );
|
|
789
789
|
#endif
|
|
790
790
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -797,7 +797,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
797
797
|
#endif
|
|
798
798
|
#ifdef USE_BATCHING_COLOR
|
|
799
799
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
800
|
-
#endif`,
|
|
800
|
+
#endif`,Av=`#define PI 3.141592653589793
|
|
801
801
|
#define PI2 6.283185307179586
|
|
802
802
|
#define PI_HALF 1.5707963267948966
|
|
803
803
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -868,7 +868,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
868
868
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
869
869
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
870
870
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
871
|
-
} // validated`,
|
|
871
|
+
} // validated`,Tv=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
872
872
|
#define cubeUV_minMipLevel 4.0
|
|
873
873
|
#define cubeUV_minTileSize 16.0
|
|
874
874
|
float getFace( vec3 direction ) {
|
|
@@ -961,7 +961,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
961
961
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
962
962
|
}
|
|
963
963
|
}
|
|
964
|
-
#endif`,
|
|
964
|
+
#endif`,Rv=`vec3 transformedNormal = objectNormal;
|
|
965
965
|
#ifdef USE_TANGENT
|
|
966
966
|
vec3 transformedTangent = objectTangent;
|
|
967
967
|
#endif
|
|
@@ -987,21 +987,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
987
987
|
#endif
|
|
988
988
|
#ifdef USE_TANGENT
|
|
989
989
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
990
|
-
#endif`,
|
|
990
|
+
#endif`,Dv=`#ifdef USE_DISPLACEMENTMAP
|
|
991
991
|
uniform sampler2D displacementMap;
|
|
992
992
|
uniform float displacementScale;
|
|
993
993
|
uniform float displacementBias;
|
|
994
|
-
#endif`,
|
|
994
|
+
#endif`,Cv=`#ifdef USE_DISPLACEMENTMAP
|
|
995
995
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
996
|
-
#endif`,
|
|
996
|
+
#endif`,Pv=`#ifdef USE_EMISSIVEMAP
|
|
997
997
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
998
998
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
999
999
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
1000
1000
|
#endif
|
|
1001
1001
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
1002
|
-
#endif`,
|
|
1002
|
+
#endif`,Iv=`#ifdef USE_EMISSIVEMAP
|
|
1003
1003
|
uniform sampler2D emissiveMap;
|
|
1004
|
-
#endif`,
|
|
1004
|
+
#endif`,Lv="gl_FragColor = linearToOutputTexel( gl_FragColor );",Nv=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
1005
1005
|
return value;
|
|
1006
1006
|
}
|
|
1007
1007
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -1009,7 +1009,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
1011
1011
|
return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );
|
|
1012
|
-
}`,
|
|
1012
|
+
}`,Ov=`#ifdef USE_ENVMAP
|
|
1013
1013
|
#ifdef ENV_WORLDPOS
|
|
1014
1014
|
vec3 cameraToFrag;
|
|
1015
1015
|
if ( isOrthographic ) {
|
|
@@ -1036,7 +1036,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1036
1036
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
1037
1037
|
#endif
|
|
1038
1038
|
#endif
|
|
1039
|
-
#endif`,
|
|
1039
|
+
#endif`,Uv=`#ifdef USE_ENVMAP
|
|
1040
1040
|
uniform float envMapIntensity;
|
|
1041
1041
|
uniform mat3 envMapRotation;
|
|
1042
1042
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -1044,7 +1044,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1044
1044
|
#else
|
|
1045
1045
|
uniform sampler2D envMap;
|
|
1046
1046
|
#endif
|
|
1047
|
-
#endif`,
|
|
1047
|
+
#endif`,Fv=`#ifdef USE_ENVMAP
|
|
1048
1048
|
uniform float reflectivity;
|
|
1049
1049
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
1050
1050
|
#define ENV_WORLDPOS
|
|
@@ -1055,7 +1055,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1055
1055
|
#else
|
|
1056
1056
|
varying vec3 vReflect;
|
|
1057
1057
|
#endif
|
|
1058
|
-
#endif`,
|
|
1058
|
+
#endif`,zv=`#ifdef USE_ENVMAP
|
|
1059
1059
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
1060
1060
|
#define ENV_WORLDPOS
|
|
1061
1061
|
#endif
|
|
@@ -1066,7 +1066,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1066
1066
|
varying vec3 vReflect;
|
|
1067
1067
|
uniform float refractionRatio;
|
|
1068
1068
|
#endif
|
|
1069
|
-
#endif`,
|
|
1069
|
+
#endif`,Bv=`#ifdef USE_ENVMAP
|
|
1070
1070
|
#ifdef ENV_WORLDPOS
|
|
1071
1071
|
vWorldPosition = worldPosition.xyz;
|
|
1072
1072
|
#else
|
|
@@ -1083,18 +1083,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1083
1083
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
1084
1084
|
#endif
|
|
1085
1085
|
#endif
|
|
1086
|
-
#endif`,
|
|
1086
|
+
#endif`,kv=`#ifdef USE_FOG
|
|
1087
1087
|
vFogDepth = - mvPosition.z;
|
|
1088
|
-
#endif`,
|
|
1088
|
+
#endif`,Hv=`#ifdef USE_FOG
|
|
1089
1089
|
varying float vFogDepth;
|
|
1090
|
-
#endif`,
|
|
1090
|
+
#endif`,Gv=`#ifdef USE_FOG
|
|
1091
1091
|
#ifdef FOG_EXP2
|
|
1092
1092
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
1093
1093
|
#else
|
|
1094
1094
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
1095
1095
|
#endif
|
|
1096
1096
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
1097
|
-
#endif`,
|
|
1097
|
+
#endif`,Vv=`#ifdef USE_FOG
|
|
1098
1098
|
uniform vec3 fogColor;
|
|
1099
1099
|
varying float vFogDepth;
|
|
1100
1100
|
#ifdef FOG_EXP2
|
|
@@ -1103,7 +1103,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1103
1103
|
uniform float fogNear;
|
|
1104
1104
|
uniform float fogFar;
|
|
1105
1105
|
#endif
|
|
1106
|
-
#endif`,
|
|
1106
|
+
#endif`,Wv=`#ifdef USE_GRADIENTMAP
|
|
1107
1107
|
uniform sampler2D gradientMap;
|
|
1108
1108
|
#endif
|
|
1109
1109
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -1115,12 +1115,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
1115
1115
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
1116
1116
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
1117
1117
|
#endif
|
|
1118
|
-
}`,
|
|
1118
|
+
}`,Xv=`#ifdef USE_LIGHTMAP
|
|
1119
1119
|
uniform sampler2D lightMap;
|
|
1120
1120
|
uniform float lightMapIntensity;
|
|
1121
|
-
#endif`,
|
|
1121
|
+
#endif`,qv=`LambertMaterial material;
|
|
1122
1122
|
material.diffuseColor = diffuseColor.rgb;
|
|
1123
|
-
material.specularStrength = specularStrength;`,
|
|
1123
|
+
material.specularStrength = specularStrength;`,Yv=`varying vec3 vViewPosition;
|
|
1124
1124
|
struct LambertMaterial {
|
|
1125
1125
|
vec3 diffuseColor;
|
|
1126
1126
|
float specularStrength;
|
|
@@ -1134,7 +1134,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
1134
1134
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1135
1135
|
}
|
|
1136
1136
|
#define RE_Direct RE_Direct_Lambert
|
|
1137
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
1137
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Kv=`uniform bool receiveShadow;
|
|
1138
1138
|
uniform vec3 ambientLightColor;
|
|
1139
1139
|
#if defined( USE_LIGHT_PROBES )
|
|
1140
1140
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -1251,7 +1251,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1251
1251
|
return irradiance;
|
|
1252
1252
|
}
|
|
1253
1253
|
#endif
|
|
1254
|
-
#include <lightprobes_pars_fragment
|
|
1254
|
+
#include <lightprobes_pars_fragment>`,$v=`#ifdef USE_ENVMAP
|
|
1255
1255
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
1256
1256
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
1257
1257
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -1284,8 +1284,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1284
1284
|
#endif
|
|
1285
1285
|
}
|
|
1286
1286
|
#endif
|
|
1287
|
-
#endif`,
|
|
1288
|
-
material.diffuseColor = diffuseColor.rgb
|
|
1287
|
+
#endif`,Zv=`ToonMaterial material;
|
|
1288
|
+
material.diffuseColor = diffuseColor.rgb;`,Jv=`varying vec3 vViewPosition;
|
|
1289
1289
|
struct ToonMaterial {
|
|
1290
1290
|
vec3 diffuseColor;
|
|
1291
1291
|
};
|
|
@@ -1297,11 +1297,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
1297
1297
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1298
1298
|
}
|
|
1299
1299
|
#define RE_Direct RE_Direct_Toon
|
|
1300
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1300
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Qv=`BlinnPhongMaterial material;
|
|
1301
1301
|
material.diffuseColor = diffuseColor.rgb;
|
|
1302
1302
|
material.specularColor = specular;
|
|
1303
1303
|
material.specularShininess = shininess;
|
|
1304
|
-
material.specularStrength = specularStrength;`,
|
|
1304
|
+
material.specularStrength = specularStrength;`,jv=`varying vec3 vViewPosition;
|
|
1305
1305
|
struct BlinnPhongMaterial {
|
|
1306
1306
|
vec3 diffuseColor;
|
|
1307
1307
|
vec3 specularColor;
|
|
@@ -1318,7 +1318,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1318
1318
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1319
1319
|
}
|
|
1320
1320
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1321
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1321
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,tx=`PhysicalMaterial material;
|
|
1322
1322
|
material.diffuseColor = diffuseColor.rgb;
|
|
1323
1323
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1324
1324
|
material.metalness = metalnessFactor;
|
|
@@ -1408,7 +1408,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1408
1408
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1409
1409
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1410
1410
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1411
|
-
#endif`,
|
|
1411
|
+
#endif`,ex=`uniform sampler2D dfgLUT;
|
|
1412
1412
|
struct PhysicalMaterial {
|
|
1413
1413
|
vec3 diffuseColor;
|
|
1414
1414
|
vec3 diffuseContribution;
|
|
@@ -1768,7 +1768,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1768
1768
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1769
1769
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1770
1770
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1771
|
-
}`,
|
|
1771
|
+
}`,nx=`
|
|
1772
1772
|
vec3 geometryPosition = - vViewPosition;
|
|
1773
1773
|
vec3 geometryNormal = normal;
|
|
1774
1774
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1890,7 +1890,7 @@ IncidentLight directLight;
|
|
|
1890
1890
|
#if defined( RE_IndirectSpecular )
|
|
1891
1891
|
vec3 radiance = vec3( 0.0 );
|
|
1892
1892
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1893
|
-
#endif`,
|
|
1893
|
+
#endif`,ix=`#if defined( RE_IndirectDiffuse )
|
|
1894
1894
|
#ifdef USE_LIGHTMAP
|
|
1895
1895
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1896
1896
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1911,7 +1911,7 @@ IncidentLight directLight;
|
|
|
1911
1911
|
#ifdef USE_CLEARCOAT
|
|
1912
1912
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1913
1913
|
#endif
|
|
1914
|
-
#endif`,
|
|
1914
|
+
#endif`,sx=`#if defined( RE_IndirectDiffuse )
|
|
1915
1915
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1916
1916
|
irradiance += iblIrradiance;
|
|
1917
1917
|
#endif
|
|
@@ -1919,7 +1919,7 @@ IncidentLight directLight;
|
|
|
1919
1919
|
#endif
|
|
1920
1920
|
#if defined( RE_IndirectSpecular )
|
|
1921
1921
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1922
|
-
#endif`,
|
|
1922
|
+
#endif`,rx=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1923
1923
|
uniform highp sampler3D probesSH;
|
|
1924
1924
|
uniform vec3 probesMin;
|
|
1925
1925
|
uniform vec3 probesMax;
|
|
@@ -1964,27 +1964,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1964
1964
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
1965
1965
|
return max( result, vec3( 0.0 ) );
|
|
1966
1966
|
}
|
|
1967
|
-
#endif`,
|
|
1967
|
+
#endif`,ax=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1968
1968
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
1969
|
-
#endif`,
|
|
1969
|
+
#endif`,ox=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
1970
1970
|
uniform float logDepthBufFC;
|
|
1971
1971
|
varying float vFragDepth;
|
|
1972
1972
|
varying float vIsPerspective;
|
|
1973
|
-
#endif`,
|
|
1973
|
+
#endif`,cx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1974
1974
|
varying float vFragDepth;
|
|
1975
1975
|
varying float vIsPerspective;
|
|
1976
|
-
#endif`,
|
|
1976
|
+
#endif`,lx=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
1977
1977
|
vFragDepth = 1.0 + gl_Position.w;
|
|
1978
1978
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
1979
|
-
#endif`,
|
|
1979
|
+
#endif`,hx=`#ifdef USE_MAP
|
|
1980
1980
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
1981
1981
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
1982
1982
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
1983
1983
|
#endif
|
|
1984
1984
|
diffuseColor *= sampledDiffuseColor;
|
|
1985
|
-
#endif`,
|
|
1985
|
+
#endif`,ux=`#ifdef USE_MAP
|
|
1986
1986
|
uniform sampler2D map;
|
|
1987
|
-
#endif`,
|
|
1987
|
+
#endif`,dx=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
1988
1988
|
#if defined( USE_POINTS_UV )
|
|
1989
1989
|
vec2 uv = vUv;
|
|
1990
1990
|
#else
|
|
@@ -1996,7 +1996,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
1996
1996
|
#endif
|
|
1997
1997
|
#ifdef USE_ALPHAMAP
|
|
1998
1998
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
1999
|
-
#endif`,
|
|
1999
|
+
#endif`,fx=`#if defined( USE_POINTS_UV )
|
|
2000
2000
|
varying vec2 vUv;
|
|
2001
2001
|
#else
|
|
2002
2002
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -2008,19 +2008,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2008
2008
|
#endif
|
|
2009
2009
|
#ifdef USE_ALPHAMAP
|
|
2010
2010
|
uniform sampler2D alphaMap;
|
|
2011
|
-
#endif`,
|
|
2011
|
+
#endif`,px=`float metalnessFactor = metalness;
|
|
2012
2012
|
#ifdef USE_METALNESSMAP
|
|
2013
2013
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
2014
2014
|
metalnessFactor *= texelMetalness.b;
|
|
2015
|
-
#endif`,
|
|
2015
|
+
#endif`,mx=`#ifdef USE_METALNESSMAP
|
|
2016
2016
|
uniform sampler2D metalnessMap;
|
|
2017
|
-
#endif`,
|
|
2017
|
+
#endif`,gx=`#ifdef USE_INSTANCING_MORPH
|
|
2018
2018
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
2019
2019
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
2020
2020
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2021
2021
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
2022
2022
|
}
|
|
2023
|
-
#endif`,
|
|
2023
|
+
#endif`,vx=`#if defined( USE_MORPHCOLORS )
|
|
2024
2024
|
vColor *= morphTargetBaseInfluence;
|
|
2025
2025
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2026
2026
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -2029,12 +2029,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2029
2029
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
2030
2030
|
#endif
|
|
2031
2031
|
}
|
|
2032
|
-
#endif`,
|
|
2032
|
+
#endif`,xx=`#ifdef USE_MORPHNORMALS
|
|
2033
2033
|
objectNormal *= morphTargetBaseInfluence;
|
|
2034
2034
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2035
2035
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
2036
2036
|
}
|
|
2037
|
-
#endif`,
|
|
2037
|
+
#endif`,_x=`#ifdef USE_MORPHTARGETS
|
|
2038
2038
|
#ifndef USE_INSTANCING_MORPH
|
|
2039
2039
|
uniform float morphTargetBaseInfluence;
|
|
2040
2040
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -2048,12 +2048,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2048
2048
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
2049
2049
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
2050
2050
|
}
|
|
2051
|
-
#endif`,
|
|
2051
|
+
#endif`,Mx=`#ifdef USE_MORPHTARGETS
|
|
2052
2052
|
transformed *= morphTargetBaseInfluence;
|
|
2053
2053
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2054
2054
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
2055
2055
|
}
|
|
2056
|
-
#endif`,
|
|
2056
|
+
#endif`,yx=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
2057
2057
|
#ifdef FLAT_SHADED
|
|
2058
2058
|
vec3 fdx = dFdx( vViewPosition );
|
|
2059
2059
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -2094,7 +2094,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2094
2094
|
tbn2[1] *= faceDirection;
|
|
2095
2095
|
#endif
|
|
2096
2096
|
#endif
|
|
2097
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
2097
|
+
vec3 nonPerturbedNormal = normal;`,Sx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
2098
2098
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2099
2099
|
#ifdef FLIP_SIDED
|
|
2100
2100
|
normal = - normal;
|
|
@@ -2112,19 +2112,19 @@ vec3 nonPerturbedNormal = normal;`,Mx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2112
2112
|
normal = normalize( tbn * mapN );
|
|
2113
2113
|
#elif defined( USE_BUMPMAP )
|
|
2114
2114
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
2115
|
-
#endif`,
|
|
2115
|
+
#endif`,bx=`#ifndef FLAT_SHADED
|
|
2116
2116
|
varying vec3 vNormal;
|
|
2117
2117
|
#ifdef USE_TANGENT
|
|
2118
2118
|
varying vec3 vTangent;
|
|
2119
2119
|
varying vec3 vBitangent;
|
|
2120
2120
|
#endif
|
|
2121
|
-
#endif`,
|
|
2121
|
+
#endif`,Ex=`#ifndef FLAT_SHADED
|
|
2122
2122
|
varying vec3 vNormal;
|
|
2123
2123
|
#ifdef USE_TANGENT
|
|
2124
2124
|
varying vec3 vTangent;
|
|
2125
2125
|
varying vec3 vBitangent;
|
|
2126
2126
|
#endif
|
|
2127
|
-
#endif`,
|
|
2127
|
+
#endif`,wx=`#ifndef FLAT_SHADED
|
|
2128
2128
|
vNormal = normalize( transformedNormal );
|
|
2129
2129
|
#ifdef USE_TANGENT
|
|
2130
2130
|
vTangent = normalize( transformedTangent );
|
|
@@ -2133,7 +2133,7 @@ vec3 nonPerturbedNormal = normal;`,Mx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2133
2133
|
vBitangent = - vBitangent;
|
|
2134
2134
|
#endif
|
|
2135
2135
|
#endif
|
|
2136
|
-
#endif`,
|
|
2136
|
+
#endif`,Ax=`#ifdef USE_NORMALMAP
|
|
2137
2137
|
uniform sampler2D normalMap;
|
|
2138
2138
|
uniform vec2 normalScale;
|
|
2139
2139
|
#endif
|
|
@@ -2155,13 +2155,13 @@ vec3 nonPerturbedNormal = normal;`,Mx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2155
2155
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
2156
2156
|
return mat3( T * scale, B * scale, N );
|
|
2157
2157
|
}
|
|
2158
|
-
#endif`,
|
|
2158
|
+
#endif`,Tx=`#ifdef USE_CLEARCOAT
|
|
2159
2159
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
2160
|
-
#endif`,
|
|
2160
|
+
#endif`,Rx=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2161
2161
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2162
2162
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
2163
2163
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
2164
|
-
#endif`,
|
|
2164
|
+
#endif`,Dx=`#ifdef USE_CLEARCOATMAP
|
|
2165
2165
|
uniform sampler2D clearcoatMap;
|
|
2166
2166
|
#endif
|
|
2167
2167
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -2170,18 +2170,18 @@ vec3 nonPerturbedNormal = normal;`,Mx=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2170
2170
|
#endif
|
|
2171
2171
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2172
2172
|
uniform sampler2D clearcoatRoughnessMap;
|
|
2173
|
-
#endif`,
|
|
2173
|
+
#endif`,Cx=`#ifdef USE_IRIDESCENCEMAP
|
|
2174
2174
|
uniform sampler2D iridescenceMap;
|
|
2175
2175
|
#endif
|
|
2176
2176
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2177
2177
|
uniform sampler2D iridescenceThicknessMap;
|
|
2178
|
-
#endif`,
|
|
2178
|
+
#endif`,Px=`#ifdef OPAQUE
|
|
2179
2179
|
diffuseColor.a = 1.0;
|
|
2180
2180
|
#endif
|
|
2181
2181
|
#ifdef USE_TRANSMISSION
|
|
2182
2182
|
diffuseColor.a *= material.transmissionAlpha;
|
|
2183
2183
|
#endif
|
|
2184
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,
|
|
2184
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,Ix=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
2185
2185
|
return normalize( normal ) * 0.5 + 0.5;
|
|
2186
2186
|
}
|
|
2187
2187
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -2260,9 +2260,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2260
2260
|
#else
|
|
2261
2261
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
2262
2262
|
#endif
|
|
2263
|
-
}`,
|
|
2263
|
+
}`,Lx=`#ifdef PREMULTIPLIED_ALPHA
|
|
2264
2264
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2265
|
-
#endif`,
|
|
2265
|
+
#endif`,Nx=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
2266
2266
|
#ifdef USE_BATCHING
|
|
2267
2267
|
mvPosition = batchingMatrix * mvPosition;
|
|
2268
2268
|
#endif
|
|
@@ -2270,22 +2270,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2270
2270
|
mvPosition = instanceMatrix * mvPosition;
|
|
2271
2271
|
#endif
|
|
2272
2272
|
mvPosition = modelViewMatrix * mvPosition;
|
|
2273
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
2273
|
+
gl_Position = projectionMatrix * mvPosition;`,Ox=`#ifdef DITHERING
|
|
2274
2274
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
2275
|
-
#endif`,
|
|
2275
|
+
#endif`,Ux=`#ifdef DITHERING
|
|
2276
2276
|
vec3 dithering( vec3 color ) {
|
|
2277
2277
|
float grid_position = rand( gl_FragCoord.xy );
|
|
2278
2278
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
2279
2279
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
2280
2280
|
return color + dither_shift_RGB;
|
|
2281
2281
|
}
|
|
2282
|
-
#endif`,
|
|
2282
|
+
#endif`,Fx=`float roughnessFactor = roughness;
|
|
2283
2283
|
#ifdef USE_ROUGHNESSMAP
|
|
2284
2284
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
2285
2285
|
roughnessFactor *= texelRoughness.g;
|
|
2286
|
-
#endif`,
|
|
2286
|
+
#endif`,zx=`#ifdef USE_ROUGHNESSMAP
|
|
2287
2287
|
uniform sampler2D roughnessMap;
|
|
2288
|
-
#endif`,
|
|
2288
|
+
#endif`,Bx=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2289
2289
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2290
2290
|
#endif
|
|
2291
2291
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2485,7 +2485,7 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2485
2485
|
}
|
|
2486
2486
|
#endif
|
|
2487
2487
|
#endif
|
|
2488
|
-
#endif`,
|
|
2488
|
+
#endif`,kx=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2489
2489
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2490
2490
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2491
2491
|
#endif
|
|
@@ -2526,7 +2526,7 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2526
2526
|
};
|
|
2527
2527
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2528
2528
|
#endif
|
|
2529
|
-
#endif`,
|
|
2529
|
+
#endif`,Hx=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2530
2530
|
#ifdef HAS_NORMAL
|
|
2531
2531
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2532
2532
|
#else
|
|
@@ -2562,7 +2562,7 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2562
2562
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2563
2563
|
}
|
|
2564
2564
|
#pragma unroll_loop_end
|
|
2565
|
-
#endif`,
|
|
2565
|
+
#endif`,Gx=`float getShadowMask() {
|
|
2566
2566
|
float shadow = 1.0;
|
|
2567
2567
|
#ifdef USE_SHADOWMAP
|
|
2568
2568
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2594,12 +2594,12 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2594
2594
|
#endif
|
|
2595
2595
|
#endif
|
|
2596
2596
|
return shadow;
|
|
2597
|
-
}`,
|
|
2597
|
+
}`,Vx=`#ifdef USE_SKINNING
|
|
2598
2598
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2599
2599
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2600
2600
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2601
2601
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2602
|
-
#endif`,
|
|
2602
|
+
#endif`,Wx=`#ifdef USE_SKINNING
|
|
2603
2603
|
uniform mat4 bindMatrix;
|
|
2604
2604
|
uniform mat4 bindMatrixInverse;
|
|
2605
2605
|
uniform highp sampler2D boneTexture;
|
|
@@ -2614,7 +2614,7 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2614
2614
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2615
2615
|
return mat4( v1, v2, v3, v4 );
|
|
2616
2616
|
}
|
|
2617
|
-
#endif`,
|
|
2617
|
+
#endif`,Xx=`#ifdef USE_SKINNING
|
|
2618
2618
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2619
2619
|
vec4 skinned = vec4( 0.0 );
|
|
2620
2620
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2622,7 +2622,7 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2622
2622
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2623
2623
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2624
2624
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2625
|
-
#endif`,
|
|
2625
|
+
#endif`,qx=`#ifdef USE_SKINNING
|
|
2626
2626
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2627
2627
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2628
2628
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2633,17 +2633,17 @@ gl_Position = projectionMatrix * mvPosition;`,Lx=`#ifdef DITHERING
|
|
|
2633
2633
|
#ifdef USE_TANGENT
|
|
2634
2634
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2635
2635
|
#endif
|
|
2636
|
-
#endif`,
|
|
2636
|
+
#endif`,Yx=`float specularStrength;
|
|
2637
2637
|
#ifdef USE_SPECULARMAP
|
|
2638
2638
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2639
2639
|
specularStrength = texelSpecular.r;
|
|
2640
2640
|
#else
|
|
2641
2641
|
specularStrength = 1.0;
|
|
2642
|
-
#endif`,
|
|
2642
|
+
#endif`,Kx=`#ifdef USE_SPECULARMAP
|
|
2643
2643
|
uniform sampler2D specularMap;
|
|
2644
|
-
#endif
|
|
2644
|
+
#endif`,$x=`#if defined( TONE_MAPPING )
|
|
2645
2645
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2646
|
-
#endif`,
|
|
2646
|
+
#endif`,Zx=`#ifndef saturate
|
|
2647
2647
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2648
2648
|
#endif
|
|
2649
2649
|
uniform float toneMappingExposure;
|
|
@@ -2740,7 +2740,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2740
2740
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2741
2741
|
return mix( color, vec3( newPeak ), g );
|
|
2742
2742
|
}
|
|
2743
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }
|
|
2743
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,Jx=`#ifdef USE_TRANSMISSION
|
|
2744
2744
|
material.transmission = transmission;
|
|
2745
2745
|
material.transmissionAlpha = 1.0;
|
|
2746
2746
|
material.thickness = thickness;
|
|
@@ -2761,7 +2761,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
2761
2761
|
material.attenuationColor, material.attenuationDistance );
|
|
2762
2762
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2763
2763
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2764
|
-
#endif`,
|
|
2764
|
+
#endif`,Qx=`#ifdef USE_TRANSMISSION
|
|
2765
2765
|
uniform float transmission;
|
|
2766
2766
|
uniform float thickness;
|
|
2767
2767
|
uniform float attenuationDistance;
|
|
@@ -2887,7 +2887,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
2887
2887
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2888
2888
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2889
2889
|
}
|
|
2890
|
-
#endif`,
|
|
2890
|
+
#endif`,jx=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2891
2891
|
varying vec2 vUv;
|
|
2892
2892
|
#endif
|
|
2893
2893
|
#ifdef USE_MAP
|
|
@@ -2957,7 +2957,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
2957
2957
|
#ifdef USE_THICKNESSMAP
|
|
2958
2958
|
uniform mat3 thicknessMapTransform;
|
|
2959
2959
|
varying vec2 vThicknessMapUv;
|
|
2960
|
-
#endif`,
|
|
2960
|
+
#endif`,t_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2961
2961
|
varying vec2 vUv;
|
|
2962
2962
|
#endif
|
|
2963
2963
|
#ifdef USE_MAP
|
|
@@ -3051,7 +3051,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
3051
3051
|
#ifdef USE_THICKNESSMAP
|
|
3052
3052
|
uniform mat3 thicknessMapTransform;
|
|
3053
3053
|
varying vec2 vThicknessMapUv;
|
|
3054
|
-
#endif`,
|
|
3054
|
+
#endif`,e_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3055
3055
|
vUv = vec3( uv, 1 ).xy;
|
|
3056
3056
|
#endif
|
|
3057
3057
|
#ifdef USE_MAP
|
|
@@ -3122,7 +3122,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
3122
3122
|
#endif
|
|
3123
3123
|
#ifdef USE_THICKNESSMAP
|
|
3124
3124
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
3125
|
-
#endif`,
|
|
3125
|
+
#endif`,n_=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
3126
3126
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
3127
3127
|
#ifdef USE_BATCHING
|
|
3128
3128
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -3131,12 +3131,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,$x=`#ifdef USE_TRANSMISS
|
|
|
3131
3131
|
worldPosition = instanceMatrix * worldPosition;
|
|
3132
3132
|
#endif
|
|
3133
3133
|
worldPosition = modelMatrix * worldPosition;
|
|
3134
|
-
#endif`;const
|
|
3134
|
+
#endif`;const i_=`varying vec2 vUv;
|
|
3135
3135
|
uniform mat3 uvTransform;
|
|
3136
3136
|
void main() {
|
|
3137
3137
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3138
3138
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
3139
|
-
}`,
|
|
3139
|
+
}`,s_=`uniform sampler2D t2D;
|
|
3140
3140
|
uniform float backgroundIntensity;
|
|
3141
3141
|
varying vec2 vUv;
|
|
3142
3142
|
void main() {
|
|
@@ -3148,14 +3148,14 @@ void main() {
|
|
|
3148
3148
|
gl_FragColor = texColor;
|
|
3149
3149
|
#include <tonemapping_fragment>
|
|
3150
3150
|
#include <colorspace_fragment>
|
|
3151
|
-
}`,
|
|
3151
|
+
}`,r_=`varying vec3 vWorldDirection;
|
|
3152
3152
|
#include <common>
|
|
3153
3153
|
void main() {
|
|
3154
3154
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3155
3155
|
#include <begin_vertex>
|
|
3156
3156
|
#include <project_vertex>
|
|
3157
3157
|
gl_Position.z = gl_Position.w;
|
|
3158
|
-
}`,
|
|
3158
|
+
}`,a_=`#ifdef ENVMAP_TYPE_CUBE
|
|
3159
3159
|
uniform samplerCube envMap;
|
|
3160
3160
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
3161
3161
|
uniform sampler2D envMap;
|
|
@@ -3177,14 +3177,14 @@ void main() {
|
|
|
3177
3177
|
gl_FragColor = texColor;
|
|
3178
3178
|
#include <tonemapping_fragment>
|
|
3179
3179
|
#include <colorspace_fragment>
|
|
3180
|
-
}`,
|
|
3180
|
+
}`,o_=`varying vec3 vWorldDirection;
|
|
3181
3181
|
#include <common>
|
|
3182
3182
|
void main() {
|
|
3183
3183
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3184
3184
|
#include <begin_vertex>
|
|
3185
3185
|
#include <project_vertex>
|
|
3186
3186
|
gl_Position.z = gl_Position.w;
|
|
3187
|
-
}`,
|
|
3187
|
+
}`,c_=`uniform samplerCube tCube;
|
|
3188
3188
|
uniform float tFlip;
|
|
3189
3189
|
uniform float opacity;
|
|
3190
3190
|
varying vec3 vWorldDirection;
|
|
@@ -3194,7 +3194,7 @@ void main() {
|
|
|
3194
3194
|
gl_FragColor.a *= opacity;
|
|
3195
3195
|
#include <tonemapping_fragment>
|
|
3196
3196
|
#include <colorspace_fragment>
|
|
3197
|
-
}`,
|
|
3197
|
+
}`,l_=`#include <common>
|
|
3198
3198
|
#include <batching_pars_vertex>
|
|
3199
3199
|
#include <uv_pars_vertex>
|
|
3200
3200
|
#include <displacementmap_pars_vertex>
|
|
@@ -3221,7 +3221,7 @@ void main() {
|
|
|
3221
3221
|
#include <logdepthbuf_vertex>
|
|
3222
3222
|
#include <clipping_planes_vertex>
|
|
3223
3223
|
vHighPrecisionZW = gl_Position.zw;
|
|
3224
|
-
}`,
|
|
3224
|
+
}`,h_=`#if DEPTH_PACKING == 3200
|
|
3225
3225
|
uniform float opacity;
|
|
3226
3226
|
#endif
|
|
3227
3227
|
#include <common>
|
|
@@ -3259,7 +3259,7 @@ void main() {
|
|
|
3259
3259
|
#elif DEPTH_PACKING == 3203
|
|
3260
3260
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
3261
3261
|
#endif
|
|
3262
|
-
}`,
|
|
3262
|
+
}`,u_=`#define DISTANCE
|
|
3263
3263
|
varying vec3 vWorldPosition;
|
|
3264
3264
|
#include <common>
|
|
3265
3265
|
#include <batching_pars_vertex>
|
|
@@ -3286,7 +3286,7 @@ void main() {
|
|
|
3286
3286
|
#include <worldpos_vertex>
|
|
3287
3287
|
#include <clipping_planes_vertex>
|
|
3288
3288
|
vWorldPosition = worldPosition.xyz;
|
|
3289
|
-
}`,
|
|
3289
|
+
}`,d_=`#define DISTANCE
|
|
3290
3290
|
uniform vec3 referencePosition;
|
|
3291
3291
|
uniform float nearDistance;
|
|
3292
3292
|
uniform float farDistance;
|
|
@@ -3309,13 +3309,13 @@ void main() {
|
|
|
3309
3309
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3310
3310
|
dist = saturate( dist );
|
|
3311
3311
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3312
|
-
}`,
|
|
3312
|
+
}`,f_=`varying vec3 vWorldDirection;
|
|
3313
3313
|
#include <common>
|
|
3314
3314
|
void main() {
|
|
3315
3315
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3316
3316
|
#include <begin_vertex>
|
|
3317
3317
|
#include <project_vertex>
|
|
3318
|
-
}`,
|
|
3318
|
+
}`,p_=`uniform sampler2D tEquirect;
|
|
3319
3319
|
varying vec3 vWorldDirection;
|
|
3320
3320
|
#include <common>
|
|
3321
3321
|
void main() {
|
|
@@ -3324,7 +3324,7 @@ void main() {
|
|
|
3324
3324
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3325
3325
|
#include <tonemapping_fragment>
|
|
3326
3326
|
#include <colorspace_fragment>
|
|
3327
|
-
}`,
|
|
3327
|
+
}`,m_=`uniform float scale;
|
|
3328
3328
|
attribute float lineDistance;
|
|
3329
3329
|
varying float vLineDistance;
|
|
3330
3330
|
#include <common>
|
|
@@ -3346,7 +3346,7 @@ void main() {
|
|
|
3346
3346
|
#include <logdepthbuf_vertex>
|
|
3347
3347
|
#include <clipping_planes_vertex>
|
|
3348
3348
|
#include <fog_vertex>
|
|
3349
|
-
}`,
|
|
3349
|
+
}`,g_=`uniform vec3 diffuse;
|
|
3350
3350
|
uniform float opacity;
|
|
3351
3351
|
uniform float dashSize;
|
|
3352
3352
|
uniform float totalSize;
|
|
@@ -3374,7 +3374,7 @@ void main() {
|
|
|
3374
3374
|
#include <colorspace_fragment>
|
|
3375
3375
|
#include <fog_fragment>
|
|
3376
3376
|
#include <premultiplied_alpha_fragment>
|
|
3377
|
-
}`,
|
|
3377
|
+
}`,v_=`#include <common>
|
|
3378
3378
|
#include <batching_pars_vertex>
|
|
3379
3379
|
#include <uv_pars_vertex>
|
|
3380
3380
|
#include <envmap_pars_vertex>
|
|
@@ -3406,7 +3406,7 @@ void main() {
|
|
|
3406
3406
|
#include <worldpos_vertex>
|
|
3407
3407
|
#include <envmap_vertex>
|
|
3408
3408
|
#include <fog_vertex>
|
|
3409
|
-
}`,
|
|
3409
|
+
}`,x_=`uniform vec3 diffuse;
|
|
3410
3410
|
uniform float opacity;
|
|
3411
3411
|
#ifndef FLAT_SHADED
|
|
3412
3412
|
varying vec3 vNormal;
|
|
@@ -3454,7 +3454,7 @@ void main() {
|
|
|
3454
3454
|
#include <fog_fragment>
|
|
3455
3455
|
#include <premultiplied_alpha_fragment>
|
|
3456
3456
|
#include <dithering_fragment>
|
|
3457
|
-
}`,
|
|
3457
|
+
}`,__=`#define LAMBERT
|
|
3458
3458
|
varying vec3 vViewPosition;
|
|
3459
3459
|
#include <common>
|
|
3460
3460
|
#include <batching_pars_vertex>
|
|
@@ -3493,7 +3493,7 @@ void main() {
|
|
|
3493
3493
|
#include <envmap_vertex>
|
|
3494
3494
|
#include <shadowmap_vertex>
|
|
3495
3495
|
#include <fog_vertex>
|
|
3496
|
-
}`,
|
|
3496
|
+
}`,M_=`#define LAMBERT
|
|
3497
3497
|
uniform vec3 diffuse;
|
|
3498
3498
|
uniform vec3 emissive;
|
|
3499
3499
|
uniform float opacity;
|
|
@@ -3551,7 +3551,7 @@ void main() {
|
|
|
3551
3551
|
#include <fog_fragment>
|
|
3552
3552
|
#include <premultiplied_alpha_fragment>
|
|
3553
3553
|
#include <dithering_fragment>
|
|
3554
|
-
}`,
|
|
3554
|
+
}`,y_=`#define MATCAP
|
|
3555
3555
|
varying vec3 vViewPosition;
|
|
3556
3556
|
#include <common>
|
|
3557
3557
|
#include <batching_pars_vertex>
|
|
@@ -3585,7 +3585,7 @@ void main() {
|
|
|
3585
3585
|
#include <clipping_planes_vertex>
|
|
3586
3586
|
#include <fog_vertex>
|
|
3587
3587
|
vViewPosition = - mvPosition.xyz;
|
|
3588
|
-
}`,
|
|
3588
|
+
}`,S_=`#define MATCAP
|
|
3589
3589
|
uniform vec3 diffuse;
|
|
3590
3590
|
uniform float opacity;
|
|
3591
3591
|
uniform sampler2D matcap;
|
|
@@ -3631,7 +3631,7 @@ void main() {
|
|
|
3631
3631
|
#include <fog_fragment>
|
|
3632
3632
|
#include <premultiplied_alpha_fragment>
|
|
3633
3633
|
#include <dithering_fragment>
|
|
3634
|
-
}`,
|
|
3634
|
+
}`,b_=`#define NORMAL
|
|
3635
3635
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3636
3636
|
varying vec3 vViewPosition;
|
|
3637
3637
|
#endif
|
|
@@ -3664,7 +3664,7 @@ void main() {
|
|
|
3664
3664
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3665
3665
|
vViewPosition = - mvPosition.xyz;
|
|
3666
3666
|
#endif
|
|
3667
|
-
}`,
|
|
3667
|
+
}`,E_=`#define NORMAL
|
|
3668
3668
|
uniform float opacity;
|
|
3669
3669
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3670
3670
|
varying vec3 vViewPosition;
|
|
@@ -3685,7 +3685,7 @@ void main() {
|
|
|
3685
3685
|
#ifdef OPAQUE
|
|
3686
3686
|
gl_FragColor.a = 1.0;
|
|
3687
3687
|
#endif
|
|
3688
|
-
}`,
|
|
3688
|
+
}`,w_=`#define PHONG
|
|
3689
3689
|
varying vec3 vViewPosition;
|
|
3690
3690
|
#include <common>
|
|
3691
3691
|
#include <batching_pars_vertex>
|
|
@@ -3724,7 +3724,7 @@ void main() {
|
|
|
3724
3724
|
#include <envmap_vertex>
|
|
3725
3725
|
#include <shadowmap_vertex>
|
|
3726
3726
|
#include <fog_vertex>
|
|
3727
|
-
}`,
|
|
3727
|
+
}`,A_=`#define PHONG
|
|
3728
3728
|
uniform vec3 diffuse;
|
|
3729
3729
|
uniform vec3 emissive;
|
|
3730
3730
|
uniform vec3 specular;
|
|
@@ -3784,7 +3784,7 @@ void main() {
|
|
|
3784
3784
|
#include <fog_fragment>
|
|
3785
3785
|
#include <premultiplied_alpha_fragment>
|
|
3786
3786
|
#include <dithering_fragment>
|
|
3787
|
-
}`,
|
|
3787
|
+
}`,T_=`#define STANDARD
|
|
3788
3788
|
varying vec3 vViewPosition;
|
|
3789
3789
|
#ifdef USE_TRANSMISSION
|
|
3790
3790
|
varying vec3 vWorldPosition;
|
|
@@ -3827,7 +3827,7 @@ void main() {
|
|
|
3827
3827
|
#ifdef USE_TRANSMISSION
|
|
3828
3828
|
vWorldPosition = worldPosition.xyz;
|
|
3829
3829
|
#endif
|
|
3830
|
-
}`,
|
|
3830
|
+
}`,R_=`#define STANDARD
|
|
3831
3831
|
#ifdef PHYSICAL
|
|
3832
3832
|
#define IOR
|
|
3833
3833
|
#define USE_SPECULAR
|
|
@@ -3952,7 +3952,7 @@ void main() {
|
|
|
3952
3952
|
#include <fog_fragment>
|
|
3953
3953
|
#include <premultiplied_alpha_fragment>
|
|
3954
3954
|
#include <dithering_fragment>
|
|
3955
|
-
}`,
|
|
3955
|
+
}`,D_=`#define TOON
|
|
3956
3956
|
varying vec3 vViewPosition;
|
|
3957
3957
|
#include <common>
|
|
3958
3958
|
#include <batching_pars_vertex>
|
|
@@ -3989,7 +3989,7 @@ void main() {
|
|
|
3989
3989
|
#include <worldpos_vertex>
|
|
3990
3990
|
#include <shadowmap_vertex>
|
|
3991
3991
|
#include <fog_vertex>
|
|
3992
|
-
}`,
|
|
3992
|
+
}`,C_=`#define TOON
|
|
3993
3993
|
uniform vec3 diffuse;
|
|
3994
3994
|
uniform vec3 emissive;
|
|
3995
3995
|
uniform float opacity;
|
|
@@ -4041,7 +4041,7 @@ void main() {
|
|
|
4041
4041
|
#include <fog_fragment>
|
|
4042
4042
|
#include <premultiplied_alpha_fragment>
|
|
4043
4043
|
#include <dithering_fragment>
|
|
4044
|
-
}`,
|
|
4044
|
+
}`,P_=`uniform float size;
|
|
4045
4045
|
uniform float scale;
|
|
4046
4046
|
#include <common>
|
|
4047
4047
|
#include <color_pars_vertex>
|
|
@@ -4072,7 +4072,7 @@ void main() {
|
|
|
4072
4072
|
#include <clipping_planes_vertex>
|
|
4073
4073
|
#include <worldpos_vertex>
|
|
4074
4074
|
#include <fog_vertex>
|
|
4075
|
-
}`,
|
|
4075
|
+
}`,I_=`uniform vec3 diffuse;
|
|
4076
4076
|
uniform float opacity;
|
|
4077
4077
|
#include <common>
|
|
4078
4078
|
#include <color_pars_fragment>
|
|
@@ -4097,7 +4097,7 @@ void main() {
|
|
|
4097
4097
|
#include <colorspace_fragment>
|
|
4098
4098
|
#include <fog_fragment>
|
|
4099
4099
|
#include <premultiplied_alpha_fragment>
|
|
4100
|
-
}`,
|
|
4100
|
+
}`,L_=`#include <common>
|
|
4101
4101
|
#include <batching_pars_vertex>
|
|
4102
4102
|
#include <fog_pars_vertex>
|
|
4103
4103
|
#include <morphtarget_pars_vertex>
|
|
@@ -4120,7 +4120,7 @@ void main() {
|
|
|
4120
4120
|
#include <worldpos_vertex>
|
|
4121
4121
|
#include <shadowmap_vertex>
|
|
4122
4122
|
#include <fog_vertex>
|
|
4123
|
-
}`,
|
|
4123
|
+
}`,N_=`uniform vec3 color;
|
|
4124
4124
|
uniform float opacity;
|
|
4125
4125
|
#include <common>
|
|
4126
4126
|
#include <fog_pars_fragment>
|
|
@@ -4136,7 +4136,7 @@ void main() {
|
|
|
4136
4136
|
#include <colorspace_fragment>
|
|
4137
4137
|
#include <fog_fragment>
|
|
4138
4138
|
#include <premultiplied_alpha_fragment>
|
|
4139
|
-
}`,
|
|
4139
|
+
}`,O_=`uniform float rotation;
|
|
4140
4140
|
uniform vec2 center;
|
|
4141
4141
|
#include <common>
|
|
4142
4142
|
#include <uv_pars_vertex>
|
|
@@ -4160,7 +4160,7 @@ void main() {
|
|
|
4160
4160
|
#include <logdepthbuf_vertex>
|
|
4161
4161
|
#include <clipping_planes_vertex>
|
|
4162
4162
|
#include <fog_vertex>
|
|
4163
|
-
}`,
|
|
4163
|
+
}`,U_=`uniform vec3 diffuse;
|
|
4164
4164
|
uniform float opacity;
|
|
4165
4165
|
#include <common>
|
|
4166
4166
|
#include <uv_pars_fragment>
|
|
@@ -4185,7 +4185,7 @@ void main() {
|
|
|
4185
4185
|
#include <tonemapping_fragment>
|
|
4186
4186
|
#include <colorspace_fragment>
|
|
4187
4187
|
#include <fog_fragment>
|
|
4188
|
-
}`,Wt={alphahash_fragment:ev,alphahash_pars_fragment:nv,alphamap_fragment:iv,alphamap_pars_fragment:sv,alphatest_fragment:rv,alphatest_pars_fragment:av,aomap_fragment:ov,aomap_pars_fragment:cv,batching_pars_vertex:lv,batching_vertex:hv,begin_vertex:uv,beginnormal_vertex:dv,bsdfs:fv,iridescence_fragment:pv,bumpmap_pars_fragment:mv,clipping_planes_fragment:gv,clipping_planes_pars_fragment:vv,clipping_planes_pars_vertex:xv,clipping_planes_vertex:_v,color_fragment:Mv,color_pars_fragment:yv,color_pars_vertex:Sv,color_vertex:bv,common:Ev,cube_uv_reflection_fragment:wv,defaultnormal_vertex:Av,displacementmap_pars_vertex:Tv,displacementmap_vertex:Rv,emissivemap_fragment:Dv,emissivemap_pars_fragment:Cv,colorspace_fragment:Pv,colorspace_pars_fragment:Iv,envmap_fragment:Lv,envmap_common_pars_fragment:Nv,envmap_pars_fragment:Ov,envmap_pars_vertex:Uv,envmap_physical_pars_fragment:Yv,envmap_vertex:Fv,fog_vertex:zv,fog_pars_vertex:Bv,fog_fragment:kv,fog_pars_fragment:Hv,gradientmap_pars_fragment:Gv,lightmap_pars_fragment:Vv,lights_lambert_fragment:Wv,lights_lambert_pars_fragment:Xv,lights_pars_begin:qv,lights_toon_fragment:Kv,lights_toon_pars_fragment:$v,lights_phong_fragment:Zv,lights_phong_pars_fragment:Jv,lights_physical_fragment:Qv,lights_physical_pars_fragment:jv,lights_fragment_begin:tx,lights_fragment_maps:ex,lights_fragment_end:nx,lightprobes_pars_fragment:ix,logdepthbuf_fragment:sx,logdepthbuf_pars_fragment:rx,logdepthbuf_pars_vertex:ax,logdepthbuf_vertex:ox,map_fragment:cx,map_pars_fragment:lx,map_particle_fragment:hx,map_particle_pars_fragment:ux,metalnessmap_fragment:dx,metalnessmap_pars_fragment:fx,morphinstance_vertex:px,morphcolor_vertex:mx,morphnormal_vertex:gx,morphtarget_pars_vertex:vx,morphtarget_vertex:xx,normal_fragment_begin:_x,normal_fragment_maps:Mx,normal_pars_fragment:yx,normal_pars_vertex:Sx,normal_vertex:bx,normalmap_pars_fragment:Ex,clearcoat_normal_fragment_begin:wx,clearcoat_normal_fragment_maps:Ax,clearcoat_pars_fragment:Tx,iridescence_pars_fragment:Rx,opaque_fragment:Dx,packing:Cx,premultiplied_alpha_fragment:Px,project_vertex:Ix,dithering_fragment:Lx,dithering_pars_fragment:Nx,roughnessmap_fragment:Ox,roughnessmap_pars_fragment:Ux,shadowmap_pars_fragment:Fx,shadowmap_pars_vertex:zx,shadowmap_vertex:Bx,shadowmask_pars_fragment:kx,skinbase_vertex:Hx,skinning_pars_vertex:Gx,skinning_vertex:Vx,skinnormal_vertex:Wx,specularmap_fragment:Xx,specularmap_pars_fragment:qx,tonemapping_fragment:Yx,tonemapping_pars_fragment:Kx,transmission_fragment:$x,transmission_pars_fragment:Zx,uv_pars_fragment:Jx,uv_pars_vertex:Qx,uv_vertex:jx,worldpos_vertex:t_,background_vert:e_,background_frag:n_,backgroundCube_vert:i_,backgroundCube_frag:s_,cube_vert:r_,cube_frag:a_,depth_vert:o_,depth_frag:c_,distance_vert:l_,distance_frag:h_,equirect_vert:u_,equirect_frag:d_,linedashed_vert:f_,linedashed_frag:p_,meshbasic_vert:m_,meshbasic_frag:g_,meshlambert_vert:v_,meshlambert_frag:x_,meshmatcap_vert:__,meshmatcap_frag:M_,meshnormal_vert:y_,meshnormal_frag:S_,meshphong_vert:b_,meshphong_frag:E_,meshphysical_vert:w_,meshphysical_frag:A_,meshtoon_vert:T_,meshtoon_frag:R_,points_vert:D_,points_frag:C_,shadow_vert:P_,shadow_frag:I_,sprite_vert:L_,sprite_frag:N_},ft={common:{diffuse:{value:new vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new Pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vt(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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new vt(16777215)},opacity:{value:1},center:{value:new Pt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},ci={basic:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},envMapIntensity:{value:1}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},specular:{value:new vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:rn([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:rn([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new vt(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:rn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:rn([ft.points,ft.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:rn([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:rn([ft.common,ft.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:rn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:rn([ft.sprite,ft.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},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 Bt}},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:rn([ft.common,ft.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distance_vert,fragmentShader:Wt.distance_frag},shadow:{uniforms:rn([ft.lights,ft.fog,{color:{value:new vt(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};ci.physical={uniforms:rn([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new Pt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new Pt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new vt(0)},specularColor:{value:new vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new Pt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const po={r:0,b:0,g:0},O_=new Xt,Fp=new Bt;Fp.set(-1,0,0,0,1,0,0,0,1);function U_(s,t,e,n,i,r){const a=new vt(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const M=b.backgroundBlurriness>0;E=t.get(E,M)}return E}function g(b){let E=!1;const M=f(b);M===null?p(a,o):M&&M.isColor&&(p(M,1),E=!0);const S=s.xr.getEnvironmentBlendMode();S==="additive"?e.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(s.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,E){const M=f(E);M&&(M.isCubeTexture||M.mapping===hc)?(l===void 0&&(l=new $t(new Bn(1,1,1),new De({name:"BackgroundCubeMaterial",uniforms:Ar(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:Be,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(O_.makeRotationFromEuler(E.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Fp),l.material.toneMapped=Qt.getTransfer(M.colorSpace)!==se,(h!==M||u!==M.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new $t(new Hi(2,2),new De({name:"BackgroundMaterial",uniforms:Ar(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=Qt.getTransfer(M.colorSpace)!==se,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function p(b,E){b.getRGB(po,Pp(s)),e.buffers.color.setClear(po.r,po.g,po.b,E,r)}function m(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,E=1){a.set(b),o=E,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,p(a,o)},render:g,addToRenderList:v,dispose:m}}function F_(s,t){const e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,I,V,q,O){let W=!1;const G=u(D,q,V,I);r!==G&&(r=G,l(r.object)),W=f(D,q,V,O),W&&g(D,q,V,O),O!==null&&t.update(O,s.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(D,I,V,q),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,I,V,q){const O=q.wireframe===!0;let W=n[I.id];W===void 0&&(W={},n[I.id]=W);const G=D.isInstancedMesh===!0?D.id:0;let Z=W[G];Z===void 0&&(Z={},W[G]=Z);let et=Z[V.id];et===void 0&&(et={},Z[V.id]=et);let j=et[O];return j===void 0&&(j=d(c()),et[O]=j),j}function d(D){const I=[],V=[],q=[];for(let O=0;O<e;O++)I[O]=0,V[O]=0,q[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:V,attributeDivisors:q,object:D,attributes:{},index:null}}function f(D,I,V,q){const O=r.attributes,W=I.attributes;let G=0;const Z=V.getAttributes();for(const et in Z)if(Z[et].location>=0){const it=O[et];let ut=W[et];if(ut===void 0&&(et==="instanceMatrix"&&D.instanceMatrix&&(ut=D.instanceMatrix),et==="instanceColor"&&D.instanceColor&&(ut=D.instanceColor)),it===void 0||it.attribute!==ut||ut&&it.data!==ut.data)return!0;G++}return r.attributesNum!==G||r.index!==q}function g(D,I,V,q){const O={},W=I.attributes;let G=0;const Z=V.getAttributes();for(const et in Z)if(Z[et].location>=0){let it=W[et];it===void 0&&(et==="instanceMatrix"&&D.instanceMatrix&&(it=D.instanceMatrix),et==="instanceColor"&&D.instanceColor&&(it=D.instanceColor));const ut={};ut.attribute=it,it&&it.data&&(ut.data=it.data),O[et]=ut,G++}r.attributes=O,r.attributesNum=G,r.index=q}function v(){const D=r.newAttributes;for(let I=0,V=D.length;I<V;I++)D[I]=0}function p(D){m(D,0)}function m(D,I){const V=r.newAttributes,q=r.enabledAttributes,O=r.attributeDivisors;V[D]=1,q[D]===0&&(s.enableVertexAttribArray(D),q[D]=1),O[D]!==I&&(s.vertexAttribDivisor(D,I),O[D]=I)}function b(){const D=r.newAttributes,I=r.enabledAttributes;for(let V=0,q=I.length;V<q;V++)I[V]!==D[V]&&(s.disableVertexAttribArray(V),I[V]=0)}function E(D,I,V,q,O,W,G){G===!0?s.vertexAttribIPointer(D,I,V,O,W):s.vertexAttribPointer(D,I,V,q,O,W)}function M(D,I,V,q){v();const O=q.attributes,W=V.getAttributes(),G=I.defaultAttributeValues;for(const Z in W){const et=W[Z];if(et.location>=0){let j=O[Z];if(j===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(j=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(j=D.instanceColor)),j!==void 0){const it=j.normalized,ut=j.itemSize,Ht=t.get(j);if(Ht===void 0)continue;const Jt=Ht.buffer,kt=Ht.type,Y=Ht.bytesPerElement,rt=kt===s.INT||kt===s.UNSIGNED_INT||j.gpuType===ru;if(j.isInterleavedBufferAttribute){const nt=j.data,z=nt.stride,Et=j.offset;if(nt.isInstancedInterleavedBuffer){for(let It=0;It<et.locationSize;It++)m(et.location+It,nt.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let It=0;It<et.locationSize;It++)p(et.location+It);s.bindBuffer(s.ARRAY_BUFFER,Jt);for(let It=0;It<et.locationSize;It++)E(et.location+It,ut/et.locationSize,kt,it,z*Y,(Et+ut/et.locationSize*It)*Y,rt)}else{if(j.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt,j.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let nt=0;nt<et.locationSize;nt++)p(et.location+nt);s.bindBuffer(s.ARRAY_BUFFER,Jt);for(let nt=0;nt<et.locationSize;nt++)E(et.location+nt,ut/et.locationSize,kt,it,ut*Y,ut/et.locationSize*nt*Y,rt)}}else if(G!==void 0){const it=G[Z];if(it!==void 0)switch(it.length){case 2:s.vertexAttrib2fv(et.location,it);break;case 3:s.vertexAttrib3fv(et.location,it);break;case 4:s.vertexAttrib4fv(et.location,it);break;default:s.vertexAttrib1fv(et.location,it)}}}}b()}function S(){A();for(const D in n){const I=n[D];for(const V in I){const q=I[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const V in I){const q=I[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D.id]}function R(D){for(const I in n){const V=n[I];for(const q in V){const O=V[q];if(O[D.id]===void 0)continue;const W=O[D.id];for(const G in W)h(W[G].object),delete W[G];delete O[D.id]}}}function _(D){for(const I in n){const V=n[I],q=D.isInstancedMesh===!0?D.id:0,O=V[q];if(O!==void 0){for(const W in O){const G=O[W];for(const Z in G)h(G[Z].object),delete G[Z];delete O[W]}delete V[q],Object.keys(V).length===0&&delete n[I]}}}function A(){C(),a=!0,r!==i&&(r=i,l(r.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:C,dispose:S,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:p,disableUnusedAttributes:b}}function z_(s,t,e){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function B_(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==fn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===nn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==Dn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==zn&&!_)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(wt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&wt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),E=s.getParameter(s.MAX_VARYING_VECTORS),M=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),S=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:M,maxSamples:S,samples:w}}function k_(s){const t=this;let e=null,n=0,i=!1,r=!1;const a=new _s,o=new Bt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,v=u.clipIntersection,p=u.clipShadows,m=s.get(u);if(!i||g===null||g.length===0||r&&!p)r?h(null):l();else{const b=r?0:n,E=b*4;let M=m.clippingState||null;c.value=M,M=h(g,d,E,f);for(let S=0;S!==E;++S)M[S]=e[S];m.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const v=u!==null?u.length:0;let p=null;if(v!==0){if(p=c.value,g!==!0||p===null){const m=f+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(p===null||p.length<m)&&(p=new Float32Array(m));for(let E=0,M=f;E!==v;++E,M+=4)a.copy(u[E]).applyMatrix4(b,o),a.normal.toArray(p,M),p[M+3]=a.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,p}}const ss=4,u0=[.125,.215,.35,.446,.526,.582],Ss=20,H_=256,qr=new Ir,d0=new vt;let el=null,nl=0,il=0,sl=!1;const G_=new P;class f0{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:o=G_}=r;el=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),il=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=m0(),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(el,nl,il),this._renderer.xr.enabled=sl,t.scissorTest=!1,sr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ds||t.mapping===Er?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),el=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),il=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:ye,minFilter:ye,generateMipmaps:!1,type:nn,format:fn,colorSpace:$o,depthBuffer:!1},i=p0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=p0(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=V_(r)),this._blurMaterial=X_(r,t,e),this._ggxMaterial=W_(r,t,e)}return i}_compileMaterial(t){const e=new $t(new be,t);this._renderer.compile(e,qr)}_sceneToCubeUV(t,e,n,i,r){const c=new yn(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(d0),u.toneMapping=gi,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new $t(new Bn,new Oi({name:"PMREM.Background",side:Be,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,p=v.material;let m=!1;const b=t.background;b?b.isColor&&(p.color.copy(b),t.background=null,m=!0):(p.color.copy(d0),m=!0);for(let E=0;E<6;E++){const M=E%3;M===0?(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[E],r.y,r.z)):M===1?(c.up.set(0,0,l[E]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[E],r.z)):(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[E]));const S=this._cubeSize;sr(i,M*S,E>2?S:0,S,S),u.setRenderTarget(i),m&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=b}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Ds||t.mapping===Er;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=g0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=m0());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;sr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,qr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:g}=this,v=this._sizeLods[n],p=3*v*(n>g-ss?n-g+ss:0),m=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=g-e,sr(r,p,m,3*v,2*v),i.setRenderTarget(r),i.render(o,qr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,sr(t,p,m,3*v,2*v),i.setRenderTarget(t),i.render(o,qr)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&zt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ss-1),v=r/g,p=isFinite(r)?1+Math.floor(h*v):Ss;p>Ss&&wt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Ss}`);const m=[];let b=0;for(let R=0;R<Ss;++R){const _=R/v,A=Math.exp(-_*_/2);m.push(A),R===0?b+=A:R<p&&(b+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/b;d.envMap.value=t.texture,d.samples.value=p,d.weights.value=m,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=g,d.mipInt.value=E-n;const M=this._sizeLods[i],S=3*M*(i>E-ss?i-E+ss:0),w=4*(this._cubeSize-M);sr(e,S,w,3*M,2*M),c.setRenderTarget(e),c.render(u,qr)}}function V_(s){const t=[],e=[],n=[];let i=s;const r=s-ss+1+u0.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>s-ss?c=u0[a-s+ss-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,v=3,p=2,m=1,b=new Float32Array(v*g*f),E=new Float32Array(p*g*f),M=new Float32Array(m*g*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,_=w>2?0:-1,A=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];b.set(A,v*g*w),E.set(d,p*g*w);const C=[w,w,w,w,w,w];M.set(C,m*g*w)}const S=new be;S.setAttribute("position",new de(b,v)),S.setAttribute("uv",new de(E,p)),S.setAttribute("faceIndex",new de(M,m)),n.push(new $t(S,null)),i>ss&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function p0(s,t,e){const n=new Sn(s,t,e);return n.texture.mapping=hc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function sr(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function W_(s,t,e){return new De({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:H_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:fc(),fragmentShader:`
|
|
4188
|
+
}`,Wt={alphahash_fragment:iv,alphahash_pars_fragment:sv,alphamap_fragment:rv,alphamap_pars_fragment:av,alphatest_fragment:ov,alphatest_pars_fragment:cv,aomap_fragment:lv,aomap_pars_fragment:hv,batching_pars_vertex:uv,batching_vertex:dv,begin_vertex:fv,beginnormal_vertex:pv,bsdfs:mv,iridescence_fragment:gv,bumpmap_pars_fragment:vv,clipping_planes_fragment:xv,clipping_planes_pars_fragment:_v,clipping_planes_pars_vertex:Mv,clipping_planes_vertex:yv,color_fragment:Sv,color_pars_fragment:bv,color_pars_vertex:Ev,color_vertex:wv,common:Av,cube_uv_reflection_fragment:Tv,defaultnormal_vertex:Rv,displacementmap_pars_vertex:Dv,displacementmap_vertex:Cv,emissivemap_fragment:Pv,emissivemap_pars_fragment:Iv,colorspace_fragment:Lv,colorspace_pars_fragment:Nv,envmap_fragment:Ov,envmap_common_pars_fragment:Uv,envmap_pars_fragment:Fv,envmap_pars_vertex:zv,envmap_physical_pars_fragment:$v,envmap_vertex:Bv,fog_vertex:kv,fog_pars_vertex:Hv,fog_fragment:Gv,fog_pars_fragment:Vv,gradientmap_pars_fragment:Wv,lightmap_pars_fragment:Xv,lights_lambert_fragment:qv,lights_lambert_pars_fragment:Yv,lights_pars_begin:Kv,lights_toon_fragment:Zv,lights_toon_pars_fragment:Jv,lights_phong_fragment:Qv,lights_phong_pars_fragment:jv,lights_physical_fragment:tx,lights_physical_pars_fragment:ex,lights_fragment_begin:nx,lights_fragment_maps:ix,lights_fragment_end:sx,lightprobes_pars_fragment:rx,logdepthbuf_fragment:ax,logdepthbuf_pars_fragment:ox,logdepthbuf_pars_vertex:cx,logdepthbuf_vertex:lx,map_fragment:hx,map_pars_fragment:ux,map_particle_fragment:dx,map_particle_pars_fragment:fx,metalnessmap_fragment:px,metalnessmap_pars_fragment:mx,morphinstance_vertex:gx,morphcolor_vertex:vx,morphnormal_vertex:xx,morphtarget_pars_vertex:_x,morphtarget_vertex:Mx,normal_fragment_begin:yx,normal_fragment_maps:Sx,normal_pars_fragment:bx,normal_pars_vertex:Ex,normal_vertex:wx,normalmap_pars_fragment:Ax,clearcoat_normal_fragment_begin:Tx,clearcoat_normal_fragment_maps:Rx,clearcoat_pars_fragment:Dx,iridescence_pars_fragment:Cx,opaque_fragment:Px,packing:Ix,premultiplied_alpha_fragment:Lx,project_vertex:Nx,dithering_fragment:Ox,dithering_pars_fragment:Ux,roughnessmap_fragment:Fx,roughnessmap_pars_fragment:zx,shadowmap_pars_fragment:Bx,shadowmap_pars_vertex:kx,shadowmap_vertex:Hx,shadowmask_pars_fragment:Gx,skinbase_vertex:Vx,skinning_pars_vertex:Wx,skinning_vertex:Xx,skinnormal_vertex:qx,specularmap_fragment:Yx,specularmap_pars_fragment:Kx,tonemapping_fragment:$x,tonemapping_pars_fragment:Zx,transmission_fragment:Jx,transmission_pars_fragment:Qx,uv_pars_fragment:jx,uv_pars_vertex:t_,uv_vertex:e_,worldpos_vertex:n_,background_vert:i_,background_frag:s_,backgroundCube_vert:r_,backgroundCube_frag:a_,cube_vert:o_,cube_frag:c_,depth_vert:l_,depth_frag:h_,distance_vert:u_,distance_frag:d_,equirect_vert:f_,equirect_frag:p_,linedashed_vert:m_,linedashed_frag:g_,meshbasic_vert:v_,meshbasic_frag:x_,meshlambert_vert:__,meshlambert_frag:M_,meshmatcap_vert:y_,meshmatcap_frag:S_,meshnormal_vert:b_,meshnormal_frag:E_,meshphong_vert:w_,meshphong_frag:A_,meshphysical_vert:T_,meshphysical_frag:R_,meshtoon_vert:D_,meshtoon_frag:C_,points_vert:P_,points_frag:I_,shadow_vert:L_,shadow_frag:N_,sprite_vert:O_,sprite_frag:U_},ft={common:{diffuse:{value:new vt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Bt}},envmap:{envMap:{value:null},envMapRotation:{value:new Bt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Bt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Bt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Bt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Bt},normalScale:{value:new Pt(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Bt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Bt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Bt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Bt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new vt(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 P},probesMax:{value:new P},probesResolution:{value:new P}},points:{diffuse:{value:new vt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0},uvTransform:{value:new Bt}},sprite:{diffuse:{value:new vt(16777215)},opacity:{value:1},center:{value:new Pt(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Bt},alphaMap:{value:null},alphaMapTransform:{value:new Bt},alphaTest:{value:0}}},ci={basic:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Wt.meshbasic_vert,fragmentShader:Wt.meshbasic_frag},lambert:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},envMapIntensity:{value:1}}]),vertexShader:Wt.meshlambert_vert,fragmentShader:Wt.meshlambert_frag},phong:{uniforms:rn([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},specular:{value:new vt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphong_vert,fragmentShader:Wt.meshphong_frag},standard:{uniforms:rn([ft.common,ft.envmap,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.roughnessmap,ft.metalnessmap,ft.fog,ft.lights,{emissive:{value:new vt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag},toon:{uniforms:rn([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new vt(0)}}]),vertexShader:Wt.meshtoon_vert,fragmentShader:Wt.meshtoon_frag},matcap:{uniforms:rn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Wt.meshmatcap_vert,fragmentShader:Wt.meshmatcap_frag},points:{uniforms:rn([ft.points,ft.fog]),vertexShader:Wt.points_vert,fragmentShader:Wt.points_frag},dashed:{uniforms:rn([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Wt.linedashed_vert,fragmentShader:Wt.linedashed_frag},depth:{uniforms:rn([ft.common,ft.displacementmap]),vertexShader:Wt.depth_vert,fragmentShader:Wt.depth_frag},normal:{uniforms:rn([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Wt.meshnormal_vert,fragmentShader:Wt.meshnormal_frag},sprite:{uniforms:rn([ft.sprite,ft.fog]),vertexShader:Wt.sprite_vert,fragmentShader:Wt.sprite_frag},background:{uniforms:{uvTransform:{value:new Bt},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 Bt}},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:rn([ft.common,ft.displacementmap,{referencePosition:{value:new P},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Wt.distance_vert,fragmentShader:Wt.distance_frag},shadow:{uniforms:rn([ft.lights,ft.fog,{color:{value:new vt(0)},opacity:{value:1}}]),vertexShader:Wt.shadow_vert,fragmentShader:Wt.shadow_frag}};ci.physical={uniforms:rn([ci.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Bt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Bt},clearcoatNormalScale:{value:new Pt(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Bt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Bt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Bt},sheen:{value:0},sheenColor:{value:new vt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Bt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Bt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Bt},transmissionSamplerSize:{value:new Pt},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Bt},attenuationDistance:{value:0},attenuationColor:{value:new vt(0)},specularColor:{value:new vt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Bt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Bt},anisotropyVector:{value:new Pt},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Bt}}]),vertexShader:Wt.meshphysical_vert,fragmentShader:Wt.meshphysical_frag};const po={r:0,b:0,g:0},F_=new Xt,Fp=new Bt;Fp.set(-1,0,0,0,1,0,0,0,1);function z_(s,t,e,n,i,r){const a=new vt(0);let o=i===!0?0:1,c,l,h=null,u=0,d=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const M=b.backgroundBlurriness>0;E=t.get(E,M)}return E}function g(b){let E=!1;const M=f(b);M===null?p(a,o):M&&M.isColor&&(p(M,1),E=!0);const S=s.xr.getEnvironmentBlendMode();S==="additive"?e.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&e.buffers.color.setClear(0,0,0,0,r),(s.autoClear||E)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),s.clear(s.autoClearColor,s.autoClearDepth,s.autoClearStencil))}function v(b,E){const M=f(E);M&&(M.isCubeTexture||M.mapping===hc)?(l===void 0&&(l=new $t(new Bn(1,1,1),new De({name:"BackgroundCubeMaterial",uniforms:Ar(ci.backgroundCube.uniforms),vertexShader:ci.backgroundCube.vertexShader,fragmentShader:ci.backgroundCube.fragmentShader,side:Be,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,w,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(l.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(l)),l.material.uniforms.envMap.value=M,l.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(F_.makeRotationFromEuler(E.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(Fp),l.material.toneMapped=Qt.getTransfer(M.colorSpace)!==se,(h!==M||u!==M.version||d!==s.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=s.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new $t(new Hi(2,2),new De({name:"BackgroundMaterial",uniforms:Ar(ci.background.uniforms),vertexShader:ci.background.vertexShader,fragmentShader:ci.background.fragmentShader,side:cs,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),Object.defineProperty(c.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(c)),c.material.uniforms.t2D.value=M,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.toneMapped=Qt.getTransfer(M.colorSpace)!==se,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==s.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=s.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null))}function p(b,E){b.getRGB(po,Pp(s)),e.buffers.color.setClear(po.r,po.g,po.b,E,r)}function m(){l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0),c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0)}return{getClearColor:function(){return a},setClearColor:function(b,E=1){a.set(b),o=E,p(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,p(a,o)},render:g,addToRenderList:v,dispose:m}}function B_(s,t){const e=s.getParameter(s.MAX_VERTEX_ATTRIBS),n={},i=d(null);let r=i,a=!1;function o(D,I,V,q,O){let W=!1;const G=u(D,q,V,I);r!==G&&(r=G,l(r.object)),W=f(D,q,V,O),W&&g(D,q,V,O),O!==null&&t.update(O,s.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(D,I,V,q),O!==null&&s.bindBuffer(s.ELEMENT_ARRAY_BUFFER,t.get(O).buffer))}function c(){return s.createVertexArray()}function l(D){return s.bindVertexArray(D)}function h(D){return s.deleteVertexArray(D)}function u(D,I,V,q){const O=q.wireframe===!0;let W=n[I.id];W===void 0&&(W={},n[I.id]=W);const G=D.isInstancedMesh===!0?D.id:0;let Z=W[G];Z===void 0&&(Z={},W[G]=Z);let et=Z[V.id];et===void 0&&(et={},Z[V.id]=et);let j=et[O];return j===void 0&&(j=d(c()),et[O]=j),j}function d(D){const I=[],V=[],q=[];for(let O=0;O<e;O++)I[O]=0,V[O]=0,q[O]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:V,attributeDivisors:q,object:D,attributes:{},index:null}}function f(D,I,V,q){const O=r.attributes,W=I.attributes;let G=0;const Z=V.getAttributes();for(const et in Z)if(Z[et].location>=0){const it=O[et];let ut=W[et];if(ut===void 0&&(et==="instanceMatrix"&&D.instanceMatrix&&(ut=D.instanceMatrix),et==="instanceColor"&&D.instanceColor&&(ut=D.instanceColor)),it===void 0||it.attribute!==ut||ut&&it.data!==ut.data)return!0;G++}return r.attributesNum!==G||r.index!==q}function g(D,I,V,q){const O={},W=I.attributes;let G=0;const Z=V.getAttributes();for(const et in Z)if(Z[et].location>=0){let it=W[et];it===void 0&&(et==="instanceMatrix"&&D.instanceMatrix&&(it=D.instanceMatrix),et==="instanceColor"&&D.instanceColor&&(it=D.instanceColor));const ut={};ut.attribute=it,it&&it.data&&(ut.data=it.data),O[et]=ut,G++}r.attributes=O,r.attributesNum=G,r.index=q}function v(){const D=r.newAttributes;for(let I=0,V=D.length;I<V;I++)D[I]=0}function p(D){m(D,0)}function m(D,I){const V=r.newAttributes,q=r.enabledAttributes,O=r.attributeDivisors;V[D]=1,q[D]===0&&(s.enableVertexAttribArray(D),q[D]=1),O[D]!==I&&(s.vertexAttribDivisor(D,I),O[D]=I)}function b(){const D=r.newAttributes,I=r.enabledAttributes;for(let V=0,q=I.length;V<q;V++)I[V]!==D[V]&&(s.disableVertexAttribArray(V),I[V]=0)}function E(D,I,V,q,O,W,G){G===!0?s.vertexAttribIPointer(D,I,V,O,W):s.vertexAttribPointer(D,I,V,q,O,W)}function M(D,I,V,q){v();const O=q.attributes,W=V.getAttributes(),G=I.defaultAttributeValues;for(const Z in W){const et=W[Z];if(et.location>=0){let j=O[Z];if(j===void 0&&(Z==="instanceMatrix"&&D.instanceMatrix&&(j=D.instanceMatrix),Z==="instanceColor"&&D.instanceColor&&(j=D.instanceColor)),j!==void 0){const it=j.normalized,ut=j.itemSize,Ht=t.get(j);if(Ht===void 0)continue;const Jt=Ht.buffer,kt=Ht.type,Y=Ht.bytesPerElement,rt=kt===s.INT||kt===s.UNSIGNED_INT||j.gpuType===ru;if(j.isInterleavedBufferAttribute){const nt=j.data,z=nt.stride,Et=j.offset;if(nt.isInstancedInterleavedBuffer){for(let It=0;It<et.locationSize;It++)m(et.location+It,nt.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let It=0;It<et.locationSize;It++)p(et.location+It);s.bindBuffer(s.ARRAY_BUFFER,Jt);for(let It=0;It<et.locationSize;It++)E(et.location+It,ut/et.locationSize,kt,it,z*Y,(Et+ut/et.locationSize*It)*Y,rt)}else{if(j.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt,j.meshPerAttribute);D.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let nt=0;nt<et.locationSize;nt++)p(et.location+nt);s.bindBuffer(s.ARRAY_BUFFER,Jt);for(let nt=0;nt<et.locationSize;nt++)E(et.location+nt,ut/et.locationSize,kt,it,ut*Y,ut/et.locationSize*nt*Y,rt)}}else if(G!==void 0){const it=G[Z];if(it!==void 0)switch(it.length){case 2:s.vertexAttrib2fv(et.location,it);break;case 3:s.vertexAttrib3fv(et.location,it);break;case 4:s.vertexAttrib4fv(et.location,it);break;default:s.vertexAttrib1fv(et.location,it)}}}}b()}function S(){A();for(const D in n){const I=n[D];for(const V in I){const q=I[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D]}}function w(D){if(n[D.id]===void 0)return;const I=n[D.id];for(const V in I){const q=I[V];for(const O in q){const W=q[O];for(const G in W)h(W[G].object),delete W[G];delete q[O]}}delete n[D.id]}function R(D){for(const I in n){const V=n[I];for(const q in V){const O=V[q];if(O[D.id]===void 0)continue;const W=O[D.id];for(const G in W)h(W[G].object),delete W[G];delete O[D.id]}}}function _(D){for(const I in n){const V=n[I],q=D.isInstancedMesh===!0?D.id:0,O=V[q];if(O!==void 0){for(const W in O){const G=O[W];for(const Z in G)h(G[Z].object),delete G[Z];delete O[W]}delete V[q],Object.keys(V).length===0&&delete n[I]}}}function A(){C(),a=!0,r!==i&&(r=i,l(r.object))}function C(){i.geometry=null,i.program=null,i.wireframe=!1}return{setup:o,reset:A,resetDefaultState:C,dispose:S,releaseStatesOfGeometry:w,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:v,enableAttribute:p,disableUnusedAttributes:b}}function k_(s,t,e){let n;function i(c){n=c}function r(c,l){s.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(s.drawArraysInstanced(n,c,l,h),e.update(l,n,h))}function o(c,l,h){if(h===0)return;t.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,c,0,l,0,h);let d=0;for(let f=0;f<h;f++)d+=l[f];e.update(d,n,1)}this.setMode=i,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function H_(s,t,e,n){let i;function r(){if(i!==void 0)return i;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");i=s.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else i=0;return i}function a(R){return!(R!==fn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===nn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==Dn&&n.convert(R)!==s.getParameter(s.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==zn&&!_)}function c(R){if(R==="highp"){if(s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.HIGH_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&s.getShaderPrecisionFormat(s.VERTEX_SHADER,s.MEDIUM_FLOAT).precision>0&&s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(wt("WebGLRenderer:",l,"not supported, using",h,"instead."),l=h);const u=e.logarithmicDepthBuffer===!0,d=e.reversedDepthBuffer===!0&&t.has("EXT_clip_control");e.reversedDepthBuffer===!0&&d===!1&&wt("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),g=s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),v=s.getParameter(s.MAX_TEXTURE_SIZE),p=s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),m=s.getParameter(s.MAX_VERTEX_ATTRIBS),b=s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),E=s.getParameter(s.MAX_VARYING_VECTORS),M=s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),S=s.getParameter(s.MAX_SAMPLES),w=s.getParameter(s.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:v,maxCubemapSize:p,maxAttributes:m,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:M,maxSamples:S,samples:w}}function G_(s){const t=this;let e=null,n=0,i=!1,r=!1;const a=new _s,o=new Bt,c={value:null,needsUpdate:!1};this.uniform=c,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const f=u.length!==0||d||n!==0||i;return i=d,n=u.length,f},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){e=h(u,d,0)},this.setState=function(u,d,f){const g=u.clippingPlanes,v=u.clipIntersection,p=u.clipShadows,m=s.get(u);if(!i||g===null||g.length===0||r&&!p)r?h(null):l();else{const b=r?0:n,E=b*4;let M=m.clippingState||null;c.value=M,M=h(g,d,E,f);for(let S=0;S!==E;++S)M[S]=e[S];m.clippingState=M,this.numIntersection=v?this.numPlanes:0,this.numPlanes+=b}};function l(){c.value!==e&&(c.value=e,c.needsUpdate=n>0),t.numPlanes=n,t.numIntersection=0}function h(u,d,f,g){const v=u!==null?u.length:0;let p=null;if(v!==0){if(p=c.value,g!==!0||p===null){const m=f+v*4,b=d.matrixWorldInverse;o.getNormalMatrix(b),(p===null||p.length<m)&&(p=new Float32Array(m));for(let E=0,M=f;E!==v;++E,M+=4)a.copy(u[E]).applyMatrix4(b,o),a.normal.toArray(p,M),p[M+3]=a.constant}c.value=p,c.needsUpdate=!0}return t.numPlanes=v,t.numIntersection=0,p}}const ss=4,u0=[.125,.215,.35,.446,.526,.582],Ss=20,V_=256,qr=new Ir,d0=new vt;let el=null,nl=0,il=0,sl=!1;const W_=new P;class f0{constructor(t){this._renderer=t,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(t,e=0,n=.1,i=100,r={}){const{size:a=256,position:o=W_}=r;el=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),il=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,i,c,o),e>0&&this._blur(c,0,0,e),this._applyPMREM(c),this._cleanup(c),c}fromEquirectangular(t,e=null){return this._fromTexture(t,e)}fromCubemap(t,e=null){return this._fromTexture(t,e)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=g0(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=m0(),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(el,nl,il),this._renderer.xr.enabled=sl,t.scissorTest=!1,sr(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Ds||t.mapping===Er?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),el=this._renderer.getRenderTarget(),nl=this._renderer.getActiveCubeFace(),il=this._renderer.getActiveMipmapLevel(),sl=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=e||this._allocateTargets();return this._textureToCubeUV(t,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const t=3*Math.max(this._cubeSize,112),e=4*this._cubeSize,n={magFilter:ye,minFilter:ye,generateMipmaps:!1,type:nn,format:fn,colorSpace:$o,depthBuffer:!1},i=p0(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=p0(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=X_(r)),this._blurMaterial=Y_(r,t,e),this._ggxMaterial=q_(r,t,e)}return i}_compileMaterial(t){const e=new $t(new be,t);this._renderer.compile(e,qr)}_sceneToCubeUV(t,e,n,i,r){const c=new yn(90,1,e,n),l=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,f=u.toneMapping;u.getClearColor(d0),u.toneMapping=gi,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(i),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new $t(new Bn,new Oi({name:"PMREM.Background",side:Be,depthWrite:!1,depthTest:!1})));const v=this._backgroundBox,p=v.material;let m=!1;const b=t.background;b?b.isColor&&(p.color.copy(b),t.background=null,m=!0):(p.color.copy(d0),m=!0);for(let E=0;E<6;E++){const M=E%3;M===0?(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[E],r.y,r.z)):M===1?(c.up.set(0,0,l[E]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[E],r.z)):(c.up.set(0,l[E],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[E]));const S=this._cubeSize;sr(i,M*S,E>2?S:0,S,S),u.setRenderTarget(i),m&&u.render(v,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=b}_textureToCubeUV(t,e){const n=this._renderer,i=t.mapping===Ds||t.mapping===Er;i?(this._cubemapMaterial===null&&(this._cubemapMaterial=g0()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=m0());const r=i?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;sr(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,qr)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const i=this._lodMeshes.length;for(let r=1;r<i;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const i=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const c=a.uniforms,l=n/(this._lodMeshes.length-1),h=e/(this._lodMeshes.length-1),u=Math.sqrt(l*l-h*h),d=0+l*1.25,f=u*d,{_lodMax:g}=this,v=this._sizeLods[n],p=3*v*(n>g-ss?n-g+ss:0),m=4*(this._cubeSize-v);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=g-e,sr(r,p,m,3*v,2*v),i.setRenderTarget(r),i.render(o,qr),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,sr(t,p,m,3*v,2*v),i.setRenderTarget(t),i.render(o,qr)}_blur(t,e,n,i,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,i,"latitudinal",r),this._halfBlur(a,t,n,n,i,"longitudinal",r)}_halfBlur(t,e,n,i,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&zt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[i];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ss-1),v=r/g,p=isFinite(r)?1+Math.floor(h*v):Ss;p>Ss&&wt(`sigmaRadians, ${r}, is too large and will clip, as it requested ${p} samples when the maximum is set to ${Ss}`);const m=[];let b=0;for(let R=0;R<Ss;++R){const _=R/v,A=Math.exp(-_*_/2);m.push(A),R===0?b+=A:R<p&&(b+=2*A)}for(let R=0;R<m.length;R++)m[R]=m[R]/b;d.envMap.value=t.texture,d.samples.value=p,d.weights.value=m,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:E}=this;d.dTheta.value=g,d.mipInt.value=E-n;const M=this._sizeLods[i],S=3*M*(i>E-ss?i-E+ss:0),w=4*(this._cubeSize-M);sr(e,S,w,3*M,2*M),c.setRenderTarget(e),c.render(u,qr)}}function X_(s){const t=[],e=[],n=[];let i=s;const r=s-ss+1+u0.length;for(let a=0;a<r;a++){const o=Math.pow(2,i);t.push(o);let c=1/o;a>s-ss?c=u0[a-s+ss-1]:a===0&&(c=0),e.push(c);const l=1/(o-2),h=-l,u=1+l,d=[h,h,u,h,u,u,h,h,u,u,h,u],f=6,g=6,v=3,p=2,m=1,b=new Float32Array(v*g*f),E=new Float32Array(p*g*f),M=new Float32Array(m*g*f);for(let w=0;w<f;w++){const R=w%3*2/3-1,_=w>2?0:-1,A=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];b.set(A,v*g*w),E.set(d,p*g*w);const C=[w,w,w,w,w,w];M.set(C,m*g*w)}const S=new be;S.setAttribute("position",new de(b,v)),S.setAttribute("uv",new de(E,p)),S.setAttribute("faceIndex",new de(M,m)),n.push(new $t(S,null)),i>ss&&i--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function p0(s,t,e){const n=new Sn(s,t,e);return n.texture.mapping=hc,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function sr(s,t,e,n,i){s.viewport.set(t,e,n,i),s.scissor.set(t,e,n,i)}function q_(s,t,e){return new De({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:V_,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:fc(),fragmentShader:`
|
|
4189
4189
|
|
|
4190
4190
|
precision highp float;
|
|
4191
4191
|
precision highp int;
|
|
@@ -4289,7 +4289,7 @@ void main() {
|
|
|
4289
4289
|
|
|
4290
4290
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
4291
4291
|
}
|
|
4292
|
-
`,blending:mi,depthTest:!1,depthWrite:!1})}function
|
|
4292
|
+
`,blending:mi,depthTest:!1,depthWrite:!1})}function Y_(s,t,e){const n=new Float32Array(Ss),i=new P(0,1,0);return new De({name:"SphericalGaussianBlur",defines:{n:Ss,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${s}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:i}},vertexShader:fc(),fragmentShader:`
|
|
4293
4293
|
|
|
4294
4294
|
precision mediump float;
|
|
4295
4295
|
precision mediump int;
|
|
@@ -4474,7 +4474,7 @@ void main() {
|
|
|
4474
4474
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4475
4475
|
|
|
4476
4476
|
}
|
|
4477
|
-
`},i=new Bn(5,5,5),r=new De({name:"CubemapFromEquirect",uniforms:Ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Be,blending:mi});r.uniforms.tEquirect.value=e;const a=new $t(i,r),o=e.minFilter;return e.minFilter===ws&&(e.minFilter=ye),new
|
|
4477
|
+
`},i=new Bn(5,5,5),r=new De({name:"CubemapFromEquirect",uniforms:Ar(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Be,blending:mi});r.uniforms.tEquirect.value=e;const a=new $t(i,r),o=e.minFilter;return e.minFilter===ws&&(e.minFilter=ye),new W2(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,i=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,i);t.setRenderTarget(r)}}function K_(s){let t=new WeakMap,e=new WeakMap,n=null;function i(d,f=!1){return d==null?null:f?a(d):r(d)}function r(d){if(d&&d.isTexture){const f=d.mapping;if(f===Sc||f===bc)if(t.has(d)){const g=t.get(d).texture;return o(g,d.mapping)}else{const g=d.image;if(g&&g.height>0){const v=new zp(g.height);return v.fromEquirectangularTexture(s,d),t.set(d,v),d.addEventListener("dispose",l),o(v.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,g=f===Sc||f===bc,v=f===Ds||f===Er;if(g||v){let p=e.get(d);const m=p!==void 0?p.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==m)return n===null&&(n=new f0(s)),p=g?n.fromEquirectangular(d,p):n.fromCubemap(d,p),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),p.texture;if(p!==void 0)return p.texture;{const b=d.image;return g&&b&&b.height>0||v&&b&&c(b)?(n===null&&(n=new f0(s)),p=g?n.fromEquirectangular(d):n.fromCubemap(d),p.texture.pmremVersion=d.pmremVersion,e.set(d,p),d.addEventListener("dispose",h),p.texture):null}}}return d}function o(d,f){return f===Sc?d.mapping=Ds:f===bc&&(d.mapping=Er),d}function c(d){let f=0;const g=6;for(let v=0;v<g;v++)d[v]!==void 0&&f++;return f===g}function l(d){const f=d.target;f.removeEventListener("dispose",l);const g=t.get(f);g!==void 0&&(t.delete(f),g.dispose())}function h(d){const f=d.target;f.removeEventListener("dispose",h);const g=e.get(f);g!==void 0&&(e.delete(f),g.dispose())}function u(){t=new WeakMap,e=new WeakMap,n!==null&&(n.dispose(),n=null)}return{get:i,dispose:u}}function $_(s){const t={};function e(n){if(t[n]!==void 0)return t[n];const i=s.getExtension(n);return t[n]=i,i}return{has:function(n){return e(n)!==null},init:function(){e("EXT_color_buffer_float"),e("WEBGL_clip_cull_distance"),e("OES_texture_float_linear"),e("EXT_color_buffer_half_float"),e("WEBGL_multisampled_render_to_texture"),e("WEBGL_render_shared_exponent")},get:function(n){const i=e(n);return i===null&&gr("WebGLRenderer: "+n+" extension not supported."),i}}}function Z_(s,t,e,n){const i={},r=new WeakMap;function a(u){const d=u.target;d.index!==null&&t.remove(d.index);for(const g in d.attributes)t.remove(d.attributes[g]);d.removeEventListener("dispose",a),delete i[d.id];const f=r.get(d);f&&(t.remove(f),r.delete(d)),n.releaseStatesOfGeometry(d),d.isInstancedBufferGeometry===!0&&delete d._maxInstanceCount,e.memory.geometries--}function o(u,d){return i[d.id]===!0||(d.addEventListener("dispose",a),i[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.update(d[f],s.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,g=u.attributes.position;let v=0;if(g===void 0)return;if(f!==null){const b=f.array;v=f.version;for(let E=0,M=b.length;E<M;E+=3){const S=b[E+0],w=b[E+1],R=b[E+2];d.push(S,w,w,R,R,S)}}else{const b=g.array;v=g.version;for(let E=0,M=b.length/3-1;E<M;E+=3){const S=E+0,w=E+1,R=E+2;d.push(S,w,w,R,R,S)}}const p=new(g.count>=65535?xu:Ep)(d,1);p.version=v;const m=r.get(u);m&&t.remove(m),r.set(u,p)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function J_(s,t,e){let n;function i(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){s.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,f){f!==0&&(s.drawElementsInstanced(n,d,r,u*a,f),e.update(d,n,f))}function h(u,d,f){if(f===0)return;t.get("WEBGL_multi_draw").multiDrawElementsWEBGL(n,d,0,r,u,0,f);let v=0;for(let p=0;p<f;p++)v+=d[p];e.update(v,n,1)}this.setMode=i,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Q_(s){const t={geometries:0,textures:0},e={frame:0,calls:0,triangles:0,points:0,lines:0};function n(r,a,o){switch(e.calls++,a){case s.TRIANGLES:e.triangles+=o*(r/3);break;case s.LINES:e.lines+=o*(r/2);break;case s.LINE_STRIP:e.lines+=o*(r-1);break;case s.LINE_LOOP:e.lines+=o*r;break;case s.POINTS:e.points+=o*r;break;default:zt("WebGLInfo: Unknown draw mode:",a);break}}function i(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:i,update:n}}function j_(s,t,e){const n=new WeakMap,i=new le;function r(a,o,c){const l=a.morphTargetInfluences,h=o.morphAttributes.position||o.morphAttributes.normal||o.morphAttributes.color,u=h!==void 0?h.length:0;let d=n.get(o);if(d===void 0||d.count!==u){let A=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",A)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,v=o.morphAttributes.color!==void 0,p=o.morphAttributes.position||[],m=o.morphAttributes.normal||[],b=o.morphAttributes.color||[];let E=0;f===!0&&(E=1),g===!0&&(E=2),v===!0&&(E=3);let M=o.attributes.position.count*E,S=1;M>t.maxTextureSize&&(S=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const w=new Float32Array(M*S*4*u),R=new Sp(w,M,S,u);R.type=zn,R.needsUpdate=!0;const _=E*4;for(let C=0;C<u;C++){const D=p[C],I=m[C],V=b[C],q=M*S*4*C;for(let O=0;O<D.count;O++){const W=O*_;f===!0&&(i.fromBufferAttribute(D,O),w[q+W+0]=i.x,w[q+W+1]=i.y,w[q+W+2]=i.z,w[q+W+3]=0),g===!0&&(i.fromBufferAttribute(I,O),w[q+W+4]=i.x,w[q+W+5]=i.y,w[q+W+6]=i.z,w[q+W+7]=0),v===!0&&(i.fromBufferAttribute(V,O),w[q+W+8]=i.x,w[q+W+9]=i.y,w[q+W+10]=i.z,w[q+W+11]=V.itemSize===4?i.w:1)}}d={count:u,texture:R,size:new Pt(M,S)},n.set(o,d),o.addEventListener("dispose",A)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(s,"morphTexture",a.morphTexture,e);else{let f=0;for(let v=0;v<l.length;v++)f+=l[v];const g=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(s,"morphTargetBaseInfluence",g),c.getUniforms().setValue(s,"morphTargetInfluences",l)}c.getUniforms().setValue(s,"morphTargetsTexture",d.texture,e),c.getUniforms().setValue(s,"morphTargetsTextureSize",d.size)}return{update:r}}function tM(s,t,e,n,i){let r=new WeakMap;function a(l){const h=i.render.frame,u=l.geometry,d=t.get(l,u);if(r.get(d)!==h&&(t.update(d),r.set(d,h)),l.isInstancedMesh&&(l.hasEventListener("dispose",c)===!1&&l.addEventListener("dispose",c),r.get(l)!==h&&(e.update(l.instanceMatrix,s.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,s.ARRAY_BUFFER),r.set(l,h))),l.isSkinnedMesh){const f=l.skeleton;r.get(f)!==h&&(f.update(),r.set(f,h))}return d}function o(){r=new WeakMap}function c(l){const h=l.target;h.removeEventListener("dispose",c),n.releaseStatesOfObject(h),e.remove(h.instanceMatrix),h.instanceColor!==null&&e.remove(h.instanceColor)}return{update:a,dispose:o}}const eM={[op]:"LINEAR_TONE_MAPPING",[cp]:"REINHARD_TONE_MAPPING",[lp]:"CINEON_TONE_MAPPING",[hp]:"ACES_FILMIC_TONE_MAPPING",[dp]:"AGX_TONE_MAPPING",[fp]:"NEUTRAL_TONE_MAPPING",[up]:"CUSTOM_TONE_MAPPING"};function nM(s,t,e,n,i,r){const a=new Sn(t,e,{type:s,depthBuffer:i,stencilBuffer:r,samples:n?4:0,depthTexture:i?new Ps(t,e):void 0}),o=new Sn(t,e,{type:nn,depthBuffer:!1,stencilBuffer:!1}),c=new be;c.setAttribute("position",new Se([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new Se([0,2,0,0,2,0],2));const l=new y2({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4478
4478
|
precision highp float;
|
|
4479
4479
|
|
|
4480
4480
|
uniform mat4 modelViewMatrix;
|
|
@@ -4520,17 +4520,17 @@ void main() {
|
|
|
4520
4520
|
#ifdef SRGB_TRANSFER
|
|
4521
4521
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4522
4522
|
#endif
|
|
4523
|
-
}`,depthTest:!1,depthWrite:!1}),h=new $t(c,l),u=new Ir(-1,1,1,-1,0,1);let d=null,f=null,g=!1,v,p=null,m=[],b=!1;this.setSize=function(E,M){a.setSize(E,M),o.setSize(E,M);for(let S=0;S<m.length;S++){const w=m[S];w.setSize&&w.setSize(E,M)}},this.setEffects=function(E){m=E,b=m.length>0&&m[0].isRenderPass===!0;const M=a.width,S=a.height;for(let w=0;w<m.length;w++){const R=m[w];R.setSize&&R.setSize(M,S)}},this.begin=function(E,M){if(g||E.toneMapping===gi&&m.length===0)return!1;if(p=M,M!==null){const S=M.width,w=M.height;(a.width!==S||a.height!==w)&&this.setSize(S,w)}return b===!1&&E.setRenderTarget(a),v=E.toneMapping,E.toneMapping=gi,!0},this.hasRenderPass=function(){return b},this.end=function(E,M){E.toneMapping=v,g=!0;let S=a,w=o;for(let R=0;R<m.length;R++){const _=m[R];if(_.enabled!==!1&&(_.render(E,w,S,M),_.needsSwap!==!1)){const A=S;S=w,w=A}}if(d!==E.outputColorSpace||f!==E.toneMapping){d=E.outputColorSpace,f=E.toneMapping,l.defines={},Qt.getTransfer(d)===se&&(l.defines.SRGB_TRANSFER="");const R=
|
|
4523
|
+
}`,depthTest:!1,depthWrite:!1}),h=new $t(c,l),u=new Ir(-1,1,1,-1,0,1);let d=null,f=null,g=!1,v,p=null,m=[],b=!1;this.setSize=function(E,M){a.setSize(E,M),o.setSize(E,M);for(let S=0;S<m.length;S++){const w=m[S];w.setSize&&w.setSize(E,M)}},this.setEffects=function(E){m=E,b=m.length>0&&m[0].isRenderPass===!0;const M=a.width,S=a.height;for(let w=0;w<m.length;w++){const R=m[w];R.setSize&&R.setSize(M,S)}},this.begin=function(E,M){if(g||E.toneMapping===gi&&m.length===0)return!1;if(p=M,M!==null){const S=M.width,w=M.height;(a.width!==S||a.height!==w)&&this.setSize(S,w)}return b===!1&&E.setRenderTarget(a),v=E.toneMapping,E.toneMapping=gi,!0},this.hasRenderPass=function(){return b},this.end=function(E,M){E.toneMapping=v,g=!0;let S=a,w=o;for(let R=0;R<m.length;R++){const _=m[R];if(_.enabled!==!1&&(_.render(E,w,S,M),_.needsSwap!==!1)){const A=S;S=w,w=A}}if(d!==E.outputColorSpace||f!==E.toneMapping){d=E.outputColorSpace,f=E.toneMapping,l.defines={},Qt.getTransfer(d)===se&&(l.defines.SRGB_TRANSFER="");const R=eM[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=S.texture,E.setRenderTarget(p),E.render(h,u),p=null,g=!1},this.isCompositing=function(){return g},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),c.dispose(),l.dispose()}}const Bp=new $e,Rh=new Ps(1,1),kp=new Sp,Hp=new X1,Gp=new Dp,v0=[],x0=[],_0=new Float32Array(16),M0=new Float32Array(9),y0=new Float32Array(4);function Lr(s,t,e){const n=s[0];if(n<=0||n>0)return s;const i=t*e;let r=v0[i];if(r===void 0&&(r=new Float32Array(i),v0[i]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,s[a].toArray(r,o)}return r}function He(s,t){if(s.length!==t.length)return!1;for(let e=0,n=s.length;e<n;e++)if(s[e]!==t[e])return!1;return!0}function Ge(s,t){for(let e=0,n=t.length;e<n;e++)s[e]=t[e]}function pc(s,t){let e=x0[t];e===void 0&&(e=new Int32Array(t),x0[t]=e);for(let n=0;n!==t;++n)e[n]=s.allocateTextureUnit();return e}function iM(s,t){const e=this.cache;e[0]!==t&&(s.uniform1f(this.addr,t),e[0]=t)}function sM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(He(e,t))return;s.uniform2fv(this.addr,t),Ge(e,t)}}function rM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3f(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else if(t.r!==void 0)(e[0]!==t.r||e[1]!==t.g||e[2]!==t.b)&&(s.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(He(e,t))return;s.uniform3fv(this.addr,t),Ge(e,t)}}function aM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4f(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(He(e,t))return;s.uniform4fv(this.addr,t),Ge(e,t)}}function oM(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(He(e,t))return;s.uniformMatrix2fv(this.addr,!1,t),Ge(e,t)}else{if(He(e,n))return;y0.set(n),s.uniformMatrix2fv(this.addr,!1,y0),Ge(e,n)}}function cM(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(He(e,t))return;s.uniformMatrix3fv(this.addr,!1,t),Ge(e,t)}else{if(He(e,n))return;M0.set(n),s.uniformMatrix3fv(this.addr,!1,M0),Ge(e,n)}}function lM(s,t){const e=this.cache,n=t.elements;if(n===void 0){if(He(e,t))return;s.uniformMatrix4fv(this.addr,!1,t),Ge(e,t)}else{if(He(e,n))return;_0.set(n),s.uniformMatrix4fv(this.addr,!1,_0),Ge(e,n)}}function hM(s,t){const e=this.cache;e[0]!==t&&(s.uniform1i(this.addr,t),e[0]=t)}function uM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(He(e,t))return;s.uniform2iv(this.addr,t),Ge(e,t)}}function dM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(He(e,t))return;s.uniform3iv(this.addr,t),Ge(e,t)}}function fM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4i(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(He(e,t))return;s.uniform4iv(this.addr,t),Ge(e,t)}}function pM(s,t){const e=this.cache;e[0]!==t&&(s.uniform1ui(this.addr,t),e[0]=t)}function mM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(s.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(He(e,t))return;s.uniform2uiv(this.addr,t),Ge(e,t)}}function gM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(s.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(He(e,t))return;s.uniform3uiv(this.addr,t),Ge(e,t)}}function vM(s,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z||e[3]!==t.w)&&(s.uniform4ui(this.addr,t.x,t.y,t.z,t.w),e[0]=t.x,e[1]=t.y,e[2]=t.z,e[3]=t.w);else{if(He(e,t))return;s.uniform4uiv(this.addr,t),Ge(e,t)}}function xM(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i);let r;this.type===s.SAMPLER_2D_SHADOW?(Rh.compareFunction=e.isReversedDepthBuffer()?fu:du,r=Rh):r=Bp,e.setTexture2D(t||r,i)}function _M(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture3D(t||Hp,i)}function MM(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTextureCube(t||Gp,i)}function yM(s,t,e){const n=this.cache,i=e.allocateTextureUnit();n[0]!==i&&(s.uniform1i(this.addr,i),n[0]=i),e.setTexture2DArray(t||kp,i)}function SM(s){switch(s){case 5126:return iM;case 35664:return sM;case 35665:return rM;case 35666:return aM;case 35674:return oM;case 35675:return cM;case 35676:return lM;case 5124:case 35670:return hM;case 35667:case 35671:return uM;case 35668:case 35672:return dM;case 35669:case 35673:return fM;case 5125:return pM;case 36294:return mM;case 36295:return gM;case 36296:return vM;case 35678:case 36198:case 36298:case 36306:case 35682:return xM;case 35679:case 36299:case 36307:return _M;case 35680:case 36300:case 36308:case 36293:return MM;case 36289:case 36303:case 36311:case 36292:return yM}}function bM(s,t){s.uniform1fv(this.addr,t)}function EM(s,t){const e=Lr(t,this.size,2);s.uniform2fv(this.addr,e)}function wM(s,t){const e=Lr(t,this.size,3);s.uniform3fv(this.addr,e)}function AM(s,t){const e=Lr(t,this.size,4);s.uniform4fv(this.addr,e)}function TM(s,t){const e=Lr(t,this.size,4);s.uniformMatrix2fv(this.addr,!1,e)}function RM(s,t){const e=Lr(t,this.size,9);s.uniformMatrix3fv(this.addr,!1,e)}function DM(s,t){const e=Lr(t,this.size,16);s.uniformMatrix4fv(this.addr,!1,e)}function CM(s,t){s.uniform1iv(this.addr,t)}function PM(s,t){s.uniform2iv(this.addr,t)}function IM(s,t){s.uniform3iv(this.addr,t)}function LM(s,t){s.uniform4iv(this.addr,t)}function NM(s,t){s.uniform1uiv(this.addr,t)}function OM(s,t){s.uniform2uiv(this.addr,t)}function UM(s,t){s.uniform3uiv(this.addr,t)}function FM(s,t){s.uniform4uiv(this.addr,t)}function zM(s,t,e){const n=this.cache,i=t.length,r=pc(e,i);He(n,r)||(s.uniform1iv(this.addr,r),Ge(n,r));let a;this.type===s.SAMPLER_2D_SHADOW?a=Rh:a=Bp;for(let o=0;o!==i;++o)e.setTexture2D(t[o]||a,r[o])}function BM(s,t,e){const n=this.cache,i=t.length,r=pc(e,i);He(n,r)||(s.uniform1iv(this.addr,r),Ge(n,r));for(let a=0;a!==i;++a)e.setTexture3D(t[a]||Hp,r[a])}function kM(s,t,e){const n=this.cache,i=t.length,r=pc(e,i);He(n,r)||(s.uniform1iv(this.addr,r),Ge(n,r));for(let a=0;a!==i;++a)e.setTextureCube(t[a]||Gp,r[a])}function HM(s,t,e){const n=this.cache,i=t.length,r=pc(e,i);He(n,r)||(s.uniform1iv(this.addr,r),Ge(n,r));for(let a=0;a!==i;++a)e.setTexture2DArray(t[a]||kp,r[a])}function GM(s){switch(s){case 5126:return bM;case 35664:return EM;case 35665:return wM;case 35666:return AM;case 35674:return TM;case 35675:return RM;case 35676:return DM;case 5124:case 35670:return CM;case 35667:case 35671:return PM;case 35668:case 35672:return IM;case 35669:case 35673:return LM;case 5125:return NM;case 36294:return OM;case 36295:return UM;case 36296:return FM;case 35678:case 36198:case 36298:case 36306:case 35682:return zM;case 35679:case 36299:case 36307:return BM;case 35680:case 36300:case 36308:case 36293:return kM;case 36289:case 36303:case 36311:case 36292:return HM}}class VM{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=SM(e.type)}}class WM{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=GM(e.type)}}class XM{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const i=this.seq;for(let r=0,a=i.length;r!==a;++r){const o=i[r];o.setValue(t,e[o.id],n)}}}const rl=/(\w+)(\])?(\[|\.)?/g;function S0(s,t){s.seq.push(t),s.map[t.id]=t}function qM(s,t,e){const n=s.name,i=n.length;for(rl.lastIndex=0;;){const r=rl.exec(n),a=rl.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===i){S0(e,l===void 0?new VM(o,s,t):new WM(o,s,t));break}else{let u=e.map[o];u===void 0&&(u=new XM(o),S0(e,u)),e=u}}}class zo{constructor(t,e){this.seq=[],this.map={};const n=t.getProgramParameter(e,t.ACTIVE_UNIFORMS);for(let a=0;a<n;++a){const o=t.getActiveUniform(e,a),c=t.getUniformLocation(e,o.name);qM(o,c,this)}const i=[],r=[];for(const a of this.seq)a.type===t.SAMPLER_2D_SHADOW||a.type===t.SAMPLER_CUBE_SHADOW||a.type===t.SAMPLER_2D_ARRAY_SHADOW?i.push(a):r.push(a);i.length>0&&(this.seq=i.concat(r))}setValue(t,e,n,i){const r=this.map[e];r!==void 0&&r.setValue(t,n,i)}setOptional(t,e,n){const i=e[n];i!==void 0&&this.setValue(t,n,i)}static upload(t,e,n,i){for(let r=0,a=e.length;r!==a;++r){const o=e[r],c=n[o.id];c.needsUpdate!==!1&&o.setValue(t,c.value,i)}}static seqWithValue(t,e){const n=[];for(let i=0,r=t.length;i!==r;++i){const a=t[i];a.id in e&&n.push(a)}return n}}function b0(s,t,e){const n=s.createShader(t);return s.shaderSource(n,e),s.compileShader(n),n}const YM=37297;let KM=0;function $M(s,t){const e=s.split(`
|
|
4524
4524
|
`),n=[],i=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=i;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
|
|
4525
|
-
`)}const E0=new Bt;function
|
|
4525
|
+
`)}const E0=new Bt;function ZM(s){Qt._getMatrix(E0,Qt.workingColorSpace,s);const t=`mat3( ${E0.elements.map(e=>e.toFixed(4))} )`;switch(Qt.getTransfer(s)){case Zo:return[t,"LinearTransferOETF"];case se:return[t,"sRGBTransferOETF"];default:return wt("WebGLProgram: Unsupported color space: ",s),[t,"LinearTransferOETF"]}}function w0(s,t,e){const n=s.getShaderParameter(t,s.COMPILE_STATUS),r=(s.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
|
|
4526
4526
|
|
|
4527
4527
|
`+r+`
|
|
4528
4528
|
|
|
4529
|
-
|
|
4530
|
-
`)}const
|
|
4531
|
-
`)}function
|
|
4532
|
-
`)}function
|
|
4533
|
-
`)}function
|
|
4529
|
+
`+$M(s.getShaderSource(t),o)}else return r}function JM(s,t){const e=ZM(t);return[`vec4 ${s}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
4530
|
+
`)}const QM={[op]:"Linear",[cp]:"Reinhard",[lp]:"Cineon",[hp]:"ACESFilmic",[dp]:"AgX",[fp]:"Neutral",[up]:"Custom"};function jM(s,t){const e=QM[t];return e===void 0?(wt("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+s+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+s+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const mo=new P;function ty(){Qt.getLuminanceCoefficients(mo);const s=mo.x.toFixed(4),t=mo.y.toFixed(4),e=mo.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${s}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
4531
|
+
`)}function ey(s){return[s.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",s.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ea).join(`
|
|
4532
|
+
`)}function ny(s){const t=[];for(const e in s){const n=s[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
4533
|
+
`)}function iy(s,t){const e={},n=s.getProgramParameter(t,s.ACTIVE_ATTRIBUTES);for(let i=0;i<n;i++){const r=s.getActiveAttrib(t,i),a=r.name;let o=1;r.type===s.FLOAT_MAT2&&(o=2),r.type===s.FLOAT_MAT3&&(o=3),r.type===s.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:s.getAttribLocation(t,a),locationSize:o}}return e}function ea(s){return s!==""}function A0(s,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return s.replace(/NUM_DIR_LIGHTS/g,t.numDirLights).replace(/NUM_SPOT_LIGHTS/g,t.numSpotLights).replace(/NUM_SPOT_LIGHT_MAPS/g,t.numSpotLightMaps).replace(/NUM_SPOT_LIGHT_COORDS/g,e).replace(/NUM_RECT_AREA_LIGHTS/g,t.numRectAreaLights).replace(/NUM_POINT_LIGHTS/g,t.numPointLights).replace(/NUM_HEMI_LIGHTS/g,t.numHemiLights).replace(/NUM_DIR_LIGHT_SHADOWS/g,t.numDirLightShadows).replace(/NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS/g,t.numSpotLightShadowsWithMaps).replace(/NUM_SPOT_LIGHT_SHADOWS/g,t.numSpotLightShadows).replace(/NUM_POINT_LIGHT_SHADOWS/g,t.numPointLightShadows)}function T0(s,t){return s.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const sy=/^[ \t]*#include +<([\w\d./]+)>/gm;function Dh(s){return s.replace(sy,ay)}const ry=new Map;function ay(s,t){let e=Wt[t];if(e===void 0){const n=ry.get(t);if(n!==void 0)e=Wt[n],wt('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return Dh(e)}const oy=/#pragma unroll_loop_start\s+for\s*\(\s*int\s+i\s*=\s*(\d+)\s*;\s*i\s*<\s*(\d+)\s*;\s*i\s*\+\+\s*\)\s*{([\s\S]+?)}\s+#pragma unroll_loop_end/g;function R0(s){return s.replace(oy,cy)}function cy(s,t,e,n){let i="";for(let r=parseInt(t);r<parseInt(e);r++)i+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return i}function D0(s){let t=`precision ${s.precision} float;
|
|
4534
4534
|
precision ${s.precision} int;
|
|
4535
4535
|
precision ${s.precision} sampler2D;
|
|
4536
4536
|
precision ${s.precision} samplerCube;
|
|
@@ -4550,14 +4550,14 @@ void main() {
|
|
|
4550
4550
|
`;return s.precision==="highp"?t+=`
|
|
4551
4551
|
#define HIGH_PRECISION`:s.precision==="mediump"?t+=`
|
|
4552
4552
|
#define MEDIUM_PRECISION`:s.precision==="lowp"&&(t+=`
|
|
4553
|
-
#define LOW_PRECISION`),t}const
|
|
4553
|
+
#define LOW_PRECISION`),t}const ly={[ra]:"SHADOWMAP_TYPE_PCF",[jr]:"SHADOWMAP_TYPE_VSM"};function hy(s){return ly[s.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const uy={[Ds]:"ENVMAP_TYPE_CUBE",[Er]:"ENVMAP_TYPE_CUBE",[hc]:"ENVMAP_TYPE_CUBE_UV"};function dy(s){return s.envMap===!1?"ENVMAP_TYPE_CUBE":uy[s.envMapMode]||"ENVMAP_TYPE_CUBE"}const fy={[Er]:"ENVMAP_MODE_REFRACTION"};function py(s){return s.envMap===!1?"ENVMAP_MODE_REFLECTION":fy[s.envMapMode]||"ENVMAP_MODE_REFLECTION"}const my={[su]:"ENVMAP_BLENDING_MULTIPLY",[a1]:"ENVMAP_BLENDING_MIX",[o1]:"ENVMAP_BLENDING_ADD"};function gy(s){return s.envMap===!1?"ENVMAP_BLENDING_NONE":my[s.combine]||"ENVMAP_BLENDING_NONE"}function vy(s){const t=s.envMapCubeUVHeight;if(t===null)return null;const e=Math.log2(t)-2,n=1/t;return{texelWidth:1/(3*Math.max(Math.pow(2,e),112)),texelHeight:n,maxMip:e}}function xy(s,t,e,n){const i=s.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const c=hy(e),l=dy(e),h=py(e),u=gy(e),d=vy(e),f=ey(e),g=ny(r),v=i.createProgram();let p,m,b=e.glslVersion?"#version "+e.glslVersion+`
|
|
4554
4554
|
`:"";e.isRawShaderMaterial?(p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ea).join(`
|
|
4555
4555
|
`),p.length>0&&(p+=`
|
|
4556
4556
|
`),m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ea).join(`
|
|
4557
4557
|
`),m.length>0&&(m+=`
|
|
4558
4558
|
`)):(p=[D0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",e.batching?"#define USE_BATCHING":"",e.batchingColor?"#define USE_BATCHING_COLOR":"",e.instancing?"#define USE_INSTANCING":"",e.instancingColor?"#define USE_INSTANCING_COLOR":"",e.instancingMorph?"#define USE_INSTANCING_MORPH":"",e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.map?"#define USE_MAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+h:"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.displacementMap?"#define USE_DISPLACEMENTMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.mapUv?"#define MAP_UV "+e.mapUv:"",e.alphaMapUv?"#define ALPHAMAP_UV "+e.alphaMapUv:"",e.lightMapUv?"#define LIGHTMAP_UV "+e.lightMapUv:"",e.aoMapUv?"#define AOMAP_UV "+e.aoMapUv:"",e.emissiveMapUv?"#define EMISSIVEMAP_UV "+e.emissiveMapUv:"",e.bumpMapUv?"#define BUMPMAP_UV "+e.bumpMapUv:"",e.normalMapUv?"#define NORMALMAP_UV "+e.normalMapUv:"",e.displacementMapUv?"#define DISPLACEMENTMAP_UV "+e.displacementMapUv:"",e.metalnessMapUv?"#define METALNESSMAP_UV "+e.metalnessMapUv:"",e.roughnessMapUv?"#define ROUGHNESSMAP_UV "+e.roughnessMapUv:"",e.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+e.anisotropyMapUv:"",e.clearcoatMapUv?"#define CLEARCOATMAP_UV "+e.clearcoatMapUv:"",e.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+e.clearcoatNormalMapUv:"",e.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+e.clearcoatRoughnessMapUv:"",e.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+e.iridescenceMapUv:"",e.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+e.iridescenceThicknessMapUv:"",e.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+e.sheenColorMapUv:"",e.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+e.sheenRoughnessMapUv:"",e.specularMapUv?"#define SPECULARMAP_UV "+e.specularMapUv:"",e.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+e.specularColorMapUv:"",e.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+e.specularIntensityMapUv:"",e.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+e.transmissionMapUv:"",e.thicknessMapUv?"#define THICKNESSMAP_UV "+e.thicknessMapUv:"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexNormals?"#define HAS_NORMAL":"",e.vertexColors?"#define USE_COLOR":"",e.vertexAlphas?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.flatShading?"#define FLAT_SHADED":"",e.skinning?"#define USE_SKINNING":"",e.morphTargets?"#define USE_MORPHTARGETS":"",e.morphNormals&&e.flatShading===!1?"#define USE_MORPHNORMALS":"",e.morphColors?"#define USE_MORPHCOLORS":"",e.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+e.morphTextureStride:"",e.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+e.morphTargetsCount:"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.sizeAttenuation?"#define USE_SIZEATTENUATION":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",`
|
|
4559
4559
|
`].filter(ea).join(`
|
|
4560
|
-
`),m=[D0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==gi?"#define TONE_MAPPING":"",e.toneMapping!==gi?Wt.tonemapping_pars_fragment:"",e.toneMapping!==gi?
|
|
4560
|
+
`),m=[D0(e),"#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g,e.useFog&&e.fog?"#define USE_FOG":"",e.useFog&&e.fogExp2?"#define FOG_EXP2":"",e.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",e.map?"#define USE_MAP":"",e.matcap?"#define USE_MATCAP":"",e.envMap?"#define USE_ENVMAP":"",e.envMap?"#define "+l:"",e.envMap?"#define "+h:"",e.envMap?"#define "+u:"",d?"#define CUBEUV_TEXEL_WIDTH "+d.texelWidth:"",d?"#define CUBEUV_TEXEL_HEIGHT "+d.texelHeight:"",d?"#define CUBEUV_MAX_MIP "+d.maxMip+".0":"",e.lightMap?"#define USE_LIGHTMAP":"",e.aoMap?"#define USE_AOMAP":"",e.bumpMap?"#define USE_BUMPMAP":"",e.normalMap?"#define USE_NORMALMAP":"",e.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",e.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",e.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",e.emissiveMap?"#define USE_EMISSIVEMAP":"",e.anisotropy?"#define USE_ANISOTROPY":"",e.anisotropyMap?"#define USE_ANISOTROPYMAP":"",e.clearcoat?"#define USE_CLEARCOAT":"",e.clearcoatMap?"#define USE_CLEARCOATMAP":"",e.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",e.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",e.dispersion?"#define USE_DISPERSION":"",e.iridescence?"#define USE_IRIDESCENCE":"",e.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",e.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",e.specularMap?"#define USE_SPECULARMAP":"",e.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",e.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",e.roughnessMap?"#define USE_ROUGHNESSMAP":"",e.metalnessMap?"#define USE_METALNESSMAP":"",e.alphaMap?"#define USE_ALPHAMAP":"",e.alphaTest?"#define USE_ALPHATEST":"",e.alphaHash?"#define USE_ALPHAHASH":"",e.sheen?"#define USE_SHEEN":"",e.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",e.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",e.transmission?"#define USE_TRANSMISSION":"",e.transmissionMap?"#define USE_TRANSMISSIONMAP":"",e.thicknessMap?"#define USE_THICKNESSMAP":"",e.vertexTangents&&e.flatShading===!1?"#define USE_TANGENT":"",e.vertexColors||e.instancingColor?"#define USE_COLOR":"",e.vertexAlphas||e.batchingColor?"#define USE_COLOR_ALPHA":"",e.vertexUv1s?"#define USE_UV1":"",e.vertexUv2s?"#define USE_UV2":"",e.vertexUv3s?"#define USE_UV3":"",e.pointsUvs?"#define USE_POINTS_UV":"",e.gradientMap?"#define USE_GRADIENTMAP":"",e.flatShading?"#define FLAT_SHADED":"",e.doubleSided?"#define DOUBLE_SIDED":"",e.flipSided?"#define FLIP_SIDED":"",e.shadowMapEnabled?"#define USE_SHADOWMAP":"",e.shadowMapEnabled?"#define "+c:"",e.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",e.numLightProbes>0?"#define USE_LIGHT_PROBES":"",e.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",e.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",e.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",e.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",e.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",e.toneMapping!==gi?"#define TONE_MAPPING":"",e.toneMapping!==gi?Wt.tonemapping_pars_fragment:"",e.toneMapping!==gi?jM("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Wt.colorspace_pars_fragment,JM("linearToOutputTexel",e.outputColorSpace),ty(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
4561
4561
|
`].filter(ea).join(`
|
|
4562
4562
|
`)),a=Dh(a),a=A0(a,e),a=T0(a,e),o=Dh(o),o=A0(o,e),o=T0(o,e),a=R0(a),o=R0(o),e.isRawShaderMaterial!==!0&&(b=`#version 300 es
|
|
4563
4563
|
`,p=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
@@ -4571,9 +4571,9 @@ Material Type: `+D.type+`
|
|
|
4571
4571
|
|
|
4572
4572
|
Program Info Log: `+O+`
|
|
4573
4573
|
`+j+`
|
|
4574
|
-
`+it)}else O!==""?wt("WebGLProgram: Program Info Log:",O):(W===""||G==="")&&(et=!1);et&&(D.diagnostics={runnable:Z,programLog:O,vertexShader:{log:W,prefix:p},fragmentShader:{log:G,prefix:m}})}i.deleteShader(S),i.deleteShader(w),_=new zo(i,v),A=ey(i,v)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=i.getProgramParameter(v,XM)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=qM++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=w,this}let vy=0;class xy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const i=this._getShaderCacheForMaterial(t);return i.has(e)===!1&&(i.add(e),e.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new _y(t),e.set(t,n)),n}}class _y{constructor(t){this.id=vy++,this.code=t,this.usedTimes=0}}function My(s){return s===Cs||s===Xo||s===qo}function yy(s,t,e,n,i,r){const a=new gu,o=new xy,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){return c.add(_),_===0?"uv":`uv${_}`}function v(_,A,C,D,I,V){const q=D.fog,O=I.geometry,W=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?D.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,Z=t.get(_.envMap||W,G),et=Z&&Z.mapping===hc?Z.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&wt("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const it=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ut=it!==void 0?it.length:0;let Ht=0;O.morphAttributes.position!==void 0&&(Ht=1),O.morphAttributes.normal!==void 0&&(Ht=2),O.morphAttributes.color!==void 0&&(Ht=3);let Jt,kt,Y,rt;if(j){const yt=ci[j];Jt=yt.vertexShader,kt=yt.fragmentShader}else{Jt=_.vertexShader,kt=_.fragmentShader;const yt=o.getVertexShaderStage(_),Ae=o.getFragmentShaderStage(_);o.update(_,yt,Ae),Y=yt.id,rt=Ae.id}const nt=s.getRenderTarget(),z=s.state.buffers.depth.getReversed(),Et=I.isInstancedMesh===!0,It=I.isBatchedMesh===!0,Tt=!!_.map,_t=!!_.matcap,Nt=!!Z,Ot=!!_.aoMap,Ut=!!_.lightMap,ee=!!_.bumpMap&&_.wireframe===!1,ne=!!_.normalMap,Ee=!!_.displacementMap,ve=!!_.emissiveMap,we=!!_.metalnessMap,Ne=!!_.roughnessMap,N=_.anisotropy>0,gn=_.clearcoat>0,ie=_.dispersion>0,T=_.iridescence>0,x=_.sheen>0,F=_.transmission>0,H=N&&!!_.anisotropyMap,K=gn&&!!_.clearcoatMap,st=gn&&!!_.clearcoatNormalMap,ot=gn&&!!_.clearcoatRoughnessMap,$=T&&!!_.iridescenceMap,Q=T&&!!_.iridescenceThicknessMap,ct=x&&!!_.sheenColorMap,Rt=x&&!!_.sheenRoughnessMap,dt=!!_.specularMap,lt=!!_.specularColorMap,Lt=!!_.specularIntensityMap,Ft=F&&!!_.transmissionMap,Gt=F&&!!_.thicknessMap,L=!!_.gradientMap,at=!!_.alphaMap,J=_.alphaTest>0,ht=!!_.alphaHash,gt=!!_.extensions;let tt=gi;_.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(tt=s.toneMapping);const At={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:Jt,fragmentShader:kt,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:It,batchingColor:It&&I._colorsTexture!==null,instancing:Et,instancingColor:Et&&I.instanceColor!==null,instancingMorph:Et&&I.morphTexture!==null,outputColorSpace:nt===null?s.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Qt.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Tt,matcap:_t,envMap:Nt,envMapMode:Nt&&Z.mapping,envMapCubeUVHeight:et,aoMap:Ot,lightMap:Ut,bumpMap:ee,normalMap:ne,displacementMap:Ee,emissiveMap:ve,normalMapObjectSpace:ne&&_.normalMapType===h1,normalMapTangentSpace:ne&&_.normalMapType===Ko,packedNormalMap:ne&&_.normalMapType===Ko&&My(_.normalMap.format),metalnessMap:we,roughnessMap:Ne,anisotropy:N,anisotropyMap:H,clearcoat:gn,clearcoatMap:K,clearcoatNormalMap:st,clearcoatRoughnessMap:ot,dispersion:ie,iridescence:T,iridescenceMap:$,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:ct,sheenRoughnessMap:Rt,specularMap:dt,specularColorMap:lt,specularIntensityMap:Lt,transmission:F,transmissionMap:Ft,thicknessMap:Gt,gradientMap:L,opaque:_.transparent===!1&&_.blending===mr&&_.alphaToCoverage===!1,alphaMap:at,alphaTest:J,alphaHash:ht,combine:_.combine,mapUv:Tt&&g(_.map.channel),aoMapUv:Ot&&g(_.aoMap.channel),lightMapUv:Ut&&g(_.lightMap.channel),bumpMapUv:ee&&g(_.bumpMap.channel),normalMapUv:ne&&g(_.normalMap.channel),displacementMapUv:Ee&&g(_.displacementMap.channel),emissiveMapUv:ve&&g(_.emissiveMap.channel),metalnessMapUv:we&&g(_.metalnessMap.channel),roughnessMapUv:Ne&&g(_.roughnessMap.channel),anisotropyMapUv:H&&g(_.anisotropyMap.channel),clearcoatMapUv:K&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:st&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:Rt&&g(_.sheenRoughnessMap.channel),specularMapUv:dt&&g(_.specularMap.channel),specularColorMapUv:lt&&g(_.specularColorMap.channel),specularIntensityMapUv:Lt&&g(_.specularIntensityMap.channel),transmissionMapUv:Ft&&g(_.transmissionMap.channel),thicknessMapUv:Gt&&g(_.thicknessMap.channel),alphaMapUv:at&&g(_.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ne||N),vertexNormals:!!O.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(Tt||at),fog:!!q,useFog:_.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||O.attributes.normal===void 0&&ne===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:Ht,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:V.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:s.shadowMap.enabled&&C.length>0,shadowMapType:s.shadowMap.type,toneMapping:tt,decodeVideoTexture:Tt&&_.map.isVideoTexture===!0&&Qt.getTransfer(_.map.colorSpace)===se,decodeVideoTextureEmissive:ve&&_.emissiveMap.isVideoTexture===!0&&Qt.getTransfer(_.emissiveMap.colorSpace)===se,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===qn,flipSided:_.side===Be,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:gt&&_.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&_.extensions.multiDraw===!0||It)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function p(_){const A=[];if(_.shaderID?A.push(_.shaderID):(A.push(_.customVertexShaderID),A.push(_.customFragmentShaderID)),_.defines!==void 0)for(const C in _.defines)A.push(C),A.push(_.defines[C]);return _.isRawShaderMaterial===!1&&(m(A,_),b(A,_),A.push(s.outputColorSpace)),A.push(_.customProgramCacheKey),A.join()}function m(_,A){_.push(A.precision),_.push(A.outputColorSpace),_.push(A.envMapMode),_.push(A.envMapCubeUVHeight),_.push(A.mapUv),_.push(A.alphaMapUv),_.push(A.lightMapUv),_.push(A.aoMapUv),_.push(A.bumpMapUv),_.push(A.normalMapUv),_.push(A.displacementMapUv),_.push(A.emissiveMapUv),_.push(A.metalnessMapUv),_.push(A.roughnessMapUv),_.push(A.anisotropyMapUv),_.push(A.clearcoatMapUv),_.push(A.clearcoatNormalMapUv),_.push(A.clearcoatRoughnessMapUv),_.push(A.iridescenceMapUv),_.push(A.iridescenceThicknessMapUv),_.push(A.sheenColorMapUv),_.push(A.sheenRoughnessMapUv),_.push(A.specularMapUv),_.push(A.specularColorMapUv),_.push(A.specularIntensityMapUv),_.push(A.transmissionMapUv),_.push(A.thicknessMapUv),_.push(A.combine),_.push(A.fogExp2),_.push(A.sizeAttenuation),_.push(A.morphTargetsCount),_.push(A.morphAttributeCount),_.push(A.numDirLights),_.push(A.numPointLights),_.push(A.numSpotLights),_.push(A.numSpotLightMaps),_.push(A.numHemiLights),_.push(A.numRectAreaLights),_.push(A.numDirLightShadows),_.push(A.numPointLightShadows),_.push(A.numSpotLightShadows),_.push(A.numSpotLightShadowsWithMaps),_.push(A.numLightProbes),_.push(A.shadowMapType),_.push(A.toneMapping),_.push(A.numClippingPlanes),_.push(A.numClipIntersection),_.push(A.depthPacking)}function b(_,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function E(_){const A=f[_.type];let C;if(A){const D=ci[A];C=g2.clone(D.uniforms)}else C=_.uniforms;return C}function M(_,A){let C=h.get(A);return C!==void 0?++C.usedTimes:(C=new gy(s,A,_,i),l.push(C),h.set(A,C)),C}function S(_){if(--_.usedTimes===0){const A=l.indexOf(_);l[A]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function w(_){o.remove(_)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:p,getUniforms:E,acquireProgram:M,releaseProgram:S,releaseShaderCache:w,programs:l,dispose:R}}function Sy(){let s=new WeakMap;function t(a){return s.has(a)}function e(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function by(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.materialVariant!==t.materialVariant?s.materialVariant-t.materialVariant:s.z!==t.z?s.z-t.z:s.id-t.id}function C0(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function P0(){const s=[];let t=0;const e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,g,v,p,m){let b=s[t];return b===void 0?(b={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:p,group:m},s[t]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=g,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=p,b.group=m),t++,b}function c(d,f,g,v,p,m){const b=o(d,f,g,v,p,m);g.transmission>0?n.push(b):g.transparent===!0?i.push(b):e.push(b)}function l(d,f,g,v,p,m){const b=o(d,f,g,v,p,m);g.transmission>0?n.unshift(b):g.transparent===!0?i.unshift(b):e.unshift(b)}function h(d,f,g){e.length>1&&e.sort(d||by),n.length>1&&n.sort(f||C0),i.length>1&&i.sort(f||C0),g&&(e.reverse(),n.reverse(),i.reverse())}function u(){for(let d=t,f=s.length;d<f;d++){const g=s[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:e,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function Ey(){let s=new WeakMap;function t(n,i){const r=s.get(n);let a;return r===void 0?(a=new P0,s.set(n,[a])):i>=r.length?(a=new P0,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function wy(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new vt};break;case"SpotLight":e={position:new P,direction:new P,color:new vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new vt,groundColor:new vt};break;case"RectAreaLight":e={color:new vt,position:new P,halfWidth:new P,halfHeight:new P};break}return s[t.id]=e,e}}}function Ay(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}let Ty=0;function Ry(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function Dy(s){const t=new wy,e=Ay(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new P);const i=new P,r=new Xt,a=new Xt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,g=0,v=0,p=0,m=0,b=0,E=0,M=0,S=0,w=0,R=0;l.sort(Ry);for(let A=0,C=l.length;A<C;A++){const D=l[A],I=D.color,V=D.intensity,q=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Cs?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*V,u+=I.g*V,d+=I.b*V;else if(D.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(D.sh.coefficients[W],V);R++}else if(D.isDirectionalLight){const W=t.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[f]=Z,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,b++}n.directional[f]=W,f++}else if(D.isSpotLight){const W=t.get(D);W.position.setFromMatrixPosition(D.matrixWorld),W.color.copy(I).multiplyScalar(V),W.distance=q,W.coneCos=Math.cos(D.angle),W.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),W.decay=D.decay,n.spot[v]=W;const G=D.shadow;if(D.map&&(n.spotLightMap[S]=D.map,S++,G.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=G.matrix,D.castShadow){const Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[v]=Z,n.spotShadowMap[v]=O,M++}v++}else if(D.isRectAreaLight){const W=t.get(D);W.color.copy(I).multiplyScalar(V),W.halfWidth.set(D.width*.5,0,0),W.halfHeight.set(0,D.height*.5,0),n.rectArea[p]=W,p++}else if(D.isPointLight){const W=t.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),W.distance=D.distance,W.decay=D.decay,D.castShadow){const G=D.shadow,Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=D.shadow.matrix,E++}n.point[g]=W,g++}else if(D.isHemisphereLight){const W=t.get(D);W.skyColor.copy(D.color).multiplyScalar(V),W.groundColor.copy(D.groundColor).multiplyScalar(V),n.hemi[m]=W,m++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const _=n.hash;(_.directionalLength!==f||_.pointLength!==g||_.spotLength!==v||_.rectAreaLength!==p||_.hemiLength!==m||_.numDirectionalShadows!==b||_.numPointShadows!==E||_.numSpotShadows!==M||_.numSpotMaps!==S||_.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=M+S-w,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,_.directionalLength=f,_.pointLength=g,_.spotLength=v,_.rectAreaLength=p,_.hemiLength=m,_.numDirectionalShadows=b,_.numPointShadows=E,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=Ty++)}function c(l,h){let u=0,d=0,f=0,g=0,v=0;const p=h.matrixWorldInverse;for(let m=0,b=l.length;m<b;m++){const E=l[m];if(E.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(p),u++}else if(E.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),M.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(p),f++}else if(E.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),a.identity(),r.copy(E.matrixWorld),r.premultiply(p),a.extractRotation(r),M.halfWidth.set(E.width*.5,0,0),M.halfHeight.set(0,E.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(E.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),d++}else if(E.isHemisphereLight){const M=n.hemi[v];M.direction.setFromMatrixPosition(E.matrixWorld),M.direction.transformDirection(p),v++}}}return{setup:o,setupView:c,state:n}}function I0(s){const t=new Dy(s),e=[],n=[],i=[];function r(d){u.camera=d,e.length=0,n.length=0,i.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Cy(s){let t=new WeakMap;function e(i,r=0){const a=t.get(i);let o;return a===void 0?(o=new I0(s),t.set(i,[o])):r>=a.length?(o=new I0(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const Py=`void main() {
|
|
4574
|
+
`+it)}else O!==""?wt("WebGLProgram: Program Info Log:",O):(W===""||G==="")&&(et=!1);et&&(D.diagnostics={runnable:Z,programLog:O,vertexShader:{log:W,prefix:p},fragmentShader:{log:G,prefix:m}})}i.deleteShader(S),i.deleteShader(w),_=new zo(i,v),A=iy(i,v)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let A;this.getAttributes=function(){return A===void 0&&R(this),A};let C=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return C===!1&&(C=i.getProgramParameter(v,YM)),C},this.destroy=function(){n.releaseStatesOfProgram(this),i.deleteProgram(v),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=KM++,this.cacheKey=t,this.usedTimes=1,this.program=v,this.vertexShader=S,this.fragmentShader=w,this}let _y=0;class My{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const i=this._getShaderCacheForMaterial(t);return i.has(e)===!1&&(i.add(e),e.usedTimes++),i.has(n)===!1&&(i.add(n),n.usedTimes++),this}remove(t){const e=this.materialCache.get(t);for(const n of e)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(t),this}getVertexShaderStage(t){return this._getShaderStage(t.vertexShader)}getFragmentShaderStage(t){return this._getShaderStage(t.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(t){const e=this.materialCache;let n=e.get(t);return n===void 0&&(n=new Set,e.set(t,n)),n}_getShaderStage(t){const e=this.shaderCache;let n=e.get(t);return n===void 0&&(n=new yy(t),e.set(t,n)),n}}class yy{constructor(t){this.id=_y++,this.code=t,this.usedTimes=0}}function Sy(s){return s===Cs||s===Xo||s===qo}function by(s,t,e,n,i,r){const a=new gu,o=new My,c=new Set,l=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function g(_){return c.add(_),_===0?"uv":`uv${_}`}function v(_,A,C,D,I,V){const q=D.fog,O=I.geometry,W=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?D.environment:null,G=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,Z=t.get(_.envMap||W,G),et=Z&&Z.mapping===hc?Z.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&wt("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const it=O.morphAttributes.position||O.morphAttributes.normal||O.morphAttributes.color,ut=it!==void 0?it.length:0;let Ht=0;O.morphAttributes.position!==void 0&&(Ht=1),O.morphAttributes.normal!==void 0&&(Ht=2),O.morphAttributes.color!==void 0&&(Ht=3);let Jt,kt,Y,rt;if(j){const yt=ci[j];Jt=yt.vertexShader,kt=yt.fragmentShader}else{Jt=_.vertexShader,kt=_.fragmentShader;const yt=o.getVertexShaderStage(_),Ae=o.getFragmentShaderStage(_);o.update(_,yt,Ae),Y=yt.id,rt=Ae.id}const nt=s.getRenderTarget(),z=s.state.buffers.depth.getReversed(),Et=I.isInstancedMesh===!0,It=I.isBatchedMesh===!0,Tt=!!_.map,_t=!!_.matcap,Nt=!!Z,Ot=!!_.aoMap,Ut=!!_.lightMap,ee=!!_.bumpMap&&_.wireframe===!1,ne=!!_.normalMap,Ee=!!_.displacementMap,ve=!!_.emissiveMap,we=!!_.metalnessMap,Oe=!!_.roughnessMap,N=_.anisotropy>0,gn=_.clearcoat>0,ie=_.dispersion>0,T=_.iridescence>0,x=_.sheen>0,F=_.transmission>0,H=N&&!!_.anisotropyMap,K=gn&&!!_.clearcoatMap,st=gn&&!!_.clearcoatNormalMap,ot=gn&&!!_.clearcoatRoughnessMap,$=T&&!!_.iridescenceMap,Q=T&&!!_.iridescenceThicknessMap,ct=x&&!!_.sheenColorMap,Rt=x&&!!_.sheenRoughnessMap,dt=!!_.specularMap,lt=!!_.specularColorMap,Lt=!!_.specularIntensityMap,Ft=F&&!!_.transmissionMap,Gt=F&&!!_.thicknessMap,L=!!_.gradientMap,at=!!_.alphaMap,J=_.alphaTest>0,ht=!!_.alphaHash,gt=!!_.extensions;let tt=gi;_.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(tt=s.toneMapping);const At={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:Jt,fragmentShader:kt,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:It,batchingColor:It&&I._colorsTexture!==null,instancing:Et,instancingColor:Et&&I.instanceColor!==null,instancingMorph:Et&&I.morphTexture!==null,outputColorSpace:nt===null?s.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Qt.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Tt,matcap:_t,envMap:Nt,envMapMode:Nt&&Z.mapping,envMapCubeUVHeight:et,aoMap:Ot,lightMap:Ut,bumpMap:ee,normalMap:ne,displacementMap:Ee,emissiveMap:ve,normalMapObjectSpace:ne&&_.normalMapType===d1,normalMapTangentSpace:ne&&_.normalMapType===Ko,packedNormalMap:ne&&_.normalMapType===Ko&&Sy(_.normalMap.format),metalnessMap:we,roughnessMap:Oe,anisotropy:N,anisotropyMap:H,clearcoat:gn,clearcoatMap:K,clearcoatNormalMap:st,clearcoatRoughnessMap:ot,dispersion:ie,iridescence:T,iridescenceMap:$,iridescenceThicknessMap:Q,sheen:x,sheenColorMap:ct,sheenRoughnessMap:Rt,specularMap:dt,specularColorMap:lt,specularIntensityMap:Lt,transmission:F,transmissionMap:Ft,thicknessMap:Gt,gradientMap:L,opaque:_.transparent===!1&&_.blending===mr&&_.alphaToCoverage===!1,alphaMap:at,alphaTest:J,alphaHash:ht,combine:_.combine,mapUv:Tt&&g(_.map.channel),aoMapUv:Ot&&g(_.aoMap.channel),lightMapUv:Ut&&g(_.lightMap.channel),bumpMapUv:ee&&g(_.bumpMap.channel),normalMapUv:ne&&g(_.normalMap.channel),displacementMapUv:Ee&&g(_.displacementMap.channel),emissiveMapUv:ve&&g(_.emissiveMap.channel),metalnessMapUv:we&&g(_.metalnessMap.channel),roughnessMapUv:Oe&&g(_.roughnessMap.channel),anisotropyMapUv:H&&g(_.anisotropyMap.channel),clearcoatMapUv:K&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:st&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:$&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:Rt&&g(_.sheenRoughnessMap.channel),specularMapUv:dt&&g(_.specularMap.channel),specularColorMapUv:lt&&g(_.specularColorMap.channel),specularIntensityMapUv:Lt&&g(_.specularIntensityMap.channel),transmissionMapUv:Ft&&g(_.transmissionMap.channel),thicknessMapUv:Gt&&g(_.thicknessMap.channel),alphaMapUv:at&&g(_.alphaMap.channel),vertexTangents:!!O.attributes.tangent&&(ne||N),vertexNormals:!!O.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!O.attributes.color&&O.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!O.attributes.uv&&(Tt||at),fog:!!q,useFog:_.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||O.attributes.normal===void 0&&ne===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:O.attributes.position!==void 0,morphTargets:O.morphAttributes.position!==void 0,morphNormals:O.morphAttributes.normal!==void 0,morphColors:O.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:Ht,numDirLights:A.directional.length,numPointLights:A.point.length,numSpotLights:A.spot.length,numSpotLightMaps:A.spotLightMap.length,numRectAreaLights:A.rectArea.length,numHemiLights:A.hemi.length,numDirLightShadows:A.directionalShadowMap.length,numPointLightShadows:A.pointShadowMap.length,numSpotLightShadows:A.spotShadowMap.length,numSpotLightShadowsWithMaps:A.numSpotLightShadowsWithMaps,numLightProbes:A.numLightProbes,numLightProbeGrids:V.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:s.shadowMap.enabled&&C.length>0,shadowMapType:s.shadowMap.type,toneMapping:tt,decodeVideoTexture:Tt&&_.map.isVideoTexture===!0&&Qt.getTransfer(_.map.colorSpace)===se,decodeVideoTextureEmissive:ve&&_.emissiveMap.isVideoTexture===!0&&Qt.getTransfer(_.emissiveMap.colorSpace)===se,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===qn,flipSided:_.side===Be,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:gt&&_.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&_.extensions.multiDraw===!0||It)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return At.vertexUv1s=c.has(1),At.vertexUv2s=c.has(2),At.vertexUv3s=c.has(3),c.clear(),At}function p(_){const A=[];if(_.shaderID?A.push(_.shaderID):(A.push(_.customVertexShaderID),A.push(_.customFragmentShaderID)),_.defines!==void 0)for(const C in _.defines)A.push(C),A.push(_.defines[C]);return _.isRawShaderMaterial===!1&&(m(A,_),b(A,_),A.push(s.outputColorSpace)),A.push(_.customProgramCacheKey),A.join()}function m(_,A){_.push(A.precision),_.push(A.outputColorSpace),_.push(A.envMapMode),_.push(A.envMapCubeUVHeight),_.push(A.mapUv),_.push(A.alphaMapUv),_.push(A.lightMapUv),_.push(A.aoMapUv),_.push(A.bumpMapUv),_.push(A.normalMapUv),_.push(A.displacementMapUv),_.push(A.emissiveMapUv),_.push(A.metalnessMapUv),_.push(A.roughnessMapUv),_.push(A.anisotropyMapUv),_.push(A.clearcoatMapUv),_.push(A.clearcoatNormalMapUv),_.push(A.clearcoatRoughnessMapUv),_.push(A.iridescenceMapUv),_.push(A.iridescenceThicknessMapUv),_.push(A.sheenColorMapUv),_.push(A.sheenRoughnessMapUv),_.push(A.specularMapUv),_.push(A.specularColorMapUv),_.push(A.specularIntensityMapUv),_.push(A.transmissionMapUv),_.push(A.thicknessMapUv),_.push(A.combine),_.push(A.fogExp2),_.push(A.sizeAttenuation),_.push(A.morphTargetsCount),_.push(A.morphAttributeCount),_.push(A.numDirLights),_.push(A.numPointLights),_.push(A.numSpotLights),_.push(A.numSpotLightMaps),_.push(A.numHemiLights),_.push(A.numRectAreaLights),_.push(A.numDirLightShadows),_.push(A.numPointLightShadows),_.push(A.numSpotLightShadows),_.push(A.numSpotLightShadowsWithMaps),_.push(A.numLightProbes),_.push(A.shadowMapType),_.push(A.toneMapping),_.push(A.numClippingPlanes),_.push(A.numClipIntersection),_.push(A.depthPacking)}function b(_,A){a.disableAll(),A.instancing&&a.enable(0),A.instancingColor&&a.enable(1),A.instancingMorph&&a.enable(2),A.matcap&&a.enable(3),A.envMap&&a.enable(4),A.normalMapObjectSpace&&a.enable(5),A.normalMapTangentSpace&&a.enable(6),A.clearcoat&&a.enable(7),A.iridescence&&a.enable(8),A.alphaTest&&a.enable(9),A.vertexColors&&a.enable(10),A.vertexAlphas&&a.enable(11),A.vertexUv1s&&a.enable(12),A.vertexUv2s&&a.enable(13),A.vertexUv3s&&a.enable(14),A.vertexTangents&&a.enable(15),A.anisotropy&&a.enable(16),A.alphaHash&&a.enable(17),A.batching&&a.enable(18),A.dispersion&&a.enable(19),A.batchingColor&&a.enable(20),A.gradientMap&&a.enable(21),A.packedNormalMap&&a.enable(22),A.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),A.fog&&a.enable(0),A.useFog&&a.enable(1),A.flatShading&&a.enable(2),A.logarithmicDepthBuffer&&a.enable(3),A.reversedDepthBuffer&&a.enable(4),A.skinning&&a.enable(5),A.morphTargets&&a.enable(6),A.morphNormals&&a.enable(7),A.morphColors&&a.enable(8),A.premultipliedAlpha&&a.enable(9),A.shadowMapEnabled&&a.enable(10),A.doubleSided&&a.enable(11),A.flipSided&&a.enable(12),A.useDepthPacking&&a.enable(13),A.dithering&&a.enable(14),A.transmission&&a.enable(15),A.sheen&&a.enable(16),A.opaque&&a.enable(17),A.pointsUvs&&a.enable(18),A.decodeVideoTexture&&a.enable(19),A.decodeVideoTextureEmissive&&a.enable(20),A.alphaToCoverage&&a.enable(21),A.numLightProbeGrids>0&&a.enable(22),A.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function E(_){const A=f[_.type];let C;if(A){const D=ci[A];C=x2.clone(D.uniforms)}else C=_.uniforms;return C}function M(_,A){let C=h.get(A);return C!==void 0?++C.usedTimes:(C=new xy(s,A,_,i),l.push(C),h.set(A,C)),C}function S(_){if(--_.usedTimes===0){const A=l.indexOf(_);l[A]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function w(_){o.remove(_)}function R(){o.dispose()}return{getParameters:v,getProgramCacheKey:p,getUniforms:E,acquireProgram:M,releaseProgram:S,releaseShaderCache:w,programs:l,dispose:R}}function Ey(){let s=new WeakMap;function t(a){return s.has(a)}function e(a){let o=s.get(a);return o===void 0&&(o={},s.set(a,o)),o}function n(a){s.delete(a)}function i(a,o,c){s.get(a)[o]=c}function r(){s=new WeakMap}return{has:t,get:e,remove:n,update:i,dispose:r}}function wy(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.material.id!==t.material.id?s.material.id-t.material.id:s.materialVariant!==t.materialVariant?s.materialVariant-t.materialVariant:s.z!==t.z?s.z-t.z:s.id-t.id}function C0(s,t){return s.groupOrder!==t.groupOrder?s.groupOrder-t.groupOrder:s.renderOrder!==t.renderOrder?s.renderOrder-t.renderOrder:s.z!==t.z?t.z-s.z:s.id-t.id}function P0(){const s=[];let t=0;const e=[],n=[],i=[];function r(){t=0,e.length=0,n.length=0,i.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,g,v,p,m){let b=s[t];return b===void 0?(b={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:v,renderOrder:d.renderOrder,z:p,group:m},s[t]=b):(b.id=d.id,b.object=d,b.geometry=f,b.material=g,b.materialVariant=a(d),b.groupOrder=v,b.renderOrder=d.renderOrder,b.z=p,b.group=m),t++,b}function c(d,f,g,v,p,m){const b=o(d,f,g,v,p,m);g.transmission>0?n.push(b):g.transparent===!0?i.push(b):e.push(b)}function l(d,f,g,v,p,m){const b=o(d,f,g,v,p,m);g.transmission>0?n.unshift(b):g.transparent===!0?i.unshift(b):e.unshift(b)}function h(d,f,g){e.length>1&&e.sort(d||wy),n.length>1&&n.sort(f||C0),i.length>1&&i.sort(f||C0),g&&(e.reverse(),n.reverse(),i.reverse())}function u(){for(let d=t,f=s.length;d<f;d++){const g=s[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:e,transmissive:n,transparent:i,init:r,push:c,unshift:l,finish:u,sort:h}}function Ay(){let s=new WeakMap;function t(n,i){const r=s.get(n);let a;return r===void 0?(a=new P0,s.set(n,[a])):i>=r.length?(a=new P0,r.push(a)):a=r[i],a}function e(){s=new WeakMap}return{get:t,dispose:e}}function Ty(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new P,color:new vt};break;case"SpotLight":e={position:new P,direction:new P,color:new vt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new P,color:new vt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new P,skyColor:new vt,groundColor:new vt};break;case"RectAreaLight":e={color:new vt,position:new P,halfWidth:new P,halfHeight:new P};break}return s[t.id]=e,e}}}function Ry(){const s={};return{get:function(t){if(s[t.id]!==void 0)return s[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Pt,shadowCameraNear:1,shadowCameraFar:1e3};break}return s[t.id]=e,e}}}let Dy=0;function Cy(s,t){return(t.castShadow?2:0)-(s.castShadow?2:0)+(t.map?1:0)-(s.map?1:0)}function Py(s){const t=new Ty,e=Ry(),n={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let l=0;l<9;l++)n.probe.push(new P);const i=new P,r=new Xt,a=new Xt;function o(l){let h=0,u=0,d=0;for(let A=0;A<9;A++)n.probe[A].set(0,0,0);let f=0,g=0,v=0,p=0,m=0,b=0,E=0,M=0,S=0,w=0,R=0;l.sort(Cy);for(let A=0,C=l.length;A<C;A++){const D=l[A],I=D.color,V=D.intensity,q=D.distance;let O=null;if(D.shadow&&D.shadow.map&&(D.shadow.map.texture.format===Cs?O=D.shadow.map.texture:O=D.shadow.map.depthTexture||D.shadow.map.texture),D.isAmbientLight)h+=I.r*V,u+=I.g*V,d+=I.b*V;else if(D.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(D.sh.coefficients[W],V);R++}else if(D.isDirectionalLight){const W=t.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),D.castShadow){const G=D.shadow,Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.directionalShadow[f]=Z,n.directionalShadowMap[f]=O,n.directionalShadowMatrix[f]=D.shadow.matrix,b++}n.directional[f]=W,f++}else if(D.isSpotLight){const W=t.get(D);W.position.setFromMatrixPosition(D.matrixWorld),W.color.copy(I).multiplyScalar(V),W.distance=q,W.coneCos=Math.cos(D.angle),W.penumbraCos=Math.cos(D.angle*(1-D.penumbra)),W.decay=D.decay,n.spot[v]=W;const G=D.shadow;if(D.map&&(n.spotLightMap[S]=D.map,S++,G.updateMatrices(D),D.castShadow&&w++),n.spotLightMatrix[v]=G.matrix,D.castShadow){const Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,n.spotShadow[v]=Z,n.spotShadowMap[v]=O,M++}v++}else if(D.isRectAreaLight){const W=t.get(D);W.color.copy(I).multiplyScalar(V),W.halfWidth.set(D.width*.5,0,0),W.halfHeight.set(0,D.height*.5,0),n.rectArea[p]=W,p++}else if(D.isPointLight){const W=t.get(D);if(W.color.copy(D.color).multiplyScalar(D.intensity),W.distance=D.distance,W.decay=D.decay,D.castShadow){const G=D.shadow,Z=e.get(D);Z.shadowIntensity=G.intensity,Z.shadowBias=G.bias,Z.shadowNormalBias=G.normalBias,Z.shadowRadius=G.radius,Z.shadowMapSize=G.mapSize,Z.shadowCameraNear=G.camera.near,Z.shadowCameraFar=G.camera.far,n.pointShadow[g]=Z,n.pointShadowMap[g]=O,n.pointShadowMatrix[g]=D.shadow.matrix,E++}n.point[g]=W,g++}else if(D.isHemisphereLight){const W=t.get(D);W.skyColor.copy(D.color).multiplyScalar(V),W.groundColor.copy(D.groundColor).multiplyScalar(V),n.hemi[m]=W,m++}}p>0&&(s.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=ft.LTC_FLOAT_1,n.rectAreaLTC2=ft.LTC_FLOAT_2):(n.rectAreaLTC1=ft.LTC_HALF_1,n.rectAreaLTC2=ft.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const _=n.hash;(_.directionalLength!==f||_.pointLength!==g||_.spotLength!==v||_.rectAreaLength!==p||_.hemiLength!==m||_.numDirectionalShadows!==b||_.numPointShadows!==E||_.numSpotShadows!==M||_.numSpotMaps!==S||_.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=v,n.rectArea.length=p,n.point.length=g,n.hemi.length=m,n.directionalShadow.length=b,n.directionalShadowMap.length=b,n.pointShadow.length=E,n.pointShadowMap.length=E,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=b,n.pointShadowMatrix.length=E,n.spotLightMatrix.length=M+S-w,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=w,n.numLightProbes=R,_.directionalLength=f,_.pointLength=g,_.spotLength=v,_.rectAreaLength=p,_.hemiLength=m,_.numDirectionalShadows=b,_.numPointShadows=E,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=Dy++)}function c(l,h){let u=0,d=0,f=0,g=0,v=0;const p=h.matrixWorldInverse;for(let m=0,b=l.length;m<b;m++){const E=l[m];if(E.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(p),u++}else if(E.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),M.direction.setFromMatrixPosition(E.matrixWorld),i.setFromMatrixPosition(E.target.matrixWorld),M.direction.sub(i),M.direction.transformDirection(p),f++}else if(E.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),a.identity(),r.copy(E.matrixWorld),r.premultiply(p),a.extractRotation(r),M.halfWidth.set(E.width*.5,0,0),M.halfHeight.set(0,E.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(E.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(E.matrixWorld),M.position.applyMatrix4(p),d++}else if(E.isHemisphereLight){const M=n.hemi[v];M.direction.setFromMatrixPosition(E.matrixWorld),M.direction.transformDirection(p),v++}}}return{setup:o,setupView:c,state:n}}function I0(s){const t=new Py(s),e=[],n=[],i=[];function r(d){u.camera=d,e.length=0,n.length=0,i.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){i.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:i,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function Iy(s){let t=new WeakMap;function e(i,r=0){const a=t.get(i);let o;return a===void 0?(o=new I0(s),t.set(i,[o])):r>=a.length?(o=new I0(s),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const Ly=`void main() {
|
|
4575
4575
|
gl_Position = vec4( position, 1.0 );
|
|
4576
|
-
}`,
|
|
4576
|
+
}`,Ny=`uniform sampler2D shadow_pass;
|
|
4577
4577
|
uniform vec2 resolution;
|
|
4578
4578
|
uniform float radius;
|
|
4579
4579
|
void main() {
|
|
@@ -4598,12 +4598,12 @@ void main() {
|
|
|
4598
4598
|
squared_mean = squared_mean / samples;
|
|
4599
4599
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4600
4600
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4601
|
-
}`,Ly=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],Ny=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],L0=new Xt,Yr=new P,al=new P;function Oy(s,t,e){let n=new _u;const i=new Pt,r=new Pt,a=new le,o=new y2,c=new S2,l={},h=e.maxTextureSize,u={[cs]:Be,[Be]:cs,[qn]:qn},d=new De({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pt},radius:{value:4}},vertexShader:Py,fragmentShader:Iy}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new be;g.setAttribute("position",new de(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new $t(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ra;let m=this.type;this.render=function(w,R,_){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;this.type===Bg&&(wt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ra);const A=s.getRenderTarget(),C=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),I=s.state;I.setBlending(mi),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const V=m!==this.type;V&&R.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(O=>O.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,O=w.length;q<O;q++){const W=w[q],G=W.shadow;if(G===void 0){wt("WebGLShadowMap:",W,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();i.multiply(Z),r.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Z.x),i.x=r.x*Z.x,G.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Z.y),i.y=r.y*Z.y,G.mapSize.y=r.y));const et=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=et,G.map===null||V===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===jr){if(W.isPointLight){wt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Sn(i.x,i.y,{format:Cs,type:nn,minFilter:ye,magFilter:ye,generateMipmaps:!1}),G.map.texture.name=W.name+".shadowMap",G.map.depthTexture=new Ps(i.x,i.y,zn),G.map.depthTexture.name=W.name+".shadowMapDepth",G.map.depthTexture.format=Ui,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=ke,G.map.depthTexture.magFilter=ke}else W.isPointLight?(G.map=new zp(i.x),G.map.depthTexture=new p2(i.x,Jn)):(G.map=new Sn(i.x,i.y),G.map.depthTexture=new Ps(i.x,i.y,Jn)),G.map.depthTexture.name=W.name+".shadowMap",G.map.depthTexture.format=Ui,this.type===ra?(G.map.depthTexture.compareFunction=et?fu:du,G.map.depthTexture.minFilter=ye,G.map.depthTexture.magFilter=ye):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=ke,G.map.depthTexture.magFilter=ke);G.camera.updateProjectionMatrix()}const j=G.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<j;it++){if(G.map.isWebGLCubeRenderTarget)s.setRenderTarget(G.map,it),s.clear();else{it===0&&(s.setRenderTarget(G.map),s.clear());const ut=G.getViewport(it);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),I.viewport(a)}if(W.isPointLight){const ut=G.camera,Ht=G.matrix,Jt=W.distance||ut.far;Jt!==ut.far&&(ut.far=Jt,ut.updateProjectionMatrix()),Yr.setFromMatrixPosition(W.matrixWorld),ut.position.copy(Yr),al.copy(ut.position),al.add(Ly[it]),ut.up.copy(Ny[it]),ut.lookAt(al),ut.updateMatrixWorld(),Ht.makeTranslation(-Yr.x,-Yr.y,-Yr.z),L0.multiplyMatrices(ut.projectionMatrix,ut.matrixWorldInverse),G._frustum.setFromProjectionMatrix(L0,ut.coordinateSystem,ut.reversedDepth)}else G.updateMatrices(W);n=G.getFrustum(),M(R,_,G.camera,W,this.type)}G.isPointLightShadow!==!0&&this.type===jr&&b(G,_),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,s.setRenderTarget(A,C,D)};function b(w,R){const _=t.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Sn(i.x,i.y,{format:Cs,type:nn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,_,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,_,f,v,null)}function E(w,R,_,A){let C=null;const D=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)C=D;else if(C=_.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const I=C.uuid,V=R.uuid;let q=l[I];q===void 0&&(q={},l[I]=q);let O=q[V];O===void 0&&(O=C.clone(),q[V]=O,R.addEventListener("dispose",S)),C=O}if(C.visible=R.visible,C.wireframe=R.wireframe,A===jr?C.side=R.shadowSide!==null?R.shadowSide:R.side:C.side=R.shadowSide!==null?R.shadowSide:u[R.side],C.alphaMap=R.alphaMap,C.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,C.map=R.map,C.clipShadows=R.clipShadows,C.clippingPlanes=R.clippingPlanes,C.clipIntersection=R.clipIntersection,C.displacementMap=R.displacementMap,C.displacementScale=R.displacementScale,C.displacementBias=R.displacementBias,C.wireframeLinewidth=R.wireframeLinewidth,C.linewidth=R.linewidth,_.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const I=s.properties.get(C);I.light=_}return C}function M(w,R,_,A,C){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&C===jr)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);const V=t.update(w),q=w.material;if(Array.isArray(q)){const O=V.groups;for(let W=0,G=O.length;W<G;W++){const Z=O[W],et=q[Z.materialIndex];if(et&&et.visible){const j=E(w,et,A,C);w.onBeforeShadow(s,w,R,_,V,j,Z),s.renderBufferDirect(_,null,V,j,w,Z),w.onAfterShadow(s,w,R,_,V,j,Z)}}}else if(q.visible){const O=E(w,q,A,C);w.onBeforeShadow(s,w,R,_,V,O,null),s.renderBufferDirect(_,null,V,O,w,null),w.onAfterShadow(s,w,R,_,V,O,null)}}const I=w.children;for(let V=0,q=I.length;V<q;V++)M(I[V],R,_,A,C)}function S(w){w.target.removeEventListener("dispose",S);for(const _ in l){const A=l[_],C=w.target.uuid;C in A&&(A[C].dispose(),delete A[C])}}}function Uy(s,t){function e(){let L=!1;const at=new le;let J=null;const ht=new le(0,0,0,0);return{setMask:function(gt){J!==gt&&!L&&(s.colorMask(gt,gt,gt,gt),J=gt)},setLocked:function(gt){L=gt},setClear:function(gt,tt,At,yt,Ae){Ae===!0&&(gt*=yt,tt*=yt,At*=yt),at.set(gt,tt,At,yt),ht.equals(at)===!1&&(s.clearColor(gt,tt,At,yt),ht.copy(at))},reset:function(){L=!1,J=null,ht.set(-1,0,0,0)}}}function n(){let L=!1,at=!1,J=null,ht=null,gt=null;return{setReversed:function(tt){if(at!==tt){const At=t.get("EXT_clip_control");tt?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),at=tt;const yt=gt;gt=null,this.setClear(yt)}},getReversed:function(){return at},setTest:function(tt){tt?nt(s.DEPTH_TEST):z(s.DEPTH_TEST)},setMask:function(tt){J!==tt&&!L&&(s.depthMask(tt),J=tt)},setFunc:function(tt){if(at&&(tt=y1[tt]),ht!==tt){switch(tt){case kl:s.depthFunc(s.NEVER);break;case Hl:s.depthFunc(s.ALWAYS);break;case Gl:s.depthFunc(s.LESS);break;case br:s.depthFunc(s.LEQUAL);break;case Vl:s.depthFunc(s.EQUAL);break;case Wl:s.depthFunc(s.GEQUAL);break;case Xl:s.depthFunc(s.GREATER);break;case ql:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}ht=tt}},setLocked:function(tt){L=tt},setClear:function(tt){gt!==tt&&(gt=tt,at&&(tt=1-tt),s.clearDepth(tt))},reset:function(){L=!1,J=null,ht=null,gt=null,at=!1}}}function i(){let L=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,yt=null,Ae=null;return{setTest:function(fe){L||(fe?nt(s.STENCIL_TEST):z(s.STENCIL_TEST))},setMask:function(fe){at!==fe&&!L&&(s.stencilMask(fe),at=fe)},setFunc:function(fe,jn,ti){(J!==fe||ht!==jn||gt!==ti)&&(s.stencilFunc(fe,jn,ti),J=fe,ht=jn,gt=ti)},setOp:function(fe,jn,ti){(tt!==fe||At!==jn||yt!==ti)&&(s.stencilOp(fe,jn,ti),tt=fe,At=jn,yt=ti)},setLocked:function(fe){L=fe},setClear:function(fe){Ae!==fe&&(s.clearStencil(fe),Ae=fe)},reset:function(){L=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,yt=null,Ae=null}}}const r=new e,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],v=null,p=!1,m=null,b=null,E=null,M=null,S=null,w=null,R=null,_=new vt(0,0,0),A=0,C=!1,D=null,I=null,V=null,q=null,O=null;const W=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,Z=0;const et=s.getParameter(s.VERSION);et.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(et)[1]),G=Z>=1):et.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),G=Z>=2);let j=null,it={};const ut=s.getParameter(s.SCISSOR_BOX),Ht=s.getParameter(s.VIEWPORT),Jt=new le().fromArray(ut),kt=new le().fromArray(Ht);function Y(L,at,J,ht){const gt=new Uint8Array(4),tt=s.createTexture();s.bindTexture(L,tt),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let At=0;At<J;At++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(at,0,s.RGBA,1,1,ht,0,s.RGBA,s.UNSIGNED_BYTE,gt):s.texImage2D(at+At,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,gt);return tt}const rt={};rt[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),rt[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),rt[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(s.DEPTH_TEST),a.setFunc(br),ee(!1),ne(fd),nt(s.CULL_FACE),Ot(mi);function nt(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function z(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Et(L,at){return d[L]!==at?(s.bindFramebuffer(L,at),d[L]=at,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=at),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=at),!0):!1}function It(L,at){let J=g,ht=!1;if(L){J=f.get(at),J===void 0&&(J=[],f.set(at,J));const gt=L.textures;if(J.length!==gt.length||J[0]!==s.COLOR_ATTACHMENT0){for(let tt=0,At=gt.length;tt<At;tt++)J[tt]=s.COLOR_ATTACHMENT0+tt;J.length=gt.length,ht=!0}}else J[0]!==s.BACK&&(J[0]=s.BACK,ht=!0);ht&&s.drawBuffers(J)}function Tt(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const _t={[ys]:s.FUNC_ADD,[Hg]:s.FUNC_SUBTRACT,[Gg]:s.FUNC_REVERSE_SUBTRACT};_t[Vg]=s.MIN,_t[Wg]=s.MAX;const Nt={[Xg]:s.ZERO,[qg]:s.ONE,[Yg]:s.SRC_COLOR,[zl]:s.SRC_ALPHA,[jg]:s.SRC_ALPHA_SATURATE,[Jg]:s.DST_COLOR,[$g]:s.DST_ALPHA,[Kg]:s.ONE_MINUS_SRC_COLOR,[Bl]:s.ONE_MINUS_SRC_ALPHA,[Qg]:s.ONE_MINUS_DST_COLOR,[Zg]:s.ONE_MINUS_DST_ALPHA,[t1]:s.CONSTANT_COLOR,[e1]:s.ONE_MINUS_CONSTANT_COLOR,[n1]:s.CONSTANT_ALPHA,[i1]:s.ONE_MINUS_CONSTANT_ALPHA};function Ot(L,at,J,ht,gt,tt,At,yt,Ae,fe){if(L===mi){p===!0&&(z(s.BLEND),p=!1);return}if(p===!1&&(nt(s.BLEND),p=!0),L!==kg){if(L!==m||fe!==C){if((b!==ys||S!==ys)&&(s.blendEquation(s.FUNC_ADD),b=ys,S=ys),fe)switch(L){case mr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Zn:s.blendFunc(s.ONE,s.ONE);break;case pd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case md:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:zt("WebGLState: Invalid blending: ",L);break}else switch(L){case mr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Zn:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case pd:zt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case md:zt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zt("WebGLState: Invalid blending: ",L);break}E=null,M=null,w=null,R=null,_.set(0,0,0),A=0,m=L,C=fe}return}gt=gt||at,tt=tt||J,At=At||ht,(at!==b||gt!==S)&&(s.blendEquationSeparate(_t[at],_t[gt]),b=at,S=gt),(J!==E||ht!==M||tt!==w||At!==R)&&(s.blendFuncSeparate(Nt[J],Nt[ht],Nt[tt],Nt[At]),E=J,M=ht,w=tt,R=At),(yt.equals(_)===!1||Ae!==A)&&(s.blendColor(yt.r,yt.g,yt.b,Ae),_.copy(yt),A=Ae),m=L,C=!1}function Ut(L,at){L.side===qn?z(s.CULL_FACE):nt(s.CULL_FACE);let J=L.side===Be;at&&(J=!J),ee(J),L.blending===mr&&L.transparent===!1?Ot(mi):Ot(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const ht=L.stencilWrite;o.setTest(ht),ht&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ve(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?nt(s.SAMPLE_ALPHA_TO_COVERAGE):z(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ne(L){L!==Fg?(nt(s.CULL_FACE),L!==I&&(L===fd?s.cullFace(s.BACK):L===zg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):z(s.CULL_FACE),I=L}function Ee(L){L!==V&&(G&&s.lineWidth(L),V=L)}function ve(L,at,J){L?(nt(s.POLYGON_OFFSET_FILL),(q!==at||O!==J)&&(q=at,O=J,a.getReversed()&&(at=-at),s.polygonOffset(at,J))):z(s.POLYGON_OFFSET_FILL)}function we(L){L?nt(s.SCISSOR_TEST):z(s.SCISSOR_TEST)}function Ne(L){L===void 0&&(L=s.TEXTURE0+W-1),j!==L&&(s.activeTexture(L),j=L)}function N(L,at,J){J===void 0&&(j===null?J=s.TEXTURE0+W-1:J=j);let ht=it[J];ht===void 0&&(ht={type:void 0,texture:void 0},it[J]=ht),(ht.type!==L||ht.texture!==at)&&(j!==J&&(s.activeTexture(J),j=J),s.bindTexture(L,at||rt[L]),ht.type=L,ht.texture=at)}function gn(){const L=it[j];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ie(){try{s.compressedTexImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function F(){try{s.texSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function H(){try{s.compressedTexSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function K(){try{s.compressedTexSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function st(){try{s.texStorage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function ot(){try{s.texStorage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function $(){try{s.texImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function ct(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function Rt(L,at){u[L]!==at&&(s.pixelStorei(L,at),u[L]=at)}function dt(L){Jt.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),Jt.copy(L))}function lt(L){kt.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),kt.copy(L))}function Lt(L,at){let J=l.get(at);J===void 0&&(J=new WeakMap,l.set(at,J));let ht=J.get(L);ht===void 0&&(ht=s.getUniformBlockIndex(at,L.name),J.set(L,ht))}function Ft(L,at){const ht=l.get(at).get(L);c.get(at)!==ht&&(s.uniformBlockBinding(at,ht,L.__bindingPointIndex),c.set(at,ht))}function Gt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},j=null,it={},d={},f=new WeakMap,g=[],v=null,p=!1,m=null,b=null,E=null,M=null,S=null,w=null,R=null,_=new vt(0,0,0),A=0,C=!1,D=null,I=null,V=null,q=null,O=null,Jt.set(0,0,s.canvas.width,s.canvas.height),kt.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:Et,drawBuffers:It,useProgram:Tt,setBlending:Ot,setMaterial:Ut,setFlipSided:ee,setCullFace:ne,setLineWidth:Ee,setPolygonOffset:ve,setScissorTest:we,activeTexture:Ne,bindTexture:N,unbindTexture:gn,compressedTexImage2D:ie,compressedTexImage3D:T,texImage2D:$,texImage3D:Q,pixelStorei:Rt,getParameter:ct,updateUBOMapping:Lt,uniformBlockBinding:Ft,texStorage2D:st,texStorage3D:ot,texSubImage2D:x,texSubImage3D:F,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:dt,viewport:lt,reset:Gt}}function Fy(s,t,e,n,i,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Pt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,x){return g?new OffscreenCanvas(T,x):_a("canvas")}function p(T,x,F){let H=1;const K=ie(T);if((K.width>F||K.height>F)&&(H=F/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const st=Math.floor(H*K.width),ot=Math.floor(H*K.height);d===void 0&&(d=v(st,ot));const $=x?v(st,ot):d;return $.width=st,$.height=ot,$.getContext("2d").drawImage(T,0,0,st,ot),wt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+st+"x"+ot+")."),$}else return"data"in T&&wt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function m(T){return T.generateMipmaps}function b(T){s.generateMipmap(T)}function E(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function M(T,x,F,H,K,st=!1){if(T!==null){if(s[T]!==void 0)return s[T];wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ot;H&&(ot=t.get("EXT_texture_norm16"),ot||wt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=x;if(x===s.RED&&(F===s.FLOAT&&($=s.R32F),F===s.HALF_FLOAT&&($=s.R16F),F===s.UNSIGNED_BYTE&&($=s.R8),F===s.UNSIGNED_SHORT&&ot&&($=ot.R16_EXT),F===s.SHORT&&ot&&($=ot.R16_SNORM_EXT)),x===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.R8UI),F===s.UNSIGNED_SHORT&&($=s.R16UI),F===s.UNSIGNED_INT&&($=s.R32UI),F===s.BYTE&&($=s.R8I),F===s.SHORT&&($=s.R16I),F===s.INT&&($=s.R32I)),x===s.RG&&(F===s.FLOAT&&($=s.RG32F),F===s.HALF_FLOAT&&($=s.RG16F),F===s.UNSIGNED_BYTE&&($=s.RG8),F===s.UNSIGNED_SHORT&&ot&&($=ot.RG16_EXT),F===s.SHORT&&ot&&($=ot.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RG8UI),F===s.UNSIGNED_SHORT&&($=s.RG16UI),F===s.UNSIGNED_INT&&($=s.RG32UI),F===s.BYTE&&($=s.RG8I),F===s.SHORT&&($=s.RG16I),F===s.INT&&($=s.RG32I)),x===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGB8UI),F===s.UNSIGNED_SHORT&&($=s.RGB16UI),F===s.UNSIGNED_INT&&($=s.RGB32UI),F===s.BYTE&&($=s.RGB8I),F===s.SHORT&&($=s.RGB16I),F===s.INT&&($=s.RGB32I)),x===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGBA8UI),F===s.UNSIGNED_SHORT&&($=s.RGBA16UI),F===s.UNSIGNED_INT&&($=s.RGBA32UI),F===s.BYTE&&($=s.RGBA8I),F===s.SHORT&&($=s.RGBA16I),F===s.INT&&($=s.RGBA32I)),x===s.RGB&&(F===s.UNSIGNED_SHORT&&ot&&($=ot.RGB16_EXT),F===s.SHORT&&ot&&($=ot.RGB16_SNORM_EXT),F===s.UNSIGNED_INT_5_9_9_9_REV&&($=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&($=s.R11F_G11F_B10F)),x===s.RGBA){const Q=st?Zo:Qt.getTransfer(K);F===s.FLOAT&&($=s.RGBA32F),F===s.HALF_FLOAT&&($=s.RGBA16F),F===s.UNSIGNED_BYTE&&($=Q===se?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT&&ot&&($=ot.RGBA16_EXT),F===s.SHORT&&ot&&($=ot.RGBA16_SNORM_EXT),F===s.UNSIGNED_SHORT_4_4_4_4&&($=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&($=s.RGB5_A1)}return($===s.R16F||$===s.R32F||$===s.RG16F||$===s.RG32F||$===s.RGBA16F||$===s.RGBA32F)&&t.get("EXT_color_buffer_float"),$}function S(T,x){let F;return T?x===null||x===Jn||x===va?F=s.DEPTH24_STENCIL8:x===zn?F=s.DEPTH32F_STENCIL8:x===ga&&(F=s.DEPTH24_STENCIL8,wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Jn||x===va?F=s.DEPTH_COMPONENT24:x===zn?F=s.DEPTH_COMPONENT32F:x===ga&&(F=s.DEPTH_COMPONENT16),F}function w(T,x){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==ke&&T.minFilter!==ye?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function _(T){const x=T.target;x.removeEventListener("dispose",_),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const F=T.source,H=f.get(F);if(H){const K=H[x.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(T),Object.keys(H).length===0&&f.delete(F)}n.remove(T)}function C(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const F=T.source,H=f.get(F);delete H[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let K=0;K<x.__webglFramebuffer[H].length;K++)s.deleteFramebuffer(x.__webglFramebuffer[H][K]);else s.deleteFramebuffer(x.__webglFramebuffer[H]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[H])}else{if(Array.isArray(x.__webglFramebuffer))for(let H=0;H<x.__webglFramebuffer.length;H++)s.deleteFramebuffer(x.__webglFramebuffer[H]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let H=0;H<x.__webglColorRenderbuffer.length;H++)x.__webglColorRenderbuffer[H]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[H]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const F=T.textures;for(let H=0,K=F.length;H<K;H++){const st=n.get(F[H]);st.__webglTexture&&(s.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(F[H])}n.remove(T)}let I=0;function V(){I=0}function q(){return I}function O(T){I=T}function W(){const T=I;return T>=i.maxTextures&&wt("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),I+=1,T}function G(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Z(T,x){const F=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const H=T.image;if(H===null)wt("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)wt("WebGLRenderer: Texture marked for update but image is incomplete");else{z(F,T,x);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+x)}function et(T,x){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,x);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+x)}function j(T,x){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,x);return}e.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+x)}function it(T,x){const F=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){Et(F,T,x);return}e.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+x)}const ut={[Wo]:s.REPEAT,[dn]:s.CLAMP_TO_EDGE,[Yl]:s.MIRRORED_REPEAT},Ht={[ke]:s.NEAREST,[o1]:s.NEAREST_MIPMAP_NEAREST,[Ua]:s.NEAREST_MIPMAP_LINEAR,[ye]:s.LINEAR,[Ec]:s.LINEAR_MIPMAP_NEAREST,[ws]:s.LINEAR_MIPMAP_LINEAR},Jt={[u1]:s.NEVER,[g1]:s.ALWAYS,[d1]:s.LESS,[du]:s.LEQUAL,[f1]:s.EQUAL,[fu]:s.GEQUAL,[p1]:s.GREATER,[m1]:s.NOTEQUAL};function kt(T,x){if(x.type===zn&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===ye||x.magFilter===Ec||x.magFilter===Ua||x.magFilter===ws||x.minFilter===ye||x.minFilter===Ec||x.minFilter===Ua||x.minFilter===ws)&&wt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ut[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ut[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ut[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ht[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ht[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,Jt[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===ke||x.minFilter!==Ua&&x.minFilter!==ws||x.type===zn&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");s.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function Y(T,x){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const H=x.source;let K=f.get(H);K===void 0&&(K={},f.set(H,K));const st=G(x);if(st!==T.__cacheKey){K[st]===void 0&&(K[st]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[st].usedTimes++;const ot=K[T.__cacheKey];ot!==void 0&&(K[T.__cacheKey].usedTimes--,ot.usedTimes===0&&C(x)),T.__cacheKey=st,T.__webglTexture=K[st].texture}return F}function rt(T,x,F){return Math.floor(Math.floor(T/F)/x)}function nt(T,x,F,H){const st=T.updateRanges;if(st.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,F,H,x.data);else{st.sort((Rt,dt)=>Rt.start-dt.start);let ot=0;for(let Rt=1;Rt<st.length;Rt++){const dt=st[ot],lt=st[Rt],Lt=dt.start+dt.count,Ft=rt(lt.start,x.width,4),Gt=rt(dt.start,x.width,4);lt.start<=Lt+1&&Ft===Gt&&rt(lt.start+lt.count-1,x.width,4)===Ft?dt.count=Math.max(dt.count,lt.start+lt.count-dt.start):(++ot,st[ot]=lt)}st.length=ot+1;const $=e.getParameter(s.UNPACK_ROW_LENGTH),Q=e.getParameter(s.UNPACK_SKIP_PIXELS),ct=e.getParameter(s.UNPACK_SKIP_ROWS);e.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let Rt=0,dt=st.length;Rt<dt;Rt++){const lt=st[Rt],Lt=Math.floor(lt.start/4),Ft=Math.ceil(lt.count/4),Gt=Lt%x.width,L=Math.floor(Lt/x.width),at=Ft,J=1;e.pixelStorei(s.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(s.UNPACK_SKIP_ROWS,L),e.texSubImage2D(s.TEXTURE_2D,0,Gt,L,at,J,F,H,x.data)}T.clearUpdateRanges(),e.pixelStorei(s.UNPACK_ROW_LENGTH,$),e.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(s.UNPACK_SKIP_ROWS,ct)}}function z(T,x,F){let H=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(H=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(H=s.TEXTURE_3D);const K=Y(T,x),st=x.source;e.bindTexture(H,T.__webglTexture,s.TEXTURE0+F);const ot=n.get(st);if(st.version!==ot.__version||K===!0){if(e.activeTexture(s.TEXTURE0+F),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const J=Qt.getPrimaries(Qt.workingColorSpace),ht=x.colorSpace===is?null:Qt.getPrimaries(x.colorSpace),gt=x.colorSpace===is||J===ht?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt)}e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=p(x.image,!1,i.maxTextureSize);Q=gn(x,Q);const ct=r.convert(x.format,x.colorSpace),Rt=r.convert(x.type);let dt=M(x.internalFormat,ct,Rt,x.normalized,x.colorSpace,x.isVideoTexture);kt(H,x);let lt;const Lt=x.mipmaps,Ft=x.isVideoTexture!==!0,Gt=ot.__version===void 0||K===!0,L=st.dataReady,at=w(x,Q);if(x.isDepthTexture)dt=S(x.format===As,x.type),Gt&&(Ft?e.texStorage2D(s.TEXTURE_2D,1,dt,Q.width,Q.height):e.texImage2D(s.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Rt,null));else if(x.isDataTexture)if(Lt.length>0){Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Lt[0].width,Lt[0].height);for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Rt,lt.data):e.texImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Rt,lt.data);x.generateMipmaps=!1}else Ft?(Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Q.width,Q.height),L&&nt(x,Q,ct,Rt)):e.texImage2D(s.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Rt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Ft&&Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,at,dt,Lt[0].width,Lt[0].height,Q.depth);for(let J=0,ht=Lt.length;J<ht;J++)if(lt=Lt[J],x.format!==fn)if(ct!==null)if(Ft){if(L)if(x.layerUpdates.size>0){const gt=h0(lt.width,lt.height,x.format,x.type);for(const tt of x.layerUpdates){const At=lt.data.subarray(tt*gt/lt.data.BYTES_PER_ELEMENT,(tt+1)*gt/lt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,tt,lt.width,lt.height,1,ct,At)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,lt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,lt.data,0,0);else wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ft?L&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,Rt,lt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,ct,Rt,lt.data)}else{Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Lt[0].width,Lt[0].height);for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],x.format!==fn?ct!==null?Ft?L&&e.compressedTexSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,lt.data):e.compressedTexImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,lt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Rt,lt.data):e.texImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Rt,lt.data)}else if(x.isDataArrayTexture)if(Ft){if(Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,at,dt,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const J=h0(Q.width,Q.height,x.format,x.type);for(const ht of x.layerUpdates){const gt=Q.data.subarray(ht*J/Q.data.BYTES_PER_ELEMENT,(ht+1)*J/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ht,Q.width,Q.height,1,ct,Rt,gt)}x.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ct,Rt,Q.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,dt,Q.width,Q.height,Q.depth,0,ct,Rt,Q.data);else if(x.isData3DTexture)Ft?(Gt&&e.texStorage3D(s.TEXTURE_3D,at,dt,Q.width,Q.height,Q.depth),L&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ct,Rt,Q.data)):e.texImage3D(s.TEXTURE_3D,0,dt,Q.width,Q.height,Q.depth,0,ct,Rt,Q.data);else if(x.isFramebufferTexture){if(Gt)if(Ft)e.texStorage2D(s.TEXTURE_2D,at,dt,Q.width,Q.height);else{let J=Q.width,ht=Q.height;for(let gt=0;gt<at;gt++)e.texImage2D(s.TEXTURE_2D,gt,dt,J,ht,0,ct,Rt,null),J>>=1,ht>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in s){const J=s.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),u.add(x),J.onpaint=ht=>{const gt=ht.changedElements;for(const tt of u)gt.includes(tt.image)&&(tt.needsUpdate=!0)},J.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const gt=s.RGBA,tt=s.RGBA,At=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,gt,tt,At,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Lt.length>0){if(Ft&&Gt){const J=ie(Lt[0]);e.texStorage2D(s.TEXTURE_2D,at,dt,J.width,J.height)}for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,ct,Rt,lt):e.texImage2D(s.TEXTURE_2D,J,dt,ct,Rt,lt);x.generateMipmaps=!1}else if(Ft){if(Gt){const J=ie(Q);e.texStorage2D(s.TEXTURE_2D,at,dt,J.width,J.height)}L&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,ct,Rt,Q)}else e.texImage2D(s.TEXTURE_2D,0,dt,ct,Rt,Q);m(x)&&b(H),ot.__version=st.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Et(T,x,F){if(x.image.length!==6)return;const H=Y(T,x),K=x.source;e.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+F);const st=n.get(K);if(K.version!==st.__version||H===!0){e.activeTexture(s.TEXTURE0+F);const ot=Qt.getPrimaries(Qt.workingColorSpace),$=x.colorSpace===is?null:Qt.getPrimaries(x.colorSpace),Q=x.colorSpace===is||ot===$?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ct=x.isCompressedTexture||x.image[0].isCompressedTexture,Rt=x.image[0]&&x.image[0].isDataTexture,dt=[];for(let tt=0;tt<6;tt++)!ct&&!Rt?dt[tt]=p(x.image[tt],!0,i.maxCubemapSize):dt[tt]=Rt?x.image[tt].image:x.image[tt],dt[tt]=gn(x,dt[tt]);const lt=dt[0],Lt=r.convert(x.format,x.colorSpace),Ft=r.convert(x.type),Gt=M(x.internalFormat,Lt,Ft,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,at=st.__version===void 0||H===!0,J=K.dataReady;let ht=w(x,lt);kt(s.TEXTURE_CUBE_MAP,x);let gt;if(ct){L&&at&&e.texStorage2D(s.TEXTURE_CUBE_MAP,ht,Gt,lt.width,lt.height);for(let tt=0;tt<6;tt++){gt=dt[tt].mipmaps;for(let At=0;At<gt.length;At++){const yt=gt[At];x.format!==fn?Lt!==null?L?J&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,yt.width,yt.height,Lt,yt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,yt.width,yt.height,0,yt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,yt.width,yt.height,Lt,Ft,yt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,yt.width,yt.height,0,Lt,Ft,yt.data)}}}else{if(gt=x.mipmaps,L&&at){gt.length>0&&ht++;const tt=ie(dt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,ht,Gt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(Rt){L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,dt[tt].width,dt[tt].height,Lt,Ft,dt[tt].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,dt[tt].width,dt[tt].height,0,Lt,Ft,dt[tt].data);for(let At=0;At<gt.length;At++){const Ae=gt[At].image[tt].image;L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Ae.width,Ae.height,Lt,Ft,Ae.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Ae.width,Ae.height,0,Lt,Ft,Ae.data)}}else{L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Lt,Ft,dt[tt]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,Lt,Ft,dt[tt]);for(let At=0;At<gt.length;At++){const yt=gt[At];L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Lt,Ft,yt.image[tt]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Lt,Ft,yt.image[tt])}}}m(x)&&b(s.TEXTURE_CUBE_MAP),st.__version=K.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function It(T,x,F,H,K,st){const ot=r.convert(F.format,F.colorSpace),$=r.convert(F.type),Q=M(F.internalFormat,ot,$,F.normalized,F.colorSpace),ct=n.get(x),Rt=n.get(F);if(Rt.__renderTarget=x,!ct.__hasExternalTextures){const dt=Math.max(1,x.width>>st),lt=Math.max(1,x.height>>st);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?e.texImage3D(K,st,Q,dt,lt,x.depth,0,ot,$,null):e.texImage2D(K,st,Q,dt,lt,0,ot,$,null)}e.bindFramebuffer(s.FRAMEBUFFER,T),Ne(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,H,K,Rt.__webglTexture,0,we(x)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,H,K,Rt.__webglTexture,st),e.bindFramebuffer(s.FRAMEBUFFER,null)}function Tt(T,x,F){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const H=x.depthTexture,K=H&&H.isDepthTexture?H.type:null,st=S(x.stencilBuffer,K),ot=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Ne(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,we(x),st,x.width,x.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,we(x),st,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,st,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ot,s.RENDERBUFFER,T)}else{const H=x.textures;for(let K=0;K<H.length;K++){const st=H[K],ot=r.convert(st.format,st.colorSpace),$=r.convert(st.type),Q=M(st.internalFormat,ot,$,st.normalized,st.colorSpace);Ne(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,we(x),Q,x.width,x.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,we(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function _t(T,x,F){const H=x.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(x.depthTexture);if(K.__renderTarget=x,(!K.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),H){if(K.__webglInit===void 0&&(K.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=s.createTexture(),e.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),kt(s.TEXTURE_CUBE_MAP,x.depthTexture);const ct=r.convert(x.depthTexture.format),Rt=r.convert(x.depthTexture.type);let dt;x.depthTexture.format===Ui?dt=s.DEPTH_COMPONENT24:x.depthTexture.format===As&&(dt=s.DEPTH24_STENCIL8);for(let lt=0;lt<6;lt++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,dt,x.width,x.height,0,ct,Rt,null)}}else Z(x.depthTexture,0);const st=K.__webglTexture,ot=we(x),$=H?s.TEXTURE_CUBE_MAP_POSITIVE_X+F:s.TEXTURE_2D,Q=x.depthTexture.format===As?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===Ui)Ne(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,$,st,0,ot):s.framebufferTexture2D(s.FRAMEBUFFER,Q,$,st,0);else if(x.depthTexture.format===As)Ne(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,$,st,0,ot):s.framebufferTexture2D(s.FRAMEBUFFER,Q,$,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Nt(T){const x=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const H=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),H){const K=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),x.__depthDisposeCallback=K}x.__boundDepthTexture=H}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(F)for(let H=0;H<6;H++)_t(x.__webglFramebuffer[H],T,H);else{const H=T.texture.mipmaps;H&&H.length>0?_t(x.__webglFramebuffer[0],T,0):_t(x.__webglFramebuffer,T,0)}else if(F){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=s.createRenderbuffer(),Tt(x.__webglDepthbuffer[H],T,!1);else{const K=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer[H];s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,st)}}else{const H=T.texture.mipmaps;if(H&&H.length>0?e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Tt(x.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,st)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Ot(T,x,F){const H=n.get(T);x!==void 0&&It(H.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Nt(T)}function Ut(T){const x=T.texture,F=n.get(T),H=n.get(x);T.addEventListener("dispose",_);const K=T.textures,st=T.isWebGLCubeRenderTarget===!0,ot=K.length>1;if(ot||(H.__webglTexture===void 0&&(H.__webglTexture=s.createTexture()),H.__version=x.version,a.memory.textures++),st){F.__webglFramebuffer=[];for(let $=0;$<6;$++)if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer[$]=[];for(let Q=0;Q<x.mipmaps.length;Q++)F.__webglFramebuffer[$][Q]=s.createFramebuffer()}else F.__webglFramebuffer[$]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer=[];for(let $=0;$<x.mipmaps.length;$++)F.__webglFramebuffer[$]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(ot)for(let $=0,Q=K.length;$<Q;$++){const ct=n.get(K[$]);ct.__webglTexture===void 0&&(ct.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Ne(T)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const Q=K[$];F.__webglColorRenderbuffer[$]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[$]);const ct=r.convert(Q.format,Q.colorSpace),Rt=r.convert(Q.type),dt=M(Q.internalFormat,ct,Rt,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),lt=we(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,lt,dt,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+$,s.RENDERBUFFER,F.__webglColorRenderbuffer[$])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Tt(F.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(st){e.bindTexture(s.TEXTURE_CUBE_MAP,H.__webglTexture),kt(s.TEXTURE_CUBE_MAP,x);for(let $=0;$<6;$++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(F.__webglFramebuffer[$][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,Q);else It(F.__webglFramebuffer[$],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);m(x)&&b(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let $=0,Q=K.length;$<Q;$++){const ct=K[$],Rt=n.get(ct);let dt=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(dt=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(dt,Rt.__webglTexture),kt(dt,ct),It(F.__webglFramebuffer,T,ct,s.COLOR_ATTACHMENT0+$,dt,0),m(ct)&&b(dt)}e.unbindTexture()}else{let $=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&($=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture($,H.__webglTexture),kt($,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(F.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,$,Q);else It(F.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,$,0);m(x)&&b($),e.unbindTexture()}T.depthBuffer&&Nt(T)}function ee(T){const x=T.textures;for(let F=0,H=x.length;F<H;F++){const K=x[F];if(m(K)){const st=E(T),ot=n.get(K).__webglTexture;e.bindTexture(st,ot),b(st),e.unbindTexture()}}}const ne=[],Ee=[];function ve(T){if(T.samples>0){if(Ne(T)===!1){const x=T.textures,F=T.width,H=T.height;let K=s.COLOR_BUFFER_BIT;const st=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ot=n.get(T),$=x.length>1;if($)for(let ct=0;ct<x.length;ct++)e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ct=0;ct<x.length;ct++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),$){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Rt=n.get(x[ct]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Rt,0)}s.blitFramebuffer(0,0,F,H,0,0,F,H,K,s.NEAREST),c===!0&&(ne.length=0,Ee.length=0,ne.push(s.COLOR_ATTACHMENT0+ct),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ne.push(st),Ee.push(st),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ee)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ne))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),$)for(let ct=0;ct<x.length;ct++){e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Rt=n.get(x[ct]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.TEXTURE_2D,Rt,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function we(T){return Math.min(i.maxSamples,T.samples)}function Ne(T){const x=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function gn(T,x){const F=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==$o&&F!==is&&(Qt.getTransfer(F)===se?(H!==fn||K!==Dn)&&wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zt("WebGLTextures: Unsupported texture color space:",F)),x}function ie(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=W,this.resetTextureUnits=V,this.getTextureUnits=q,this.setTextureUnits=O,this.setTexture2D=Z,this.setTexture2DArray=et,this.setTexture3D=j,this.setTextureCube=it,this.rebindTextures=Ot,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ve,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=It,this.useMultisampledRTT=Ne,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function zy(s,t){function e(n,i=is){let r;const a=Qt.getTransfer(i);if(n===Dn)return s.UNSIGNED_BYTE;if(n===au)return s.UNSIGNED_SHORT_4_4_4_4;if(n===ou)return s.UNSIGNED_SHORT_5_5_5_1;if(n===vp)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===xp)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===mp)return s.BYTE;if(n===gp)return s.SHORT;if(n===ga)return s.UNSIGNED_SHORT;if(n===ru)return s.INT;if(n===Jn)return s.UNSIGNED_INT;if(n===zn)return s.FLOAT;if(n===nn)return s.HALF_FLOAT;if(n===_p)return s.ALPHA;if(n===Mp)return s.RGB;if(n===fn)return s.RGBA;if(n===Ui)return s.DEPTH_COMPONENT;if(n===As)return s.DEPTH_STENCIL;if(n===cu)return s.RED;if(n===lu)return s.RED_INTEGER;if(n===Cs)return s.RG;if(n===hu)return s.RG_INTEGER;if(n===uu)return s.RGBA_INTEGER;if(n===Lo||n===No||n===Oo||n===Uo)if(a===se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Lo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===No)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Oo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Uo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Lo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===No)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Oo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Uo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Kl||n===$l||n===Zl||n===Jl)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===$l)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Zl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Jl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ql||n===jl||n===th||n===eh||n===nh||n===Xo||n===ih)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ql||n===jl)return a===se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===th)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===eh)return r.COMPRESSED_R11_EAC;if(n===nh)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Xo)return r.COMPRESSED_RG11_EAC;if(n===ih)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===sh||n===rh||n===ah||n===oh||n===ch||n===lh||n===hh||n===uh||n===dh||n===fh||n===ph||n===mh||n===gh||n===vh)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===sh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===rh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ah)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===oh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ch)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===lh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===hh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===uh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===dh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===fh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ph)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===mh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===gh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===vh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xh||n===_h||n===Mh)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===xh)return a===se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===_h)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Mh)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===yh||n===Sh||n===qo||n===bh)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===yh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Sh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===qo)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===bh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===va?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}const By=`
|
|
4601
|
+
}`,Oy=[new P(1,0,0),new P(-1,0,0),new P(0,1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1)],Uy=[new P(0,-1,0),new P(0,-1,0),new P(0,0,1),new P(0,0,-1),new P(0,-1,0),new P(0,-1,0)],L0=new Xt,Yr=new P,al=new P;function Fy(s,t,e){let n=new _u;const i=new Pt,r=new Pt,a=new le,o=new b2,c=new E2,l={},h=e.maxTextureSize,u={[cs]:Be,[Be]:cs,[qn]:qn},d=new De({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Pt},radius:{value:4}},vertexShader:Ly,fragmentShader:Ny}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new be;g.setAttribute("position",new de(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const v=new $t(g,d),p=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ra;let m=this.type;this.render=function(w,R,_){if(p.enabled===!1||p.autoUpdate===!1&&p.needsUpdate===!1||w.length===0)return;this.type===Hg&&(wt("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ra);const A=s.getRenderTarget(),C=s.getActiveCubeFace(),D=s.getActiveMipmapLevel(),I=s.state;I.setBlending(mi),I.buffers.depth.getReversed()===!0?I.buffers.color.setClear(0,0,0,0):I.buffers.color.setClear(1,1,1,1),I.buffers.depth.setTest(!0),I.setScissorTest(!1);const V=m!==this.type;V&&R.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(O=>O.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,O=w.length;q<O;q++){const W=w[q],G=W.shadow;if(G===void 0){wt("WebGLShadowMap:",W,"has no shadow.");continue}if(G.autoUpdate===!1&&G.needsUpdate===!1)continue;i.copy(G.mapSize);const Z=G.getFrameExtents();i.multiply(Z),r.copy(G.mapSize),(i.x>h||i.y>h)&&(i.x>h&&(r.x=Math.floor(h/Z.x),i.x=r.x*Z.x,G.mapSize.x=r.x),i.y>h&&(r.y=Math.floor(h/Z.y),i.y=r.y*Z.y,G.mapSize.y=r.y));const et=s.state.buffers.depth.getReversed();if(G.camera._reversedDepth=et,G.map===null||V===!0){if(G.map!==null&&(G.map.depthTexture!==null&&(G.map.depthTexture.dispose(),G.map.depthTexture=null),G.map.dispose()),this.type===jr){if(W.isPointLight){wt("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}G.map=new Sn(i.x,i.y,{format:Cs,type:nn,minFilter:ye,magFilter:ye,generateMipmaps:!1}),G.map.texture.name=W.name+".shadowMap",G.map.depthTexture=new Ps(i.x,i.y,zn),G.map.depthTexture.name=W.name+".shadowMapDepth",G.map.depthTexture.format=Ui,G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=ke,G.map.depthTexture.magFilter=ke}else W.isPointLight?(G.map=new zp(i.x),G.map.depthTexture=new g2(i.x,Jn)):(G.map=new Sn(i.x,i.y),G.map.depthTexture=new Ps(i.x,i.y,Jn)),G.map.depthTexture.name=W.name+".shadowMap",G.map.depthTexture.format=Ui,this.type===ra?(G.map.depthTexture.compareFunction=et?fu:du,G.map.depthTexture.minFilter=ye,G.map.depthTexture.magFilter=ye):(G.map.depthTexture.compareFunction=null,G.map.depthTexture.minFilter=ke,G.map.depthTexture.magFilter=ke);G.camera.updateProjectionMatrix()}const j=G.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<j;it++){if(G.map.isWebGLCubeRenderTarget)s.setRenderTarget(G.map,it),s.clear();else{it===0&&(s.setRenderTarget(G.map),s.clear());const ut=G.getViewport(it);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),I.viewport(a)}if(W.isPointLight){const ut=G.camera,Ht=G.matrix,Jt=W.distance||ut.far;Jt!==ut.far&&(ut.far=Jt,ut.updateProjectionMatrix()),Yr.setFromMatrixPosition(W.matrixWorld),ut.position.copy(Yr),al.copy(ut.position),al.add(Oy[it]),ut.up.copy(Uy[it]),ut.lookAt(al),ut.updateMatrixWorld(),Ht.makeTranslation(-Yr.x,-Yr.y,-Yr.z),L0.multiplyMatrices(ut.projectionMatrix,ut.matrixWorldInverse),G._frustum.setFromProjectionMatrix(L0,ut.coordinateSystem,ut.reversedDepth)}else G.updateMatrices(W);n=G.getFrustum(),M(R,_,G.camera,W,this.type)}G.isPointLightShadow!==!0&&this.type===jr&&b(G,_),G.needsUpdate=!1}m=this.type,p.needsUpdate=!1,s.setRenderTarget(A,C,D)};function b(w,R){const _=t.update(v);d.defines.VSM_SAMPLES!==w.blurSamples&&(d.defines.VSM_SAMPLES=w.blurSamples,f.defines.VSM_SAMPLES=w.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),w.mapPass===null&&(w.mapPass=new Sn(i.x,i.y,{format:Cs,type:nn})),d.uniforms.shadow_pass.value=w.map.depthTexture,d.uniforms.resolution.value=w.mapSize,d.uniforms.radius.value=w.radius,s.setRenderTarget(w.mapPass),s.clear(),s.renderBufferDirect(R,null,_,d,v,null),f.uniforms.shadow_pass.value=w.mapPass.texture,f.uniforms.resolution.value=w.mapSize,f.uniforms.radius.value=w.radius,s.setRenderTarget(w.map),s.clear(),s.renderBufferDirect(R,null,_,f,v,null)}function E(w,R,_,A){let C=null;const D=_.isPointLight===!0?w.customDistanceMaterial:w.customDepthMaterial;if(D!==void 0)C=D;else if(C=_.isPointLight===!0?c:o,s.localClippingEnabled&&R.clipShadows===!0&&Array.isArray(R.clippingPlanes)&&R.clippingPlanes.length!==0||R.displacementMap&&R.displacementScale!==0||R.alphaMap&&R.alphaTest>0||R.map&&R.alphaTest>0||R.alphaToCoverage===!0){const I=C.uuid,V=R.uuid;let q=l[I];q===void 0&&(q={},l[I]=q);let O=q[V];O===void 0&&(O=C.clone(),q[V]=O,R.addEventListener("dispose",S)),C=O}if(C.visible=R.visible,C.wireframe=R.wireframe,A===jr?C.side=R.shadowSide!==null?R.shadowSide:R.side:C.side=R.shadowSide!==null?R.shadowSide:u[R.side],C.alphaMap=R.alphaMap,C.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,C.map=R.map,C.clipShadows=R.clipShadows,C.clippingPlanes=R.clippingPlanes,C.clipIntersection=R.clipIntersection,C.displacementMap=R.displacementMap,C.displacementScale=R.displacementScale,C.displacementBias=R.displacementBias,C.wireframeLinewidth=R.wireframeLinewidth,C.linewidth=R.linewidth,_.isPointLight===!0&&C.isMeshDistanceMaterial===!0){const I=s.properties.get(C);I.light=_}return C}function M(w,R,_,A,C){if(w.visible===!1)return;if(w.layers.test(R.layers)&&(w.isMesh||w.isLine||w.isPoints)&&(w.castShadow||w.receiveShadow&&C===jr)&&(!w.frustumCulled||n.intersectsObject(w))){w.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,w.matrixWorld);const V=t.update(w),q=w.material;if(Array.isArray(q)){const O=V.groups;for(let W=0,G=O.length;W<G;W++){const Z=O[W],et=q[Z.materialIndex];if(et&&et.visible){const j=E(w,et,A,C);w.onBeforeShadow(s,w,R,_,V,j,Z),s.renderBufferDirect(_,null,V,j,w,Z),w.onAfterShadow(s,w,R,_,V,j,Z)}}}else if(q.visible){const O=E(w,q,A,C);w.onBeforeShadow(s,w,R,_,V,O,null),s.renderBufferDirect(_,null,V,O,w,null),w.onAfterShadow(s,w,R,_,V,O,null)}}const I=w.children;for(let V=0,q=I.length;V<q;V++)M(I[V],R,_,A,C)}function S(w){w.target.removeEventListener("dispose",S);for(const _ in l){const A=l[_],C=w.target.uuid;C in A&&(A[C].dispose(),delete A[C])}}}function zy(s,t){function e(){let L=!1;const at=new le;let J=null;const ht=new le(0,0,0,0);return{setMask:function(gt){J!==gt&&!L&&(s.colorMask(gt,gt,gt,gt),J=gt)},setLocked:function(gt){L=gt},setClear:function(gt,tt,At,yt,Ae){Ae===!0&&(gt*=yt,tt*=yt,At*=yt),at.set(gt,tt,At,yt),ht.equals(at)===!1&&(s.clearColor(gt,tt,At,yt),ht.copy(at))},reset:function(){L=!1,J=null,ht.set(-1,0,0,0)}}}function n(){let L=!1,at=!1,J=null,ht=null,gt=null;return{setReversed:function(tt){if(at!==tt){const At=t.get("EXT_clip_control");tt?At.clipControlEXT(At.LOWER_LEFT_EXT,At.ZERO_TO_ONE_EXT):At.clipControlEXT(At.LOWER_LEFT_EXT,At.NEGATIVE_ONE_TO_ONE_EXT),at=tt;const yt=gt;gt=null,this.setClear(yt)}},getReversed:function(){return at},setTest:function(tt){tt?nt(s.DEPTH_TEST):z(s.DEPTH_TEST)},setMask:function(tt){J!==tt&&!L&&(s.depthMask(tt),J=tt)},setFunc:function(tt){if(at&&(tt=b1[tt]),ht!==tt){switch(tt){case kl:s.depthFunc(s.NEVER);break;case Hl:s.depthFunc(s.ALWAYS);break;case Gl:s.depthFunc(s.LESS);break;case br:s.depthFunc(s.LEQUAL);break;case Vl:s.depthFunc(s.EQUAL);break;case Wl:s.depthFunc(s.GEQUAL);break;case Xl:s.depthFunc(s.GREATER);break;case ql:s.depthFunc(s.NOTEQUAL);break;default:s.depthFunc(s.LEQUAL)}ht=tt}},setLocked:function(tt){L=tt},setClear:function(tt){gt!==tt&&(gt=tt,at&&(tt=1-tt),s.clearDepth(tt))},reset:function(){L=!1,J=null,ht=null,gt=null,at=!1}}}function i(){let L=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,yt=null,Ae=null;return{setTest:function(fe){L||(fe?nt(s.STENCIL_TEST):z(s.STENCIL_TEST))},setMask:function(fe){at!==fe&&!L&&(s.stencilMask(fe),at=fe)},setFunc:function(fe,jn,ti){(J!==fe||ht!==jn||gt!==ti)&&(s.stencilFunc(fe,jn,ti),J=fe,ht=jn,gt=ti)},setOp:function(fe,jn,ti){(tt!==fe||At!==jn||yt!==ti)&&(s.stencilOp(fe,jn,ti),tt=fe,At=jn,yt=ti)},setLocked:function(fe){L=fe},setClear:function(fe){Ae!==fe&&(s.clearStencil(fe),Ae=fe)},reset:function(){L=!1,at=null,J=null,ht=null,gt=null,tt=null,At=null,yt=null,Ae=null}}}const r=new e,a=new n,o=new i,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],v=null,p=!1,m=null,b=null,E=null,M=null,S=null,w=null,R=null,_=new vt(0,0,0),A=0,C=!1,D=null,I=null,V=null,q=null,O=null;const W=s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let G=!1,Z=0;const et=s.getParameter(s.VERSION);et.indexOf("WebGL")!==-1?(Z=parseFloat(/^WebGL (\d)/.exec(et)[1]),G=Z>=1):et.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),G=Z>=2);let j=null,it={};const ut=s.getParameter(s.SCISSOR_BOX),Ht=s.getParameter(s.VIEWPORT),Jt=new le().fromArray(ut),kt=new le().fromArray(Ht);function Y(L,at,J,ht){const gt=new Uint8Array(4),tt=s.createTexture();s.bindTexture(L,tt),s.texParameteri(L,s.TEXTURE_MIN_FILTER,s.NEAREST),s.texParameteri(L,s.TEXTURE_MAG_FILTER,s.NEAREST);for(let At=0;At<J;At++)L===s.TEXTURE_3D||L===s.TEXTURE_2D_ARRAY?s.texImage3D(at,0,s.RGBA,1,1,ht,0,s.RGBA,s.UNSIGNED_BYTE,gt):s.texImage2D(at+At,0,s.RGBA,1,1,0,s.RGBA,s.UNSIGNED_BYTE,gt);return tt}const rt={};rt[s.TEXTURE_2D]=Y(s.TEXTURE_2D,s.TEXTURE_2D,1),rt[s.TEXTURE_CUBE_MAP]=Y(s.TEXTURE_CUBE_MAP,s.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[s.TEXTURE_2D_ARRAY]=Y(s.TEXTURE_2D_ARRAY,s.TEXTURE_2D_ARRAY,1,1),rt[s.TEXTURE_3D]=Y(s.TEXTURE_3D,s.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(s.DEPTH_TEST),a.setFunc(br),ee(!1),ne(fd),nt(s.CULL_FACE),Ot(mi);function nt(L){h[L]!==!0&&(s.enable(L),h[L]=!0)}function z(L){h[L]!==!1&&(s.disable(L),h[L]=!1)}function Et(L,at){return d[L]!==at?(s.bindFramebuffer(L,at),d[L]=at,L===s.DRAW_FRAMEBUFFER&&(d[s.FRAMEBUFFER]=at),L===s.FRAMEBUFFER&&(d[s.DRAW_FRAMEBUFFER]=at),!0):!1}function It(L,at){let J=g,ht=!1;if(L){J=f.get(at),J===void 0&&(J=[],f.set(at,J));const gt=L.textures;if(J.length!==gt.length||J[0]!==s.COLOR_ATTACHMENT0){for(let tt=0,At=gt.length;tt<At;tt++)J[tt]=s.COLOR_ATTACHMENT0+tt;J.length=gt.length,ht=!0}}else J[0]!==s.BACK&&(J[0]=s.BACK,ht=!0);ht&&s.drawBuffers(J)}function Tt(L){return v!==L?(s.useProgram(L),v=L,!0):!1}const _t={[ys]:s.FUNC_ADD,[Vg]:s.FUNC_SUBTRACT,[Wg]:s.FUNC_REVERSE_SUBTRACT};_t[Xg]=s.MIN,_t[qg]=s.MAX;const Nt={[Yg]:s.ZERO,[Kg]:s.ONE,[$g]:s.SRC_COLOR,[zl]:s.SRC_ALPHA,[e1]:s.SRC_ALPHA_SATURATE,[jg]:s.DST_COLOR,[Jg]:s.DST_ALPHA,[Zg]:s.ONE_MINUS_SRC_COLOR,[Bl]:s.ONE_MINUS_SRC_ALPHA,[t1]:s.ONE_MINUS_DST_COLOR,[Qg]:s.ONE_MINUS_DST_ALPHA,[n1]:s.CONSTANT_COLOR,[i1]:s.ONE_MINUS_CONSTANT_COLOR,[s1]:s.CONSTANT_ALPHA,[r1]:s.ONE_MINUS_CONSTANT_ALPHA};function Ot(L,at,J,ht,gt,tt,At,yt,Ae,fe){if(L===mi){p===!0&&(z(s.BLEND),p=!1);return}if(p===!1&&(nt(s.BLEND),p=!0),L!==Gg){if(L!==m||fe!==C){if((b!==ys||S!==ys)&&(s.blendEquation(s.FUNC_ADD),b=ys,S=ys),fe)switch(L){case mr:s.blendFuncSeparate(s.ONE,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Zn:s.blendFunc(s.ONE,s.ONE);break;case pd:s.blendFuncSeparate(s.ZERO,s.ONE_MINUS_SRC_COLOR,s.ZERO,s.ONE);break;case md:s.blendFuncSeparate(s.DST_COLOR,s.ONE_MINUS_SRC_ALPHA,s.ZERO,s.ONE);break;default:zt("WebGLState: Invalid blending: ",L);break}else switch(L){case mr:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA,s.ONE,s.ONE_MINUS_SRC_ALPHA);break;case Zn:s.blendFuncSeparate(s.SRC_ALPHA,s.ONE,s.ONE,s.ONE);break;case pd:zt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case md:zt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:zt("WebGLState: Invalid blending: ",L);break}E=null,M=null,w=null,R=null,_.set(0,0,0),A=0,m=L,C=fe}return}gt=gt||at,tt=tt||J,At=At||ht,(at!==b||gt!==S)&&(s.blendEquationSeparate(_t[at],_t[gt]),b=at,S=gt),(J!==E||ht!==M||tt!==w||At!==R)&&(s.blendFuncSeparate(Nt[J],Nt[ht],Nt[tt],Nt[At]),E=J,M=ht,w=tt,R=At),(yt.equals(_)===!1||Ae!==A)&&(s.blendColor(yt.r,yt.g,yt.b,Ae),_.copy(yt),A=Ae),m=L,C=!1}function Ut(L,at){L.side===qn?z(s.CULL_FACE):nt(s.CULL_FACE);let J=L.side===Be;at&&(J=!J),ee(J),L.blending===mr&&L.transparent===!1?Ot(mi):Ot(L.blending,L.blendEquation,L.blendSrc,L.blendDst,L.blendEquationAlpha,L.blendSrcAlpha,L.blendDstAlpha,L.blendColor,L.blendAlpha,L.premultipliedAlpha),a.setFunc(L.depthFunc),a.setTest(L.depthTest),a.setMask(L.depthWrite),r.setMask(L.colorWrite);const ht=L.stencilWrite;o.setTest(ht),ht&&(o.setMask(L.stencilWriteMask),o.setFunc(L.stencilFunc,L.stencilRef,L.stencilFuncMask),o.setOp(L.stencilFail,L.stencilZFail,L.stencilZPass)),ve(L.polygonOffset,L.polygonOffsetFactor,L.polygonOffsetUnits),L.alphaToCoverage===!0?nt(s.SAMPLE_ALPHA_TO_COVERAGE):z(s.SAMPLE_ALPHA_TO_COVERAGE)}function ee(L){D!==L&&(L?s.frontFace(s.CW):s.frontFace(s.CCW),D=L)}function ne(L){L!==Bg?(nt(s.CULL_FACE),L!==I&&(L===fd?s.cullFace(s.BACK):L===kg?s.cullFace(s.FRONT):s.cullFace(s.FRONT_AND_BACK))):z(s.CULL_FACE),I=L}function Ee(L){L!==V&&(G&&s.lineWidth(L),V=L)}function ve(L,at,J){L?(nt(s.POLYGON_OFFSET_FILL),(q!==at||O!==J)&&(q=at,O=J,a.getReversed()&&(at=-at),s.polygonOffset(at,J))):z(s.POLYGON_OFFSET_FILL)}function we(L){L?nt(s.SCISSOR_TEST):z(s.SCISSOR_TEST)}function Oe(L){L===void 0&&(L=s.TEXTURE0+W-1),j!==L&&(s.activeTexture(L),j=L)}function N(L,at,J){J===void 0&&(j===null?J=s.TEXTURE0+W-1:J=j);let ht=it[J];ht===void 0&&(ht={type:void 0,texture:void 0},it[J]=ht),(ht.type!==L||ht.texture!==at)&&(j!==J&&(s.activeTexture(J),j=J),s.bindTexture(L,at||rt[L]),ht.type=L,ht.texture=at)}function gn(){const L=it[j];L!==void 0&&L.type!==void 0&&(s.bindTexture(L.type,null),L.type=void 0,L.texture=void 0)}function ie(){try{s.compressedTexImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function T(){try{s.compressedTexImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function x(){try{s.texSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function F(){try{s.texSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function H(){try{s.compressedTexSubImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function K(){try{s.compressedTexSubImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function st(){try{s.texStorage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function ot(){try{s.texStorage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function $(){try{s.texImage2D(...arguments)}catch(L){zt("WebGLState:",L)}}function Q(){try{s.texImage3D(...arguments)}catch(L){zt("WebGLState:",L)}}function ct(L){return u[L]!==void 0?u[L]:s.getParameter(L)}function Rt(L,at){u[L]!==at&&(s.pixelStorei(L,at),u[L]=at)}function dt(L){Jt.equals(L)===!1&&(s.scissor(L.x,L.y,L.z,L.w),Jt.copy(L))}function lt(L){kt.equals(L)===!1&&(s.viewport(L.x,L.y,L.z,L.w),kt.copy(L))}function Lt(L,at){let J=l.get(at);J===void 0&&(J=new WeakMap,l.set(at,J));let ht=J.get(L);ht===void 0&&(ht=s.getUniformBlockIndex(at,L.name),J.set(L,ht))}function Ft(L,at){const ht=l.get(at).get(L);c.get(at)!==ht&&(s.uniformBlockBinding(at,ht,L.__bindingPointIndex),c.set(at,ht))}function Gt(){s.disable(s.BLEND),s.disable(s.CULL_FACE),s.disable(s.DEPTH_TEST),s.disable(s.POLYGON_OFFSET_FILL),s.disable(s.SCISSOR_TEST),s.disable(s.STENCIL_TEST),s.disable(s.SAMPLE_ALPHA_TO_COVERAGE),s.blendEquation(s.FUNC_ADD),s.blendFunc(s.ONE,s.ZERO),s.blendFuncSeparate(s.ONE,s.ZERO,s.ONE,s.ZERO),s.blendColor(0,0,0,0),s.colorMask(!0,!0,!0,!0),s.clearColor(0,0,0,0),s.depthMask(!0),s.depthFunc(s.LESS),a.setReversed(!1),s.clearDepth(1),s.stencilMask(4294967295),s.stencilFunc(s.ALWAYS,0,4294967295),s.stencilOp(s.KEEP,s.KEEP,s.KEEP),s.clearStencil(0),s.cullFace(s.BACK),s.frontFace(s.CCW),s.polygonOffset(0,0),s.activeTexture(s.TEXTURE0),s.bindFramebuffer(s.FRAMEBUFFER,null),s.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),s.bindFramebuffer(s.READ_FRAMEBUFFER,null),s.useProgram(null),s.lineWidth(1),s.scissor(0,0,s.canvas.width,s.canvas.height),s.viewport(0,0,s.canvas.width,s.canvas.height),s.pixelStorei(s.PACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_ALIGNMENT,4),s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,!1),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),s.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,s.BROWSER_DEFAULT_WEBGL),s.pixelStorei(s.PACK_ROW_LENGTH,0),s.pixelStorei(s.PACK_SKIP_PIXELS,0),s.pixelStorei(s.PACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_ROW_LENGTH,0),s.pixelStorei(s.UNPACK_IMAGE_HEIGHT,0),s.pixelStorei(s.UNPACK_SKIP_PIXELS,0),s.pixelStorei(s.UNPACK_SKIP_ROWS,0),s.pixelStorei(s.UNPACK_SKIP_IMAGES,0),h={},u={},j=null,it={},d={},f=new WeakMap,g=[],v=null,p=!1,m=null,b=null,E=null,M=null,S=null,w=null,R=null,_=new vt(0,0,0),A=0,C=!1,D=null,I=null,V=null,q=null,O=null,Jt.set(0,0,s.canvas.width,s.canvas.height),kt.set(0,0,s.canvas.width,s.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:Et,drawBuffers:It,useProgram:Tt,setBlending:Ot,setMaterial:Ut,setFlipSided:ee,setCullFace:ne,setLineWidth:Ee,setPolygonOffset:ve,setScissorTest:we,activeTexture:Oe,bindTexture:N,unbindTexture:gn,compressedTexImage2D:ie,compressedTexImage3D:T,texImage2D:$,texImage3D:Q,pixelStorei:Rt,getParameter:ct,updateUBOMapping:Lt,uniformBlockBinding:Ft,texStorage2D:st,texStorage3D:ot,texSubImage2D:x,texSubImage3D:F,compressedTexSubImage2D:H,compressedTexSubImage3D:K,scissor:dt,viewport:lt,reset:Gt}}function By(s,t,e,n,i,r,a){const o=t.has("WEBGL_multisampled_render_to_texture")?t.get("WEBGL_multisampled_render_to_texture"):null,c=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),l=new Pt,h=new WeakMap,u=new Set;let d;const f=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function v(T,x){return g?new OffscreenCanvas(T,x):_a("canvas")}function p(T,x,F){let H=1;const K=ie(T);if((K.width>F||K.height>F)&&(H=F/Math.max(K.width,K.height)),H<1)if(typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&T instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&T instanceof ImageBitmap||typeof VideoFrame<"u"&&T instanceof VideoFrame){const st=Math.floor(H*K.width),ot=Math.floor(H*K.height);d===void 0&&(d=v(st,ot));const $=x?v(st,ot):d;return $.width=st,$.height=ot,$.getContext("2d").drawImage(T,0,0,st,ot),wt("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+st+"x"+ot+")."),$}else return"data"in T&&wt("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function m(T){return T.generateMipmaps}function b(T){s.generateMipmap(T)}function E(T){return T.isWebGLCubeRenderTarget?s.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?s.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?s.TEXTURE_2D_ARRAY:s.TEXTURE_2D}function M(T,x,F,H,K,st=!1){if(T!==null){if(s[T]!==void 0)return s[T];wt("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ot;H&&(ot=t.get("EXT_texture_norm16"),ot||wt("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let $=x;if(x===s.RED&&(F===s.FLOAT&&($=s.R32F),F===s.HALF_FLOAT&&($=s.R16F),F===s.UNSIGNED_BYTE&&($=s.R8),F===s.UNSIGNED_SHORT&&ot&&($=ot.R16_EXT),F===s.SHORT&&ot&&($=ot.R16_SNORM_EXT)),x===s.RED_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.R8UI),F===s.UNSIGNED_SHORT&&($=s.R16UI),F===s.UNSIGNED_INT&&($=s.R32UI),F===s.BYTE&&($=s.R8I),F===s.SHORT&&($=s.R16I),F===s.INT&&($=s.R32I)),x===s.RG&&(F===s.FLOAT&&($=s.RG32F),F===s.HALF_FLOAT&&($=s.RG16F),F===s.UNSIGNED_BYTE&&($=s.RG8),F===s.UNSIGNED_SHORT&&ot&&($=ot.RG16_EXT),F===s.SHORT&&ot&&($=ot.RG16_SNORM_EXT)),x===s.RG_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RG8UI),F===s.UNSIGNED_SHORT&&($=s.RG16UI),F===s.UNSIGNED_INT&&($=s.RG32UI),F===s.BYTE&&($=s.RG8I),F===s.SHORT&&($=s.RG16I),F===s.INT&&($=s.RG32I)),x===s.RGB_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGB8UI),F===s.UNSIGNED_SHORT&&($=s.RGB16UI),F===s.UNSIGNED_INT&&($=s.RGB32UI),F===s.BYTE&&($=s.RGB8I),F===s.SHORT&&($=s.RGB16I),F===s.INT&&($=s.RGB32I)),x===s.RGBA_INTEGER&&(F===s.UNSIGNED_BYTE&&($=s.RGBA8UI),F===s.UNSIGNED_SHORT&&($=s.RGBA16UI),F===s.UNSIGNED_INT&&($=s.RGBA32UI),F===s.BYTE&&($=s.RGBA8I),F===s.SHORT&&($=s.RGBA16I),F===s.INT&&($=s.RGBA32I)),x===s.RGB&&(F===s.UNSIGNED_SHORT&&ot&&($=ot.RGB16_EXT),F===s.SHORT&&ot&&($=ot.RGB16_SNORM_EXT),F===s.UNSIGNED_INT_5_9_9_9_REV&&($=s.RGB9_E5),F===s.UNSIGNED_INT_10F_11F_11F_REV&&($=s.R11F_G11F_B10F)),x===s.RGBA){const Q=st?Zo:Qt.getTransfer(K);F===s.FLOAT&&($=s.RGBA32F),F===s.HALF_FLOAT&&($=s.RGBA16F),F===s.UNSIGNED_BYTE&&($=Q===se?s.SRGB8_ALPHA8:s.RGBA8),F===s.UNSIGNED_SHORT&&ot&&($=ot.RGBA16_EXT),F===s.SHORT&&ot&&($=ot.RGBA16_SNORM_EXT),F===s.UNSIGNED_SHORT_4_4_4_4&&($=s.RGBA4),F===s.UNSIGNED_SHORT_5_5_5_1&&($=s.RGB5_A1)}return($===s.R16F||$===s.R32F||$===s.RG16F||$===s.RG32F||$===s.RGBA16F||$===s.RGBA32F)&&t.get("EXT_color_buffer_float"),$}function S(T,x){let F;return T?x===null||x===Jn||x===va?F=s.DEPTH24_STENCIL8:x===zn?F=s.DEPTH32F_STENCIL8:x===ga&&(F=s.DEPTH24_STENCIL8,wt("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===Jn||x===va?F=s.DEPTH_COMPONENT24:x===zn?F=s.DEPTH_COMPONENT32F:x===ga&&(F=s.DEPTH_COMPONENT16),F}function w(T,x){return m(T)===!0||T.isFramebufferTexture&&T.minFilter!==ke&&T.minFilter!==ye?Math.log2(Math.max(x.width,x.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?x.mipmaps.length:1}function R(T){const x=T.target;x.removeEventListener("dispose",R),A(x),x.isVideoTexture&&h.delete(x),x.isHTMLTexture&&u.delete(x)}function _(T){const x=T.target;x.removeEventListener("dispose",_),D(x)}function A(T){const x=n.get(T);if(x.__webglInit===void 0)return;const F=T.source,H=f.get(F);if(H){const K=H[x.__cacheKey];K.usedTimes--,K.usedTimes===0&&C(T),Object.keys(H).length===0&&f.delete(F)}n.remove(T)}function C(T){const x=n.get(T);s.deleteTexture(x.__webglTexture);const F=T.source,H=f.get(F);delete H[x.__cacheKey],a.memory.textures--}function D(T){const x=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let K=0;K<x.__webglFramebuffer[H].length;K++)s.deleteFramebuffer(x.__webglFramebuffer[H][K]);else s.deleteFramebuffer(x.__webglFramebuffer[H]);x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer[H])}else{if(Array.isArray(x.__webglFramebuffer))for(let H=0;H<x.__webglFramebuffer.length;H++)s.deleteFramebuffer(x.__webglFramebuffer[H]);else s.deleteFramebuffer(x.__webglFramebuffer);if(x.__webglDepthbuffer&&s.deleteRenderbuffer(x.__webglDepthbuffer),x.__webglMultisampledFramebuffer&&s.deleteFramebuffer(x.__webglMultisampledFramebuffer),x.__webglColorRenderbuffer)for(let H=0;H<x.__webglColorRenderbuffer.length;H++)x.__webglColorRenderbuffer[H]&&s.deleteRenderbuffer(x.__webglColorRenderbuffer[H]);x.__webglDepthRenderbuffer&&s.deleteRenderbuffer(x.__webglDepthRenderbuffer)}const F=T.textures;for(let H=0,K=F.length;H<K;H++){const st=n.get(F[H]);st.__webglTexture&&(s.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(F[H])}n.remove(T)}let I=0;function V(){I=0}function q(){return I}function O(T){I=T}function W(){const T=I;return T>=i.maxTextures&&wt("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+i.maxTextures),I+=1,T}function G(T){const x=[];return x.push(T.wrapS),x.push(T.wrapT),x.push(T.wrapR||0),x.push(T.magFilter),x.push(T.minFilter),x.push(T.anisotropy),x.push(T.internalFormat),x.push(T.format),x.push(T.type),x.push(T.generateMipmaps),x.push(T.premultiplyAlpha),x.push(T.flipY),x.push(T.unpackAlignment),x.push(T.colorSpace),x.join()}function Z(T,x){const F=n.get(T);if(T.isVideoTexture&&N(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&F.__version!==T.version){const H=T.image;if(H===null)wt("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)wt("WebGLRenderer: Texture marked for update but image is incomplete");else{z(F,T,x);return}}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D,F.__webglTexture,s.TEXTURE0+x)}function et(T,x){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,x);return}else T.isExternalTexture&&(F.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(s.TEXTURE_2D_ARRAY,F.__webglTexture,s.TEXTURE0+x)}function j(T,x){const F=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&F.__version!==T.version){z(F,T,x);return}e.bindTexture(s.TEXTURE_3D,F.__webglTexture,s.TEXTURE0+x)}function it(T,x){const F=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&F.__version!==T.version){Et(F,T,x);return}e.bindTexture(s.TEXTURE_CUBE_MAP,F.__webglTexture,s.TEXTURE0+x)}const ut={[Wo]:s.REPEAT,[dn]:s.CLAMP_TO_EDGE,[Yl]:s.MIRRORED_REPEAT},Ht={[ke]:s.NEAREST,[l1]:s.NEAREST_MIPMAP_NEAREST,[Ua]:s.NEAREST_MIPMAP_LINEAR,[ye]:s.LINEAR,[Ec]:s.LINEAR_MIPMAP_NEAREST,[ws]:s.LINEAR_MIPMAP_LINEAR},Jt={[f1]:s.NEVER,[x1]:s.ALWAYS,[p1]:s.LESS,[du]:s.LEQUAL,[m1]:s.EQUAL,[fu]:s.GEQUAL,[g1]:s.GREATER,[v1]:s.NOTEQUAL};function kt(T,x){if(x.type===zn&&t.has("OES_texture_float_linear")===!1&&(x.magFilter===ye||x.magFilter===Ec||x.magFilter===Ua||x.magFilter===ws||x.minFilter===ye||x.minFilter===Ec||x.minFilter===Ua||x.minFilter===ws)&&wt("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),s.texParameteri(T,s.TEXTURE_WRAP_S,ut[x.wrapS]),s.texParameteri(T,s.TEXTURE_WRAP_T,ut[x.wrapT]),(T===s.TEXTURE_3D||T===s.TEXTURE_2D_ARRAY)&&s.texParameteri(T,s.TEXTURE_WRAP_R,ut[x.wrapR]),s.texParameteri(T,s.TEXTURE_MAG_FILTER,Ht[x.magFilter]),s.texParameteri(T,s.TEXTURE_MIN_FILTER,Ht[x.minFilter]),x.compareFunction&&(s.texParameteri(T,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(T,s.TEXTURE_COMPARE_FUNC,Jt[x.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===ke||x.minFilter!==Ua&&x.minFilter!==ws||x.type===zn&&t.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||n.get(x).__currentAnisotropy){const F=t.get("EXT_texture_filter_anisotropic");s.texParameterf(T,F.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,i.getMaxAnisotropy())),n.get(x).__currentAnisotropy=x.anisotropy}}}function Y(T,x){let F=!1;T.__webglInit===void 0&&(T.__webglInit=!0,x.addEventListener("dispose",R));const H=x.source;let K=f.get(H);K===void 0&&(K={},f.set(H,K));const st=G(x);if(st!==T.__cacheKey){K[st]===void 0&&(K[st]={texture:s.createTexture(),usedTimes:0},a.memory.textures++,F=!0),K[st].usedTimes++;const ot=K[T.__cacheKey];ot!==void 0&&(K[T.__cacheKey].usedTimes--,ot.usedTimes===0&&C(x)),T.__cacheKey=st,T.__webglTexture=K[st].texture}return F}function rt(T,x,F){return Math.floor(Math.floor(T/F)/x)}function nt(T,x,F,H){const st=T.updateRanges;if(st.length===0)e.texSubImage2D(s.TEXTURE_2D,0,0,0,x.width,x.height,F,H,x.data);else{st.sort((Rt,dt)=>Rt.start-dt.start);let ot=0;for(let Rt=1;Rt<st.length;Rt++){const dt=st[ot],lt=st[Rt],Lt=dt.start+dt.count,Ft=rt(lt.start,x.width,4),Gt=rt(dt.start,x.width,4);lt.start<=Lt+1&&Ft===Gt&&rt(lt.start+lt.count-1,x.width,4)===Ft?dt.count=Math.max(dt.count,lt.start+lt.count-dt.start):(++ot,st[ot]=lt)}st.length=ot+1;const $=e.getParameter(s.UNPACK_ROW_LENGTH),Q=e.getParameter(s.UNPACK_SKIP_PIXELS),ct=e.getParameter(s.UNPACK_SKIP_ROWS);e.pixelStorei(s.UNPACK_ROW_LENGTH,x.width);for(let Rt=0,dt=st.length;Rt<dt;Rt++){const lt=st[Rt],Lt=Math.floor(lt.start/4),Ft=Math.ceil(lt.count/4),Gt=Lt%x.width,L=Math.floor(Lt/x.width),at=Ft,J=1;e.pixelStorei(s.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(s.UNPACK_SKIP_ROWS,L),e.texSubImage2D(s.TEXTURE_2D,0,Gt,L,at,J,F,H,x.data)}T.clearUpdateRanges(),e.pixelStorei(s.UNPACK_ROW_LENGTH,$),e.pixelStorei(s.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(s.UNPACK_SKIP_ROWS,ct)}}function z(T,x,F){let H=s.TEXTURE_2D;(x.isDataArrayTexture||x.isCompressedArrayTexture)&&(H=s.TEXTURE_2D_ARRAY),x.isData3DTexture&&(H=s.TEXTURE_3D);const K=Y(T,x),st=x.source;e.bindTexture(H,T.__webglTexture,s.TEXTURE0+F);const ot=n.get(st);if(st.version!==ot.__version||K===!0){if(e.activeTexture(s.TEXTURE0+F),(typeof ImageBitmap<"u"&&x.image instanceof ImageBitmap)===!1){const J=Qt.getPrimaries(Qt.workingColorSpace),ht=x.colorSpace===is?null:Qt.getPrimaries(x.colorSpace),gt=x.colorSpace===is||J===ht?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt)}e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment);let Q=p(x.image,!1,i.maxTextureSize);Q=gn(x,Q);const ct=r.convert(x.format,x.colorSpace),Rt=r.convert(x.type);let dt=M(x.internalFormat,ct,Rt,x.normalized,x.colorSpace,x.isVideoTexture);kt(H,x);let lt;const Lt=x.mipmaps,Ft=x.isVideoTexture!==!0,Gt=ot.__version===void 0||K===!0,L=st.dataReady,at=w(x,Q);if(x.isDepthTexture)dt=S(x.format===As,x.type),Gt&&(Ft?e.texStorage2D(s.TEXTURE_2D,1,dt,Q.width,Q.height):e.texImage2D(s.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Rt,null));else if(x.isDataTexture)if(Lt.length>0){Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Lt[0].width,Lt[0].height);for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Rt,lt.data):e.texImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Rt,lt.data);x.generateMipmaps=!1}else Ft?(Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Q.width,Q.height),L&&nt(x,Q,ct,Rt)):e.texImage2D(s.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Rt,Q.data);else if(x.isCompressedTexture)if(x.isCompressedArrayTexture){Ft&&Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,at,dt,Lt[0].width,Lt[0].height,Q.depth);for(let J=0,ht=Lt.length;J<ht;J++)if(lt=Lt[J],x.format!==fn)if(ct!==null)if(Ft){if(L)if(x.layerUpdates.size>0){const gt=h0(lt.width,lt.height,x.format,x.type);for(const tt of x.layerUpdates){const At=lt.data.subarray(tt*gt/lt.data.BYTES_PER_ELEMENT,(tt+1)*gt/lt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,tt,lt.width,lt.height,1,ct,At)}x.clearLayerUpdates()}else e.compressedTexSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,lt.data)}else e.compressedTexImage3D(s.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,lt.data,0,0);else wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ft?L&&e.texSubImage3D(s.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,Rt,lt.data):e.texImage3D(s.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,ct,Rt,lt.data)}else{Ft&&Gt&&e.texStorage2D(s.TEXTURE_2D,at,dt,Lt[0].width,Lt[0].height);for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],x.format!==fn?ct!==null?Ft?L&&e.compressedTexSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,lt.data):e.compressedTexImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,lt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Rt,lt.data):e.texImage2D(s.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Rt,lt.data)}else if(x.isDataArrayTexture)if(Ft){if(Gt&&e.texStorage3D(s.TEXTURE_2D_ARRAY,at,dt,Q.width,Q.height,Q.depth),L)if(x.layerUpdates.size>0){const J=h0(Q.width,Q.height,x.format,x.type);for(const ht of x.layerUpdates){const gt=Q.data.subarray(ht*J/Q.data.BYTES_PER_ELEMENT,(ht+1)*J/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,ht,Q.width,Q.height,1,ct,Rt,gt)}x.clearLayerUpdates()}else e.texSubImage3D(s.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ct,Rt,Q.data)}else e.texImage3D(s.TEXTURE_2D_ARRAY,0,dt,Q.width,Q.height,Q.depth,0,ct,Rt,Q.data);else if(x.isData3DTexture)Ft?(Gt&&e.texStorage3D(s.TEXTURE_3D,at,dt,Q.width,Q.height,Q.depth),L&&e.texSubImage3D(s.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ct,Rt,Q.data)):e.texImage3D(s.TEXTURE_3D,0,dt,Q.width,Q.height,Q.depth,0,ct,Rt,Q.data);else if(x.isFramebufferTexture){if(Gt)if(Ft)e.texStorage2D(s.TEXTURE_2D,at,dt,Q.width,Q.height);else{let J=Q.width,ht=Q.height;for(let gt=0;gt<at;gt++)e.texImage2D(s.TEXTURE_2D,gt,dt,J,ht,0,ct,Rt,null),J>>=1,ht>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in s){const J=s.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),u.add(x),J.onpaint=ht=>{const gt=ht.changedElements;for(const tt of u)gt.includes(tt.image)&&(tt.needsUpdate=!0)},J.requestPaint();return}if(s.texElementImage2D.length===3)s.texElementImage2D(s.TEXTURE_2D,s.RGBA8,Q);else{const gt=s.RGBA,tt=s.RGBA,At=s.UNSIGNED_BYTE;s.texElementImage2D(s.TEXTURE_2D,0,gt,tt,At,Q)}s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)}}else if(Lt.length>0){if(Ft&&Gt){const J=ie(Lt[0]);e.texStorage2D(s.TEXTURE_2D,at,dt,J.width,J.height)}for(let J=0,ht=Lt.length;J<ht;J++)lt=Lt[J],Ft?L&&e.texSubImage2D(s.TEXTURE_2D,J,0,0,ct,Rt,lt):e.texImage2D(s.TEXTURE_2D,J,dt,ct,Rt,lt);x.generateMipmaps=!1}else if(Ft){if(Gt){const J=ie(Q);e.texStorage2D(s.TEXTURE_2D,at,dt,J.width,J.height)}L&&e.texSubImage2D(s.TEXTURE_2D,0,0,0,ct,Rt,Q)}else e.texImage2D(s.TEXTURE_2D,0,dt,ct,Rt,Q);m(x)&&b(H),ot.__version=st.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function Et(T,x,F){if(x.image.length!==6)return;const H=Y(T,x),K=x.source;e.bindTexture(s.TEXTURE_CUBE_MAP,T.__webglTexture,s.TEXTURE0+F);const st=n.get(K);if(K.version!==st.__version||H===!0){e.activeTexture(s.TEXTURE0+F);const ot=Qt.getPrimaries(Qt.workingColorSpace),$=x.colorSpace===is?null:Qt.getPrimaries(x.colorSpace),Q=x.colorSpace===is||ot===$?s.NONE:s.BROWSER_DEFAULT_WEBGL;e.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,x.flipY),e.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,x.premultiplyAlpha),e.pixelStorei(s.UNPACK_ALIGNMENT,x.unpackAlignment),e.pixelStorei(s.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ct=x.isCompressedTexture||x.image[0].isCompressedTexture,Rt=x.image[0]&&x.image[0].isDataTexture,dt=[];for(let tt=0;tt<6;tt++)!ct&&!Rt?dt[tt]=p(x.image[tt],!0,i.maxCubemapSize):dt[tt]=Rt?x.image[tt].image:x.image[tt],dt[tt]=gn(x,dt[tt]);const lt=dt[0],Lt=r.convert(x.format,x.colorSpace),Ft=r.convert(x.type),Gt=M(x.internalFormat,Lt,Ft,x.normalized,x.colorSpace),L=x.isVideoTexture!==!0,at=st.__version===void 0||H===!0,J=K.dataReady;let ht=w(x,lt);kt(s.TEXTURE_CUBE_MAP,x);let gt;if(ct){L&&at&&e.texStorage2D(s.TEXTURE_CUBE_MAP,ht,Gt,lt.width,lt.height);for(let tt=0;tt<6;tt++){gt=dt[tt].mipmaps;for(let At=0;At<gt.length;At++){const yt=gt[At];x.format!==fn?Lt!==null?L?J&&e.compressedTexSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,yt.width,yt.height,Lt,yt.data):e.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,yt.width,yt.height,0,yt.data):wt("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,0,0,yt.width,yt.height,Lt,Ft,yt.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At,Gt,yt.width,yt.height,0,Lt,Ft,yt.data)}}}else{if(gt=x.mipmaps,L&&at){gt.length>0&&ht++;const tt=ie(dt[0]);e.texStorage2D(s.TEXTURE_CUBE_MAP,ht,Gt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(Rt){L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,dt[tt].width,dt[tt].height,Lt,Ft,dt[tt].data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,dt[tt].width,dt[tt].height,0,Lt,Ft,dt[tt].data);for(let At=0;At<gt.length;At++){const Ae=gt[At].image[tt].image;L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Ae.width,Ae.height,Lt,Ft,Ae.data):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Ae.width,Ae.height,0,Lt,Ft,Ae.data)}}else{L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Lt,Ft,dt[tt]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,Lt,Ft,dt[tt]);for(let At=0;At<gt.length;At++){const yt=gt[At];L?J&&e.texSubImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,0,0,Lt,Ft,yt.image[tt]):e.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+tt,At+1,Gt,Lt,Ft,yt.image[tt])}}}m(x)&&b(s.TEXTURE_CUBE_MAP),st.__version=K.version,x.onUpdate&&x.onUpdate(x)}T.__version=x.version}function It(T,x,F,H,K,st){const ot=r.convert(F.format,F.colorSpace),$=r.convert(F.type),Q=M(F.internalFormat,ot,$,F.normalized,F.colorSpace),ct=n.get(x),Rt=n.get(F);if(Rt.__renderTarget=x,!ct.__hasExternalTextures){const dt=Math.max(1,x.width>>st),lt=Math.max(1,x.height>>st);K===s.TEXTURE_3D||K===s.TEXTURE_2D_ARRAY?e.texImage3D(K,st,Q,dt,lt,x.depth,0,ot,$,null):e.texImage2D(K,st,Q,dt,lt,0,ot,$,null)}e.bindFramebuffer(s.FRAMEBUFFER,T),Oe(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,H,K,Rt.__webglTexture,0,we(x)):(K===s.TEXTURE_2D||K>=s.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=s.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&s.framebufferTexture2D(s.FRAMEBUFFER,H,K,Rt.__webglTexture,st),e.bindFramebuffer(s.FRAMEBUFFER,null)}function Tt(T,x,F){if(s.bindRenderbuffer(s.RENDERBUFFER,T),x.depthBuffer){const H=x.depthTexture,K=H&&H.isDepthTexture?H.type:null,st=S(x.stencilBuffer,K),ot=x.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;Oe(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,we(x),st,x.width,x.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,we(x),st,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,st,x.width,x.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,ot,s.RENDERBUFFER,T)}else{const H=x.textures;for(let K=0;K<H.length;K++){const st=H[K],ot=r.convert(st.format,st.colorSpace),$=r.convert(st.type),Q=M(st.internalFormat,ot,$,st.normalized,st.colorSpace);Oe(x)?o.renderbufferStorageMultisampleEXT(s.RENDERBUFFER,we(x),Q,x.width,x.height):F?s.renderbufferStorageMultisample(s.RENDERBUFFER,we(x),Q,x.width,x.height):s.renderbufferStorage(s.RENDERBUFFER,Q,x.width,x.height)}}s.bindRenderbuffer(s.RENDERBUFFER,null)}function _t(T,x,F){const H=x.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(s.FRAMEBUFFER,T),!(x.depthTexture&&x.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(x.depthTexture);if(K.__renderTarget=x,(!K.__webglTexture||x.depthTexture.image.width!==x.width||x.depthTexture.image.height!==x.height)&&(x.depthTexture.image.width=x.width,x.depthTexture.image.height=x.height,x.depthTexture.needsUpdate=!0),H){if(K.__webglInit===void 0&&(K.__webglInit=!0,x.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=s.createTexture(),e.bindTexture(s.TEXTURE_CUBE_MAP,K.__webglTexture),kt(s.TEXTURE_CUBE_MAP,x.depthTexture);const ct=r.convert(x.depthTexture.format),Rt=r.convert(x.depthTexture.type);let dt;x.depthTexture.format===Ui?dt=s.DEPTH_COMPONENT24:x.depthTexture.format===As&&(dt=s.DEPTH24_STENCIL8);for(let lt=0;lt<6;lt++)s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,dt,x.width,x.height,0,ct,Rt,null)}}else Z(x.depthTexture,0);const st=K.__webglTexture,ot=we(x),$=H?s.TEXTURE_CUBE_MAP_POSITIVE_X+F:s.TEXTURE_2D,Q=x.depthTexture.format===As?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;if(x.depthTexture.format===Ui)Oe(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,$,st,0,ot):s.framebufferTexture2D(s.FRAMEBUFFER,Q,$,st,0);else if(x.depthTexture.format===As)Oe(x)?o.framebufferTexture2DMultisampleEXT(s.FRAMEBUFFER,Q,$,st,0,ot):s.framebufferTexture2D(s.FRAMEBUFFER,Q,$,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Nt(T){const x=n.get(T),F=T.isWebGLCubeRenderTarget===!0;if(x.__boundDepthTexture!==T.depthTexture){const H=T.depthTexture;if(x.__depthDisposeCallback&&x.__depthDisposeCallback(),H){const K=()=>{delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",K)};H.addEventListener("dispose",K),x.__depthDisposeCallback=K}x.__boundDepthTexture=H}if(T.depthTexture&&!x.__autoAllocateDepthBuffer)if(F)for(let H=0;H<6;H++)_t(x.__webglFramebuffer[H],T,H);else{const H=T.texture.mipmaps;H&&H.length>0?_t(x.__webglFramebuffer[0],T,0):_t(x.__webglFramebuffer,T,0)}else if(F){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=s.createRenderbuffer(),Tt(x.__webglDepthbuffer[H],T,!1);else{const K=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer[H];s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,st)}}else{const H=T.texture.mipmaps;if(H&&H.length>0?e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer[0]):e.bindFramebuffer(s.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=s.createRenderbuffer(),Tt(x.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,st=x.__webglDepthbuffer;s.bindRenderbuffer(s.RENDERBUFFER,st),s.framebufferRenderbuffer(s.FRAMEBUFFER,K,s.RENDERBUFFER,st)}}e.bindFramebuffer(s.FRAMEBUFFER,null)}function Ot(T,x,F){const H=n.get(T);x!==void 0&&It(H.__webglFramebuffer,T,T.texture,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,0),F!==void 0&&Nt(T)}function Ut(T){const x=T.texture,F=n.get(T),H=n.get(x);T.addEventListener("dispose",_);const K=T.textures,st=T.isWebGLCubeRenderTarget===!0,ot=K.length>1;if(ot||(H.__webglTexture===void 0&&(H.__webglTexture=s.createTexture()),H.__version=x.version,a.memory.textures++),st){F.__webglFramebuffer=[];for(let $=0;$<6;$++)if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer[$]=[];for(let Q=0;Q<x.mipmaps.length;Q++)F.__webglFramebuffer[$][Q]=s.createFramebuffer()}else F.__webglFramebuffer[$]=s.createFramebuffer()}else{if(x.mipmaps&&x.mipmaps.length>0){F.__webglFramebuffer=[];for(let $=0;$<x.mipmaps.length;$++)F.__webglFramebuffer[$]=s.createFramebuffer()}else F.__webglFramebuffer=s.createFramebuffer();if(ot)for(let $=0,Q=K.length;$<Q;$++){const ct=n.get(K[$]);ct.__webglTexture===void 0&&(ct.__webglTexture=s.createTexture(),a.memory.textures++)}if(T.samples>0&&Oe(T)===!1){F.__webglMultisampledFramebuffer=s.createFramebuffer(),F.__webglColorRenderbuffer=[],e.bindFramebuffer(s.FRAMEBUFFER,F.__webglMultisampledFramebuffer);for(let $=0;$<K.length;$++){const Q=K[$];F.__webglColorRenderbuffer[$]=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,F.__webglColorRenderbuffer[$]);const ct=r.convert(Q.format,Q.colorSpace),Rt=r.convert(Q.type),dt=M(Q.internalFormat,ct,Rt,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),lt=we(T);s.renderbufferStorageMultisample(s.RENDERBUFFER,lt,dt,T.width,T.height),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+$,s.RENDERBUFFER,F.__webglColorRenderbuffer[$])}s.bindRenderbuffer(s.RENDERBUFFER,null),T.depthBuffer&&(F.__webglDepthRenderbuffer=s.createRenderbuffer(),Tt(F.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(s.FRAMEBUFFER,null)}}if(st){e.bindTexture(s.TEXTURE_CUBE_MAP,H.__webglTexture),kt(s.TEXTURE_CUBE_MAP,x);for(let $=0;$<6;$++)if(x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(F.__webglFramebuffer[$][Q],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,Q);else It(F.__webglFramebuffer[$],T,x,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+$,0);m(x)&&b(s.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let $=0,Q=K.length;$<Q;$++){const ct=K[$],Rt=n.get(ct);let dt=s.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(dt=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture(dt,Rt.__webglTexture),kt(dt,ct),It(F.__webglFramebuffer,T,ct,s.COLOR_ATTACHMENT0+$,dt,0),m(ct)&&b(dt)}e.unbindTexture()}else{let $=s.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&($=T.isWebGL3DRenderTarget?s.TEXTURE_3D:s.TEXTURE_2D_ARRAY),e.bindTexture($,H.__webglTexture),kt($,x),x.mipmaps&&x.mipmaps.length>0)for(let Q=0;Q<x.mipmaps.length;Q++)It(F.__webglFramebuffer[Q],T,x,s.COLOR_ATTACHMENT0,$,Q);else It(F.__webglFramebuffer,T,x,s.COLOR_ATTACHMENT0,$,0);m(x)&&b($),e.unbindTexture()}T.depthBuffer&&Nt(T)}function ee(T){const x=T.textures;for(let F=0,H=x.length;F<H;F++){const K=x[F];if(m(K)){const st=E(T),ot=n.get(K).__webglTexture;e.bindTexture(st,ot),b(st),e.unbindTexture()}}}const ne=[],Ee=[];function ve(T){if(T.samples>0){if(Oe(T)===!1){const x=T.textures,F=T.width,H=T.height;let K=s.COLOR_BUFFER_BIT;const st=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT,ot=n.get(T),$=x.length>1;if($)for(let ct=0;ct<x.length;ct++)e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.RENDERBUFFER,null),e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.TEXTURE_2D,null,0);e.bindFramebuffer(s.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ct=0;ct<x.length;ct++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=s.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=s.STENCIL_BUFFER_BIT)),$){s.framebufferRenderbuffer(s.READ_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Rt=n.get(x[ct]).__webglTexture;s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,Rt,0)}s.blitFramebuffer(0,0,F,H,0,0,F,H,K,s.NEAREST),c===!0&&(ne.length=0,Ee.length=0,ne.push(s.COLOR_ATTACHMENT0+ct),T.depthBuffer&&T.resolveDepthBuffer===!1&&(ne.push(st),Ee.push(st),s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,Ee)),s.invalidateFramebuffer(s.READ_FRAMEBUFFER,ne))}if(e.bindFramebuffer(s.READ_FRAMEBUFFER,null),e.bindFramebuffer(s.DRAW_FRAMEBUFFER,null),$)for(let ct=0;ct<x.length;ct++){e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Rt=n.get(x[ct]).__webglTexture;e.bindFramebuffer(s.FRAMEBUFFER,ot.__webglFramebuffer),s.framebufferTexture2D(s.DRAW_FRAMEBUFFER,s.COLOR_ATTACHMENT0+ct,s.TEXTURE_2D,Rt,0)}e.bindFramebuffer(s.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const x=T.stencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;s.invalidateFramebuffer(s.DRAW_FRAMEBUFFER,[x])}}}function we(T){return Math.min(i.maxSamples,T.samples)}function Oe(T){const x=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function N(T){const x=a.render.frame;h.get(T)!==x&&(h.set(T,x),T.update())}function gn(T,x){const F=T.colorSpace,H=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||F!==$o&&F!==is&&(Qt.getTransfer(F)===se?(H!==fn||K!==Dn)&&wt("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):zt("WebGLTextures: Unsupported texture color space:",F)),x}function ie(T){return typeof HTMLImageElement<"u"&&T instanceof HTMLImageElement?(l.width=T.naturalWidth||T.width,l.height=T.naturalHeight||T.height):typeof VideoFrame<"u"&&T instanceof VideoFrame?(l.width=T.displayWidth,l.height=T.displayHeight):(l.width=T.width,l.height=T.height),l}this.allocateTextureUnit=W,this.resetTextureUnits=V,this.getTextureUnits=q,this.setTextureUnits=O,this.setTexture2D=Z,this.setTexture2DArray=et,this.setTexture3D=j,this.setTextureCube=it,this.rebindTextures=Ot,this.setupRenderTarget=Ut,this.updateRenderTargetMipmap=ee,this.updateMultisampleRenderTarget=ve,this.setupDepthRenderbuffer=Nt,this.setupFrameBufferTexture=It,this.useMultisampledRTT=Oe,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function ky(s,t){function e(n,i=is){let r;const a=Qt.getTransfer(i);if(n===Dn)return s.UNSIGNED_BYTE;if(n===au)return s.UNSIGNED_SHORT_4_4_4_4;if(n===ou)return s.UNSIGNED_SHORT_5_5_5_1;if(n===vp)return s.UNSIGNED_INT_5_9_9_9_REV;if(n===xp)return s.UNSIGNED_INT_10F_11F_11F_REV;if(n===mp)return s.BYTE;if(n===gp)return s.SHORT;if(n===ga)return s.UNSIGNED_SHORT;if(n===ru)return s.INT;if(n===Jn)return s.UNSIGNED_INT;if(n===zn)return s.FLOAT;if(n===nn)return s.HALF_FLOAT;if(n===_p)return s.ALPHA;if(n===Mp)return s.RGB;if(n===fn)return s.RGBA;if(n===Ui)return s.DEPTH_COMPONENT;if(n===As)return s.DEPTH_STENCIL;if(n===cu)return s.RED;if(n===lu)return s.RED_INTEGER;if(n===Cs)return s.RG;if(n===hu)return s.RG_INTEGER;if(n===uu)return s.RGBA_INTEGER;if(n===Lo||n===No||n===Oo||n===Uo)if(a===se)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Lo)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===No)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Oo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Uo)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Lo)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===No)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Oo)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Uo)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Kl||n===$l||n===Zl||n===Jl)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===$l)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Zl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Jl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ql||n===jl||n===th||n===eh||n===nh||n===Xo||n===ih)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ql||n===jl)return a===se?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===th)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===eh)return r.COMPRESSED_R11_EAC;if(n===nh)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Xo)return r.COMPRESSED_RG11_EAC;if(n===ih)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===sh||n===rh||n===ah||n===oh||n===ch||n===lh||n===hh||n===uh||n===dh||n===fh||n===ph||n===mh||n===gh||n===vh)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===sh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===rh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===ah)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===oh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===ch)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===lh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===hh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===uh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===dh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===fh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===ph)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===mh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===gh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===vh)return a===se?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===xh||n===_h||n===Mh)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===xh)return a===se?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===_h)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Mh)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===yh||n===Sh||n===qo||n===bh)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===yh)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Sh)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===qo)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===bh)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===va?s.UNSIGNED_INT_24_8:s[n]!==void 0?s[n]:null}return{convert:e}}const Hy=`
|
|
4602
4602
|
void main() {
|
|
4603
4603
|
|
|
4604
4604
|
gl_Position = vec4( position, 1.0 );
|
|
4605
4605
|
|
|
4606
|
-
}`,
|
|
4606
|
+
}`,Gy=`
|
|
4607
4607
|
uniform sampler2DArray depthColor;
|
|
4608
4608
|
uniform float depthWidth;
|
|
4609
4609
|
uniform float depthHeight;
|
|
@@ -4622,14 +4622,14 @@ void main() {
|
|
|
4622
4622
|
|
|
4623
4623
|
}
|
|
4624
4624
|
|
|
4625
|
-
}`;class Hy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new Cp(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new De({vertexShader:By,fragmentShader:ky,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new $t(new Hi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Gy extends Ns{constructor(t,e){super();const n=this;let i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,g=null;const v=typeof XRWebGLBinding<"u",p=new Hy,m={},b=e.getContextAttributes();let E=null,M=null;const S=[],w=[],R=new Pt;let _=null;const A=new yn;A.viewport=new le;const C=new yn;C.viewport=new le;const D=[A,C],I=new V2;let V=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getHandSpace()};function O(Y){const rt=w.indexOf(Y.inputSource);if(rt===-1)return;const nt=S[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||a),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<S.length;Y++){const rt=w[Y];rt!==null&&(w[Y]=null,S[Y].disconnect(rt))}V=null,q=null,p.reset();for(const Y in m)delete m[Y];t.setRenderTarget(E),f=null,d=null,u=null,i=null,M=null,kt.stop(),n.isPresenting=!1,t.setPixelRatio(_),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&wt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&wt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(E=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",W),i.addEventListener("inputsourceschange",G),b.xrCompatible!==!0&&await e.makeXRCompatible(),_=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,Et=null;b.depth&&(Et=b.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=b.stencil?As:Ui,z=b.stencil?va:Jn);const It={colorFormat:e.RGBA8,depthFormat:Et,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(It),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new Sn(d.textureWidth,d.textureHeight,{format:fn,type:Dn,depthTexture:new Ps(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:b.stencil,colorSpace:t.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,e,nt),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Sn(f.framebufferWidth,f.framebufferHeight,{format:fn,type:Dn,colorSpace:t.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),kt.setContext(i),kt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function G(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],z=w.indexOf(nt);z>=0&&(w[z]=null,S[z].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let z=w.indexOf(nt);if(z===-1){for(let It=0;It<S.length;It++)if(It>=w.length){w.push(nt),z=It;break}else if(w[It]===null){w[It]=nt,z=It;break}if(z===-1)break}const Et=S[z];Et&&Et.connect(nt)}}const Z=new P,et=new P;function j(Y,rt,nt){Z.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const z=Z.distanceTo(et),Et=rt.projectionMatrix.elements,It=nt.projectionMatrix.elements,Tt=Et[14]/(Et[10]-1),_t=Et[14]/(Et[10]+1),Nt=(Et[9]+1)/Et[5],Ot=(Et[9]-1)/Et[5],Ut=(Et[8]-1)/Et[0],ee=(It[8]+1)/It[0],ne=Tt*Ut,Ee=Tt*ee,ve=z/(-Ut+ee),we=ve*-Ut;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(we),Y.translateZ(ve),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Et[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Ne=Tt+ve,N=_t+ve,gn=ne-we,ie=Ee+(z-we),T=Nt*_t/N*Ne,x=Ot*_t/N*Ne;Y.projectionMatrix.makePerspective(gn,ie,T,x,Ne,N),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(i===null)return;let rt=Y.near,nt=Y.far;p.texture!==null&&(p.depthNear>0&&(rt=p.depthNear),p.depthFar>0&&(nt=p.depthFar)),I.near=C.near=A.near=rt,I.far=C.far=A.far=nt,(V!==I.near||q!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),V=I.near,q=I.far),I.layers.mask=Y.layers.mask|6,A.layers.mask=I.layers.mask&-5,C.layers.mask=I.layers.mask&-3;const z=Y.parent,Et=I.cameras;it(I,z);for(let It=0;It<Et.length;It++)it(Et[It],z);Et.length===2?j(I,A,C):I.projectionMatrix.copy(A.projectionMatrix),ut(Y,I,z)};function ut(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=wr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&f===null))return 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 p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(I)},this.getCameraTexture=function(Y){return m[Y]};let Ht=null;function Jt(Y,rt){if(h=rt.getViewerPose(l||a),g=rt,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let _t=0;_t<nt.length;_t++){const Nt=nt[_t];let Ot=null;if(f!==null)Ot=f.getViewport(Nt);else{const ee=u.getViewSubImage(d,Nt);Ot=ee.viewport,_t===0&&(t.setRenderTargetTextures(M,ee.colorTexture,ee.depthStencilTexture),t.setRenderTarget(M))}let Ut=D[_t];Ut===void 0&&(Ut=new yn,Ut.layers.enable(_t),Ut.viewport=new le,D[_t]=Ut),Ut.matrix.fromArray(Nt.transform.matrix),Ut.matrix.decompose(Ut.position,Ut.quaternion,Ut.scale),Ut.projectionMatrix.fromArray(Nt.projectionMatrix),Ut.projectionMatrixInverse.copy(Ut.projectionMatrix).invert(),Ut.viewport.set(Ot.x,Ot.y,Ot.width,Ot.height),_t===0&&(I.matrix.copy(Ut.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Ut)}const Et=i.enabledFeatures;if(Et&&Et.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const _t=u.getDepthInformation(nt[0]);_t&&_t.isValid&&_t.texture&&p.init(_t,i.renderState)}if(Et&&Et.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let _t=0;_t<nt.length;_t++){const Nt=nt[_t].camera;if(Nt){let Ot=m[Nt];Ot||(Ot=new Cp,m[Nt]=Ot);const Ut=u.getCameraImage(Nt);Ot.sourceTexture=Ut}}}}for(let nt=0;nt<S.length;nt++){const z=w[nt],Et=S[nt];z!==null&&Et!==void 0&&Et.update(z,rt,l||a)}Ht&&Ht(Y,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),g=null}const kt=new Up;kt.setAnimationLoop(Jt),this.setAnimationLoop=function(Y){Ht=Y},this.dispose=function(){}}}const Vy=new Xt,Vp=new Bt;Vp.set(-1,0,0,0,1,0,0,0,1);function Wy(s,t){function e(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Pp(s)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function i(p,m,b,E,M){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?r(p,m):m.isMeshLambertMaterial?(r(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(r(p,m),u(p,m)):m.isMeshPhongMaterial?(r(p,m),h(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(r(p,m),d(p,m),m.isMeshPhysicalMaterial&&f(p,m,M)):m.isMeshMatcapMaterial?(r(p,m),g(p,m)):m.isMeshDepthMaterial?r(p,m):m.isMeshDistanceMaterial?(r(p,m),v(p,m)):m.isMeshNormalMaterial?r(p,m):m.isLineBasicMaterial?(a(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?c(p,m,b,E):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,e(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Be&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,e(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Be&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,e(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,e(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const b=t.get(m),E=b.envMap,M=b.envMapRotation;E&&(p.envMap.value=E,p.envMapRotation.value.setFromMatrix4(Vy.makeRotationFromEuler(M)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(Vp),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function a(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,b,E){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*b,p.scale.value=E*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,b){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Be&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=b.texture,p.transmissionSamplerSize.value.set(b.width,b.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function v(p,m){const b=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(b.matrixWorld),p.nearDistance.value=b.shadow.camera.near,p.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Xy(s,t,e,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const w=S.program;n.uniformBlockBinding(M,w)}function l(M,S){let w=i[M.id];w===void 0&&(p(M),w=h(M),i[M.id]=w,M.addEventListener("dispose",b));const R=S.program;n.updateUBOMapping(M,R);const _=t.render.frame;r[M.id]!==_&&(d(M),r[M.id]=_)}function h(M){const S=u();M.__bindingPointIndex=S;const w=s.createBuffer(),R=M.__size,_=M.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,_),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,S,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return zt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=i[M.id],w=M.uniforms,R=M.__cache;s.bindBuffer(s.UNIFORM_BUFFER,S);for(let _=0,A=w.length;_<A;_++){const C=w[_];if(Array.isArray(C))for(let D=0,I=C.length;D<I;D++)f(C[D],_,D,R);else f(C,_,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(M,S,w,R){if(v(M,S,w,R)===!0){const _=M.__offset,A=M.value;if(Array.isArray(A)){let C=0;for(let D=0;D<A.length;D++){const I=A[D],V=m(I);g(I,M.__data,C),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(A,M.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,w){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,w)}function v(M,S,w,R){const _=M.value,A=S+"_"+w;if(R[A]===void 0)return typeof _=="number"||typeof _=="boolean"?R[A]=_:ArrayBuffer.isView(_)?R[A]=_.slice():R[A]=_.clone(),!0;{const C=R[A];if(typeof _=="number"||typeof _=="boolean"){if(C!==_)return R[A]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(C.equals(_)===!1)return C.copy(_),!0}}return!1}function p(M){const S=M.uniforms;let w=0;const R=16;for(let A=0,C=S.length;A<C;A++){const D=Array.isArray(S[A])?S[A]:[S[A]];for(let I=0,V=D.length;I<V;I++){const q=D[I],O=Array.isArray(q.value)?q.value:[q.value];for(let W=0,G=O.length;W<G;W++){const Z=O[W],et=m(Z),j=w%R,it=j%et.boundary,ut=j+it;w+=it,ut!==0&&R-ut<et.storage&&(w+=R-ut),q.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=w,w+=et.storage}}}const _=w%R;return _>0&&(w+=R-_),M.__size=w,M.__cache={},this}function m(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?wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):wt("WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const w=a.indexOf(S.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[S.id]),delete i[S.id],delete r[S.id]}function E(){for(const M in i)s.deleteBuffer(i[M]);a=[],i={},r={}}return{bind:c,update:l,dispose:E}}const qy=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 ii=null;function Yy(){return ii===null&&(ii=new Dr(qy,16,16,Cs,nn),ii.name="DFG_LUT",ii.minFilter=ye,ii.magFilter=ye,ii.wrapS=dn,ii.wrapT=dn,ii.generateMipmaps=!1,ii.needsUpdate=!0),ii}class Ky{constructor(t={}){const{canvas:e=_1(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Dn}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const v=f,p=new Set([uu,hu,lu]),m=new Set([Dn,Jn,ga,va,au,ou]),b=new Uint32Array(4),E=new Int32Array(4),M=new P;let S=null,w=null;const R=[],_=[];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=gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,I=null,V=null,q=null,O=null;this._outputColorSpace=Rn;let W=0,G=0,Z=null,et=-1,j=null;const it=new le,ut=new le;let Ht=null;const Jt=new vt(0);let kt=0,Y=e.width,rt=e.height,nt=1,z=null,Et=null;const It=new le(0,0,Y,rt),Tt=new le(0,0,Y,rt);let _t=!1;const Nt=new _u;let Ot=!1,Ut=!1;const ee=new Xt,ne=new P,Ee=new le,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let we=!1;function Ne(){return Z===null?nt:1}let N=n;function gn(y,U){return e.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${iu}`),e.addEventListener("webglcontextlost",Ae,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",jn,!1),N===null){const U="webgl2";if(N=gn(U,y),N===null)throw gn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw zt("WebGLRenderer: "+y.message),y}let ie,T,x,F,H,K,st,ot,$,Q,ct,Rt,dt,lt,Lt,Ft,Gt,L,at,J,ht,gt,tt;function At(){ie=new Y_(N),ie.init(),ht=new zy(N,ie),T=new B_(N,ie,t,ht),x=new Uy(N,ie),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),V=N.createFramebuffer(),q=N.createFramebuffer(),O=N.createFramebuffer(),F=new Z_(N),H=new Sy,K=new Fy(N,ie,x,H,T,ht,F),st=new q_(C),ot=new tv(N),gt=new F_(N,ot),$=new K_(N,ot,F,gt),Q=new Q_(N,$,ot,gt,F),L=new J_(N,T,K),Lt=new k_(H),ct=new yy(C,st,ie,T,gt,Lt),Rt=new Wy(C,H),dt=new Ey,lt=new Cy(ie),Gt=new U_(C,st,x,Q,g,c),Ft=new Oy(C,Q,T),tt=new Xy(N,F,T,x),at=new z_(N,ie,F),J=new $_(N,ie,F),F.programs=ct.programs,C.capabilities=T,C.extensions=ie,C.properties=H,C.renderLists=dt,C.shadowMap=Ft,C.state=x,C.info=F}At(),v!==Dn&&(A=new tM(v,e.width,e.height,o,i,r));const yt=new Gy(C,N);this.xr=yt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ie.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ie.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(y){y!==void 0&&(nt=y,this.setSize(Y,rt,!1))},this.getSize=function(y){return y.set(Y,rt)},this.setSize=function(y,U,X=!0){if(yt.isPresenting){wt("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,rt=U,e.width=Math.floor(y*nt),e.height=Math.floor(U*nt),X===!0&&(e.style.width=y+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(y,U,X){Y=y,rt=U,nt=X,e.width=Math.floor(y*X),e.height=Math.floor(U*X),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===Dn){zt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){wt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(it)},this.getViewport=function(y){return y.copy(It)},this.setViewport=function(y,U,X,B){y.isVector4?It.set(y.x,y.y,y.z,y.w):It.set(y,U,X,B),x.viewport(it.copy(It).multiplyScalar(nt).round())},this.getScissor=function(y){return y.copy(Tt)},this.setScissor=function(y,U,X,B){y.isVector4?Tt.set(y.x,y.y,y.z,y.w):Tt.set(y,U,X,B),x.scissor(ut.copy(Tt).multiplyScalar(nt).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(y){x.setScissorTest(_t=y)},this.setOpaqueSort=function(y){z=y},this.setTransparentSort=function(y){Et=y},this.getClearColor=function(y){return y.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,X=!0){let B=0;if(y){let k=!1;if(Z!==null){const mt=Z.texture.format;k=p.has(mt)}if(k){const mt=Z.texture.type,Mt=m.has(mt),pt=Gt.getClearColor(),bt=Gt.getClearAlpha(),Dt=pt.r,Vt=pt.g,qt=pt.b;Mt?(b[0]=Dt,b[1]=Vt,b[2]=qt,b[3]=bt,N.clearBufferuiv(N.COLOR,0,b)):(E[0]=Dt,E[1]=Vt,E[2]=qt,E[3]=bt,N.clearBufferiv(N.COLOR,0,E))}else B|=N.COLOR_BUFFER_BIT}U&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),X&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){e.removeEventListener("webglcontextlost",Ae,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",jn,!1),Gt.dispose(),dt.dispose(),lt.dispose(),H.dispose(),st.dispose(),Q.dispose(),gt.dispose(),tt.dispose(),ct.dispose(),yt.dispose(),yt.removeEventListener("sessionstart",Ou),yt.removeEventListener("sessionend",Uu),us.stop()};function Ae(y){y.preventDefault(),Jo("WebGLRenderer: Context Lost."),D=!0}function fe(){Jo("WebGLRenderer: Context Restored."),D=!1;const y=F.autoReset,U=Ft.enabled,X=Ft.autoUpdate,B=Ft.needsUpdate,k=Ft.type;At(),F.autoReset=y,Ft.enabled=U,Ft.autoUpdate=X,Ft.needsUpdate=B,Ft.type=k}function jn(y){zt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function ti(y){const U=y.target;U.removeEventListener("dispose",ti),Tm(U)}function Tm(y){Rm(y),H.remove(y)}function Rm(y){const U=H.get(y).programs;U!==void 0&&(U.forEach(function(X){ct.releaseProgram(X)}),y.isShaderMaterial&&ct.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,X,B,k,mt){U===null&&(U=ve);const Mt=k.isMesh&&k.matrixWorld.determinantAffine()<0,pt=Pm(y,U,X,B,k);x.setMaterial(B,Mt);let bt=X.index,Dt=1;if(B.wireframe===!0){if(bt=$.getWireframeAttribute(X),bt===void 0)return;Dt=2}const Vt=X.drawRange,qt=X.attributes.position;let Ct=Vt.start*Dt,oe=(Vt.start+Vt.count)*Dt;mt!==null&&(Ct=Math.max(Ct,mt.start*Dt),oe=Math.min(oe,(mt.start+mt.count)*Dt)),bt!==null?(Ct=Math.max(Ct,0),oe=Math.min(oe,bt.count)):qt!=null&&(Ct=Math.max(Ct,0),oe=Math.min(oe,qt.count));const Ce=oe-Ct;if(Ce<0||Ce===1/0)return;gt.setup(k,B,pt,X,bt);let Te,he=at;if(bt!==null&&(Te=ot.get(bt),he=J,he.setIndex(Te)),k.isMesh)B.wireframe===!0?(x.setLineWidth(B.wireframeLinewidth*Ne()),he.setMode(N.LINES)):he.setMode(N.TRIANGLES);else if(k.isLine){let Ze=B.linewidth;Ze===void 0&&(Ze=1),x.setLineWidth(Ze*Ne()),k.isLineSegments?he.setMode(N.LINES):k.isLineLoop?he.setMode(N.LINE_LOOP):he.setMode(N.LINE_STRIP)}else k.isPoints?he.setMode(N.POINTS):k.isSprite&&he.setMode(N.TRIANGLES);if(k.isBatchedMesh)if(ie.get("WEBGL_multi_draw"))he.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Ze=k._multiDrawStarts,xt=k._multiDrawCounts,bn=k._multiDrawCount,jt=bt?ot.get(bt).bytesPerElement:1,Cn=H.get(B).currentProgram.getUniforms();for(let ei=0;ei<bn;ei++)Cn.setValue(N,"_gl_DrawID",ei),he.render(Ze[ei]/jt,xt[ei])}else if(k.isInstancedMesh)he.renderInstances(Ct,Ce,k.count);else if(X.isInstancedBufferGeometry){const Ze=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,xt=Math.min(X.instanceCount,Ze);he.renderInstances(Ct,Ce,xt)}else he.render(Ct,Ce)};function Nu(y,U,X){y.transparent===!0&&y.side===qn&&y.forceSinglePass===!1?(y.side=Be,y.needsUpdate=!0,Da(y,U,X),y.side=cs,y.needsUpdate=!0,Da(y,U,X),y.side=qn):Da(y,U,X)}this.compile=function(y,U,X=null){X===null&&(X=y),w=lt.get(X),w.init(U),_.push(w),X.traverseVisible(function(k){k.isLight&&k.layers.test(U.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),y!==X&&y.traverseVisible(function(k){k.isLight&&k.layers.test(U.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),w.setupLights();const B=new Set;return y.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const mt=k.material;if(mt)if(Array.isArray(mt))for(let Mt=0;Mt<mt.length;Mt++){const pt=mt[Mt];Nu(pt,X,k),B.add(pt)}else Nu(mt,X,k),B.add(mt)}),w=_.pop(),B},this.compileAsync=function(y,U,X=null){const B=this.compile(y,U,X);return new Promise(k=>{function mt(){if(B.forEach(function(Mt){H.get(Mt).currentProgram.isReady()&&B.delete(Mt)}),B.size===0){k(y);return}setTimeout(mt,10)}ie.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let xc=null;function Dm(y){xc&&xc(y)}function Ou(){us.stop()}function Uu(){us.start()}const us=new Up;us.setAnimationLoop(Dm),typeof self<"u"&&us.setContext(self),this.setAnimationLoop=function(y){xc=y,yt.setAnimationLoop(y),y===null?us.stop():us.start()},yt.addEventListener("sessionstart",Ou),yt.addEventListener("sessionend",Uu),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){zt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(y,U);const X=yt.enabled===!0&&yt.isPresenting===!0,B=A!==null&&(Z===null||X)&&A.begin(C,Z);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(U),U=yt.getCamera()),y.isScene===!0&&y.onBeforeRender(C,y,U,Z),w=lt.get(y,_.length),w.init(U),w.state.textureUnits=K.getTextureUnits(),_.push(w),ee.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Nt.setFromProjectionMatrix(ee,fi,U.reversedDepth),Ut=this.localClippingEnabled,Ot=Lt.init(this.clippingPlanes,Ut),S=dt.get(y,R.length),S.init(),R.push(S),yt.enabled===!0&&yt.isPresenting===!0){const Mt=C.xr.getDepthSensingMesh();Mt!==null&&_c(Mt,U,-1/0,C.sortObjects)}_c(y,U,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(z,Et,U.reversedDepth),we=yt.enabled===!1||yt.isPresenting===!1||yt.hasDepthSensing()===!1,we&&Gt.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ot===!0&&Lt.beginShadows();const k=w.state.shadowsArray;if(Ft.render(k,y,U),Ot===!0&&Lt.endShadows(),(B&&A.hasRenderPass())===!1){const Mt=S.opaque,pt=S.transmissive;if(w.setupLights(),U.isArrayCamera){const bt=U.cameras;if(pt.length>0)for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt];zu(Mt,pt,y,qt)}we&&Gt.render(y);for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt];Fu(S,y,qt,qt.viewport)}}else pt.length>0&&zu(Mt,pt,y,U),we&&Gt.render(y),Fu(S,y,U)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&A.end(C),y.isScene===!0&&y.onAfterRender(C,y,U),gt.resetDefaultState(),et=-1,j=null,_.pop(),_.length>0?(w=_[_.length-1],K.setTextureUnits(w.state.textureUnits),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function _c(y,U,X,B){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)X=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Nt.intersectsSprite(y)){B&&Ee.setFromMatrixPosition(y.matrixWorld).applyMatrix4(ee);const Mt=Q.update(y),pt=y.material;pt.visible&&S.push(y,Mt,pt,X,Ee.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Nt.intersectsObject(y))){const Mt=Q.update(y),pt=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ee.copy(y.boundingSphere.center)):(Mt.boundingSphere===null&&Mt.computeBoundingSphere(),Ee.copy(Mt.boundingSphere.center)),Ee.applyMatrix4(y.matrixWorld).applyMatrix4(ee)),Array.isArray(pt)){const bt=Mt.groups;for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt],Ct=pt[qt.materialIndex];Ct&&Ct.visible&&S.push(y,Mt,Ct,X,Ee.z,qt)}}else pt.visible&&S.push(y,Mt,pt,X,Ee.z,null)}}const mt=y.children;for(let Mt=0,pt=mt.length;Mt<pt;Mt++)_c(mt[Mt],U,X,B)}function Fu(y,U,X,B){const{opaque:k,transmissive:mt,transparent:Mt}=y;w.setupLightsView(X),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,X),B&&x.viewport(it.copy(B)),k.length>0&&Ra(k,U,X),mt.length>0&&Ra(mt,U,X),Mt.length>0&&Ra(Mt,U,X),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function zu(y,U,X,B){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){const Ct=ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new Sn(1,1,{generateMipmaps:!0,type:Ct?nn:Dn,minFilter:ws,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qt.workingColorSpace})}const mt=w.state.transmissionRenderTarget[B.id],Mt=B.viewport||it;mt.setSize(Mt.z*C.transmissionResolutionScale,Mt.w*C.transmissionResolutionScale);const pt=C.getRenderTarget(),bt=C.getActiveCubeFace(),Dt=C.getActiveMipmapLevel();C.setRenderTarget(mt),C.getClearColor(Jt),kt=C.getClearAlpha(),kt<1&&C.setClearColor(16777215,.5),C.clear(),we&&Gt.render(X);const Vt=C.toneMapping;C.toneMapping=gi;const qt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),w.setupLightsView(B),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,B),Ra(y,X,B),K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt),ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let oe=0,Ce=U.length;oe<Ce;oe++){const Te=U[oe],{object:he,geometry:Ze,material:xt,group:bn}=Te;if(xt.side===qn&&he.layers.test(B.layers)){const jt=xt.side;xt.side=Be,xt.needsUpdate=!0,Bu(he,X,B,Ze,xt,bn),xt.side=jt,xt.needsUpdate=!0,Ct=!0}}Ct===!0&&(K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt))}C.setRenderTarget(pt,bt,Dt),C.setClearColor(Jt,kt),qt!==void 0&&(B.viewport=qt),C.toneMapping=Vt}function Ra(y,U,X){const B=U.isScene===!0?U.overrideMaterial:null;for(let k=0,mt=y.length;k<mt;k++){const Mt=y[k],{object:pt,geometry:bt,group:Dt}=Mt;let Vt=Mt.material;Vt.allowOverride===!0&&B!==null&&(Vt=B),pt.layers.test(X.layers)&&Bu(pt,U,X,bt,Vt,Dt)}}function Bu(y,U,X,B,k,mt){y.onBeforeRender(C,U,X,B,k,mt),y.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(C,U,X,B,y,mt),k.transparent===!0&&k.side===qn&&k.forceSinglePass===!1?(k.side=Be,k.needsUpdate=!0,C.renderBufferDirect(X,U,B,k,y,mt),k.side=cs,k.needsUpdate=!0,C.renderBufferDirect(X,U,B,k,y,mt),k.side=qn):C.renderBufferDirect(X,U,B,k,y,mt),y.onAfterRender(C,U,X,B,k,mt)}function Da(y,U,X){U.isScene!==!0&&(U=ve);const B=H.get(y),k=w.state.lights,mt=w.state.shadowsArray,Mt=k.state.version,pt=ct.getParameters(y,k.state,mt,U,X,w.state.lightProbeGridArray),bt=ct.getProgramCacheKey(pt);let Dt=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const Vt=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=st.get(y.envMap||B.environment,Vt),B.envMapRotation=B.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Dt===void 0&&(y.addEventListener("dispose",ti),Dt=new Map,B.programs=Dt);let qt=Dt.get(bt);if(qt!==void 0){if(B.currentProgram===qt&&B.lightsStateVersion===Mt)return Hu(y,pt),qt}else pt.uniforms=ct.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,X,pt),y.onBeforeCompile(pt,C),qt=ct.acquireProgram(pt,bt),Dt.set(bt,qt),B.uniforms=pt.uniforms;const Ct=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ct.clippingPlanes=Lt.uniform),Hu(y,pt),B.needsLights=Lm(y),B.lightsStateVersion=Mt,B.needsLights&&(Ct.ambientLightColor.value=k.state.ambient,Ct.lightProbe.value=k.state.probe,Ct.directionalLights.value=k.state.directional,Ct.directionalLightShadows.value=k.state.directionalShadow,Ct.spotLights.value=k.state.spot,Ct.spotLightShadows.value=k.state.spotShadow,Ct.rectAreaLights.value=k.state.rectArea,Ct.ltc_1.value=k.state.rectAreaLTC1,Ct.ltc_2.value=k.state.rectAreaLTC2,Ct.pointLights.value=k.state.point,Ct.pointLightShadows.value=k.state.pointShadow,Ct.hemisphereLights.value=k.state.hemi,Ct.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ct.spotLightMatrix.value=k.state.spotLightMatrix,Ct.spotLightMap.value=k.state.spotLightMap,Ct.pointShadowMatrix.value=k.state.pointShadowMatrix),B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=qt,B.uniformsList=null,qt}function ku(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=zo.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function Hu(y,U){const X=H.get(y);X.outputColorSpace=U.outputColorSpace,X.batching=U.batching,X.batchingColor=U.batchingColor,X.instancing=U.instancing,X.instancingColor=U.instancingColor,X.instancingMorph=U.instancingMorph,X.skinning=U.skinning,X.morphTargets=U.morphTargets,X.morphNormals=U.morphNormals,X.morphColors=U.morphColors,X.morphTargetsCount=U.morphTargetsCount,X.numClippingPlanes=U.numClippingPlanes,X.numIntersection=U.numClipIntersection,X.vertexAlphas=U.vertexAlphas,X.vertexTangents=U.vertexTangents,X.toneMapping=U.toneMapping}function Cm(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let X=0,B=y.length;X<B;X++){const k=y[X];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Pm(y,U,X,B,k){U.isScene!==!0&&(U=ve),K.resetTextureUnits();const mt=U.fog,Mt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,pt=Z===null?C.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Qt.workingColorSpace,bt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Dt=st.get(B.envMap||Mt,bt),Vt=B.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,qt=!!X.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!X.morphAttributes.position,oe=!!X.morphAttributes.normal,Ce=!!X.morphAttributes.color;let Te=gi;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Te=C.toneMapping);const he=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ze=he!==void 0?he.length:0,xt=H.get(B),bn=w.state.lights;if(Ot===!0&&(Ut===!0||y!==j)){const pe=y===j&&B.id===et;Lt.setState(B,y,pe)}let jt=!1;B.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==bn.state.version||xt.outputColorSpace!==pt||k.isBatchedMesh&&xt.batching===!1||!k.isBatchedMesh&&xt.batching===!0||k.isBatchedMesh&&xt.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&xt.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&xt.instancing===!1||!k.isInstancedMesh&&xt.instancing===!0||k.isSkinnedMesh&&xt.skinning===!1||!k.isSkinnedMesh&&xt.skinning===!0||k.isInstancedMesh&&xt.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&xt.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&xt.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&xt.instancingMorph===!1&&k.morphTexture!==null||xt.envMap!==Dt||B.fog===!0&&xt.fog!==mt||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Lt.numPlanes||xt.numIntersection!==Lt.numIntersection)||xt.vertexAlphas!==Vt||xt.vertexTangents!==qt||xt.morphTargets!==Ct||xt.morphNormals!==oe||xt.morphColors!==Ce||xt.toneMapping!==Te||xt.morphTargetsCount!==Ze||!!xt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(jt=!0):(jt=!0,xt.__version=B.version);let Cn=xt.currentProgram;jt===!0&&(Cn=Da(B,U,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,Cn,xt));let ei=!1,Gi=!1,Os=!1;const ue=Cn.getUniforms(),Pe=xt.uniforms;if(x.useProgram(Cn.program)&&(ei=!0,Gi=!0,Os=!0),B.id!==et&&(et=B.id,Gi=!0),xt.needsLights){const pe=Cm(w.state.lightProbeGridArray,k);xt.lightProbeGrid!==pe&&(xt.lightProbeGrid=pe,Gi=!0)}if(ei||j!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ue.setValue(N,"projectionMatrix",y.projectionMatrix),ue.setValue(N,"viewMatrix",y.matrixWorldInverse);const Wi=ue.map.cameraPosition;Wi!==void 0&&Wi.setValue(N,ne.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ue.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ue.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,Gi=!0,Os=!0)}if(xt.needsLights&&(bn.state.directionalShadowMap.length>0&&ue.setValue(N,"directionalShadowMap",bn.state.directionalShadowMap,K),bn.state.spotShadowMap.length>0&&ue.setValue(N,"spotShadowMap",bn.state.spotShadowMap,K),bn.state.pointShadowMap.length>0&&ue.setValue(N,"pointShadowMap",bn.state.pointShadowMap,K)),k.isSkinnedMesh){ue.setOptional(N,k,"bindMatrix"),ue.setOptional(N,k,"bindMatrixInverse");const pe=k.skeleton;pe&&(pe.boneTexture===null&&pe.computeBoneTexture(),ue.setValue(N,"boneTexture",pe.boneTexture,K))}k.isBatchedMesh&&(ue.setOptional(N,k,"batchingTexture"),ue.setValue(N,"batchingTexture",k._matricesTexture,K),ue.setOptional(N,k,"batchingIdTexture"),ue.setValue(N,"batchingIdTexture",k._indirectTexture,K),ue.setOptional(N,k,"batchingColorTexture"),k._colorsTexture!==null&&ue.setValue(N,"batchingColorTexture",k._colorsTexture,K));const Vi=X.morphAttributes;if((Vi.position!==void 0||Vi.normal!==void 0||Vi.color!==void 0)&&L.update(k,X,Cn),(Gi||xt.receiveShadow!==k.receiveShadow)&&(xt.receiveShadow=k.receiveShadow,ue.setValue(N,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&(Pe.envMapIntensity.value=U.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=Yy()),Gi){if(ue.setValue(N,"toneMappingExposure",C.toneMappingExposure),xt.needsLights&&Im(Pe,Os),mt&&B.fog===!0&&Rt.refreshFogUniforms(Pe,mt),Rt.refreshMaterialUniforms(Pe,B,nt,rt,w.state.transmissionRenderTarget[y.id]),xt.needsLights&&xt.lightProbeGrid){const pe=xt.lightProbeGrid;Pe.probesSH.value=pe.texture,Pe.probesMin.value.copy(pe.boundingBox.min),Pe.probesMax.value.copy(pe.boundingBox.max),Pe.probesResolution.value.copy(pe.resolution)}zo.upload(N,ku(xt),Pe,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(zo.upload(N,ku(xt),Pe,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ue.setValue(N,"center",k.center),ue.setValue(N,"modelViewMatrix",k.modelViewMatrix),ue.setValue(N,"normalMatrix",k.normalMatrix),ue.setValue(N,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const pe=B.uniformsGroups;for(let Wi=0,Us=pe.length;Wi<Us;Wi++){const Gu=pe[Wi];tt.update(Gu,Cn),tt.bind(Gu,Cn)}}return Cn}function Im(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function Lm(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(y,U,X){const B=H.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(y.texture).__webglTexture=U,H.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:X,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const X=H.get(y);X.__webglFramebuffer=U,X.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,X=0){Z=y,W=U,G=X;let B=null,k=!1,mt=!1;if(y){const pt=H.get(y);if(pt.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,pt.__webglFramebuffer),it.copy(y.viewport),ut.copy(y.scissor),Ht=y.scissorTest,x.viewport(it),x.scissor(ut),x.setScissorTest(Ht),et=-1;return}else if(pt.__webglFramebuffer===void 0)K.setupRenderTarget(y);else if(pt.__hasExternalTextures)K.rebindTextures(y,H.get(y.texture).__webglTexture,H.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Vt=y.depthTexture;if(pt.__boundDepthTexture!==Vt){if(Vt!==null&&H.has(Vt)&&(y.width!==Vt.image.width||y.height!==Vt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const bt=y.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(mt=!0);const Dt=H.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Dt[U])?B=Dt[U][X]:B=Dt[U],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=H.get(y).__webglMultisampledFramebuffer:Array.isArray(Dt)?B=Dt[X]:B=Dt,it.copy(y.viewport),ut.copy(y.scissor),Ht=y.scissorTest}else it.copy(It).multiplyScalar(nt).floor(),ut.copy(Tt).multiplyScalar(nt).floor(),Ht=_t;if(X!==0&&(B=V),x.bindFramebuffer(N.FRAMEBUFFER,B)&&x.drawBuffers(y,B),x.viewport(it),x.scissor(ut),x.setScissorTest(Ht),k){const pt=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,pt.__webglTexture,X)}else if(mt){const pt=U;for(let bt=0;bt<y.textures.length;bt++){const Dt=H.get(y.textures[bt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+bt,Dt.__webglTexture,X,pt)}}else if(y!==null&&X!==0){const pt=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pt.__webglTexture,X)}et=-1},this.readRenderTargetPixels=function(y,U,X,B,k,mt,Mt,pt=0){if(!(y&&y.isWebGLRenderTarget)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(bt=bt[Mt]),bt){x.bindFramebuffer(N.FRAMEBUFFER,bt);try{const Dt=y.textures[pt],Vt=Dt.format,qt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Vt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(qt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-B&&X>=0&&X<=y.height-k&&N.readPixels(U,X,B,k,ht.convert(Vt),ht.convert(qt),mt)}finally{const Dt=Z!==null?H.get(Z).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(y,U,X,B,k,mt,Mt,pt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(bt=bt[Mt]),bt)if(U>=0&&U<=y.width-B&&X>=0&&X<=y.height-k){x.bindFramebuffer(N.FRAMEBUFFER,bt);const Dt=y.textures[pt],Vt=Dt.format,qt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(qt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.bufferData(N.PIXEL_PACK_BUFFER,mt.byteLength,N.STREAM_READ),N.readPixels(U,X,B,k,ht.convert(Vt),ht.convert(qt),0);const oe=Z!==null?H.get(Z).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,oe);const Ce=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await M1(N,Ce,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,mt),N.deleteBuffer(Ct),N.deleteSync(Ce),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,X=0){const B=Math.pow(2,-X),k=Math.floor(y.image.width*B),mt=Math.floor(y.image.height*B),Mt=U!==null?U.x:0,pt=U!==null?U.y:0;K.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,Mt,pt,k,mt),x.unbindTexture()},this.copyTextureToTexture=function(y,U,X=null,B=null,k=0,mt=0){let Mt,pt,bt,Dt,Vt,qt,Ct,oe,Ce;const Te=y.isCompressedTexture?y.mipmaps[mt]:y.image;if(X!==null)Mt=X.max.x-X.min.x,pt=X.max.y-X.min.y,bt=X.isBox3?X.max.z-X.min.z:1,Dt=X.min.x,Vt=X.min.y,qt=X.isBox3?X.min.z:0;else{const Pe=Math.pow(2,-k);Mt=Math.floor(Te.width*Pe),pt=Math.floor(Te.height*Pe),y.isDataArrayTexture?bt=Te.depth:y.isData3DTexture?bt=Math.floor(Te.depth*Pe):bt=1,Dt=0,Vt=0,qt=0}B!==null?(Ct=B.x,oe=B.y,Ce=B.z):(Ct=0,oe=0,Ce=0);const he=ht.convert(U.format),Ze=ht.convert(U.type);let xt;U.isData3DTexture?(K.setTexture3D(U,0),xt=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(K.setTexture2DArray(U,0),xt=N.TEXTURE_2D_ARRAY):(K.setTexture2D(U,0),xt=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const bn=x.getParameter(N.UNPACK_ROW_LENGTH),jt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Cn=x.getParameter(N.UNPACK_SKIP_PIXELS),ei=x.getParameter(N.UNPACK_SKIP_ROWS),Gi=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Te.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Te.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Dt),x.pixelStorei(N.UNPACK_SKIP_ROWS,Vt),x.pixelStorei(N.UNPACK_SKIP_IMAGES,qt);const Os=y.isDataArrayTexture||y.isData3DTexture,ue=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Pe=H.get(y),Vi=H.get(U),pe=H.get(Pe.__renderTarget),Wi=H.get(Vi.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,pe.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,Wi.__webglFramebuffer);for(let Us=0;Us<bt;Us++)Os&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(y).__webglTexture,k,qt+Us),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(U).__webglTexture,mt,Ce+Us)),N.blitFramebuffer(Dt,Vt,Mt,pt,Ct,oe,Mt,pt,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||H.has(y)){const Pe=H.get(y),Vi=H.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,q),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let pe=0;pe<bt;pe++)Os?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Pe.__webglTexture,k,qt+pe):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Pe.__webglTexture,k),ue?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Vi.__webglTexture,mt,Ce+pe):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Vi.__webglTexture,mt),k!==0?N.blitFramebuffer(Dt,Vt,Mt,pt,Ct,oe,Mt,pt,N.COLOR_BUFFER_BIT,N.NEAREST):ue?N.copyTexSubImage3D(xt,mt,Ct,oe,Ce+pe,Dt,Vt,Mt,pt):N.copyTexSubImage2D(xt,mt,Ct,oe,Dt,Vt,Mt,pt);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ue?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Ze,Te.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Te.data):N.texSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Ze,Te):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Mt,pt,he,Ze,Te.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Te.width,Te.height,he,Te.data):N.texSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Mt,pt,he,Ze,Te);x.pixelStorei(N.UNPACK_ROW_LENGTH,bn),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,jt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Cn),x.pixelStorei(N.UNPACK_SKIP_ROWS,ei),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Gi),mt===0&&U.generateMipmaps&&N.generateMipmap(xt),x.unbindTexture()},this.initRenderTarget=function(y){H.get(y).__webglFramebuffer===void 0&&K.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?K.setTextureCube(y,0):y.isData3DTexture?K.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?K.setTexture2DArray(y,0):K.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){W=0,G=0,Z=null,x.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Qt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Qt._getUnpackColorSpace()}}const mc=`
|
|
4625
|
+
}`;class Vy{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new Cp(t.texture);(t.depthNear!==e.depthNear||t.depthFar!==e.depthFar)&&(this.depthNear=t.depthNear,this.depthFar=t.depthFar),this.texture=n}}getMesh(t){if(this.texture!==null&&this.mesh===null){const e=t.cameras[0].viewport,n=new De({vertexShader:Hy,fragmentShader:Gy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new $t(new Hi(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Wy extends Ns{constructor(t,e){super();const n=this;let i=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,g=null;const v=typeof XRWebGLBinding<"u",p=new Vy,m={},b=e.getContextAttributes();let E=null,M=null;const S=[],w=[],R=new Pt;let _=null;const A=new yn;A.viewport=new le;const C=new yn;C.viewport=new le;const D=[A,C],I=new X2;let V=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Pc,S[Y]=rt),rt.getHandSpace()};function O(Y){const rt=w.indexOf(Y.inputSource);if(rt===-1)return;const nt=S[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||a),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function W(){i.removeEventListener("select",O),i.removeEventListener("selectstart",O),i.removeEventListener("selectend",O),i.removeEventListener("squeeze",O),i.removeEventListener("squeezestart",O),i.removeEventListener("squeezeend",O),i.removeEventListener("end",W),i.removeEventListener("inputsourceschange",G);for(let Y=0;Y<S.length;Y++){const rt=w[Y];rt!==null&&(w[Y]=null,S[Y].disconnect(rt))}V=null,q=null,p.reset();for(const Y in m)delete m[Y];t.setRenderTarget(E),f=null,d=null,u=null,i=null,M=null,kt.stop(),n.isPresenting=!1,t.setPixelRatio(_),t.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Y){r=Y,n.isPresenting===!0&&wt("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&wt("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return l||a},this.setReferenceSpace=function(Y){l=Y},this.getBaseLayer=function(){return d!==null?d:f},this.getBinding=function(){return u===null&&v&&(u=new XRWebGLBinding(i,e)),u},this.getFrame=function(){return g},this.getSession=function(){return i},this.setSession=async function(Y){if(i=Y,i!==null){if(E=t.getRenderTarget(),i.addEventListener("select",O),i.addEventListener("selectstart",O),i.addEventListener("selectend",O),i.addEventListener("squeeze",O),i.addEventListener("squeezestart",O),i.addEventListener("squeezeend",O),i.addEventListener("end",W),i.addEventListener("inputsourceschange",G),b.xrCompatible!==!0&&await e.makeXRCompatible(),_=t.getPixelRatio(),t.getSize(R),v&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,Et=null;b.depth&&(Et=b.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=b.stencil?As:Ui,z=b.stencil?va:Jn);const It={colorFormat:e.RGBA8,depthFormat:Et,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(It),i.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new Sn(d.textureWidth,d.textureHeight,{format:fn,type:Dn,depthTexture:new Ps(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:b.stencil,colorSpace:t.outputColorSpace,samples:b.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:b.antialias,alpha:!0,depth:b.depth,stencil:b.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(i,e,nt),i.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Sn(f.framebufferWidth,f.framebufferHeight,{format:fn,type:Dn,colorSpace:t.outputColorSpace,stencilBuffer:b.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await i.requestReferenceSpace(o),kt.setContext(i),kt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(i!==null)return i.environmentBlendMode},this.getDepthTexture=function(){return p.getDepthTexture()};function G(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],z=w.indexOf(nt);z>=0&&(w[z]=null,S[z].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let z=w.indexOf(nt);if(z===-1){for(let It=0;It<S.length;It++)if(It>=w.length){w.push(nt),z=It;break}else if(w[It]===null){w[It]=nt,z=It;break}if(z===-1)break}const Et=S[z];Et&&Et.connect(nt)}}const Z=new P,et=new P;function j(Y,rt,nt){Z.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const z=Z.distanceTo(et),Et=rt.projectionMatrix.elements,It=nt.projectionMatrix.elements,Tt=Et[14]/(Et[10]-1),_t=Et[14]/(Et[10]+1),Nt=(Et[9]+1)/Et[5],Ot=(Et[9]-1)/Et[5],Ut=(Et[8]-1)/Et[0],ee=(It[8]+1)/It[0],ne=Tt*Ut,Ee=Tt*ee,ve=z/(-Ut+ee),we=ve*-Ut;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(we),Y.translateZ(ve),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),Et[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const Oe=Tt+ve,N=_t+ve,gn=ne-we,ie=Ee+(z-we),T=Nt*_t/N*Oe,x=Ot*_t/N*Oe;Y.projectionMatrix.makePerspective(gn,ie,T,x,Oe,N),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(i===null)return;let rt=Y.near,nt=Y.far;p.texture!==null&&(p.depthNear>0&&(rt=p.depthNear),p.depthFar>0&&(nt=p.depthFar)),I.near=C.near=A.near=rt,I.far=C.far=A.far=nt,(V!==I.near||q!==I.far)&&(i.updateRenderState({depthNear:I.near,depthFar:I.far}),V=I.near,q=I.far),I.layers.mask=Y.layers.mask|6,A.layers.mask=I.layers.mask&-5,C.layers.mask=I.layers.mask&-3;const z=Y.parent,Et=I.cameras;it(I,z);for(let It=0;It<Et.length;It++)it(Et[It],z);Et.length===2?j(I,A,C):I.projectionMatrix.copy(A.projectionMatrix),ut(Y,I,z)};function ut(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=wr*2*Math.atan(1/Y.projectionMatrix.elements[5]),Y.zoom=1)}this.getCamera=function(){return I},this.getFoveation=function(){if(!(d===null&&f===null))return 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 p.texture!==null},this.getDepthSensingMesh=function(){return p.getMesh(I)},this.getCameraTexture=function(Y){return m[Y]};let Ht=null;function Jt(Y,rt){if(h=rt.getViewerPose(l||a),g=rt,h!==null){const nt=h.views;f!==null&&(t.setRenderTargetFramebuffer(M,f.framebuffer),t.setRenderTarget(M));let z=!1;nt.length!==I.cameras.length&&(I.cameras.length=0,z=!0);for(let _t=0;_t<nt.length;_t++){const Nt=nt[_t];let Ot=null;if(f!==null)Ot=f.getViewport(Nt);else{const ee=u.getViewSubImage(d,Nt);Ot=ee.viewport,_t===0&&(t.setRenderTargetTextures(M,ee.colorTexture,ee.depthStencilTexture),t.setRenderTarget(M))}let Ut=D[_t];Ut===void 0&&(Ut=new yn,Ut.layers.enable(_t),Ut.viewport=new le,D[_t]=Ut),Ut.matrix.fromArray(Nt.transform.matrix),Ut.matrix.decompose(Ut.position,Ut.quaternion,Ut.scale),Ut.projectionMatrix.fromArray(Nt.projectionMatrix),Ut.projectionMatrixInverse.copy(Ut.projectionMatrix).invert(),Ut.viewport.set(Ot.x,Ot.y,Ot.width,Ot.height),_t===0&&(I.matrix.copy(Ut.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Ut)}const Et=i.enabledFeatures;if(Et&&Et.includes("depth-sensing")&&i.depthUsage=="gpu-optimized"&&v){u=n.getBinding();const _t=u.getDepthInformation(nt[0]);_t&&_t.isValid&&_t.texture&&p.init(_t,i.renderState)}if(Et&&Et.includes("camera-access")&&v){t.state.unbindTexture(),u=n.getBinding();for(let _t=0;_t<nt.length;_t++){const Nt=nt[_t].camera;if(Nt){let Ot=m[Nt];Ot||(Ot=new Cp,m[Nt]=Ot);const Ut=u.getCameraImage(Nt);Ot.sourceTexture=Ut}}}}for(let nt=0;nt<S.length;nt++){const z=w[nt],Et=S[nt];z!==null&&Et!==void 0&&Et.update(z,rt,l||a)}Ht&&Ht(Y,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),g=null}const kt=new Up;kt.setAnimationLoop(Jt),this.setAnimationLoop=function(Y){Ht=Y},this.dispose=function(){}}}const Xy=new Xt,Vp=new Bt;Vp.set(-1,0,0,0,1,0,0,0,1);function qy(s,t){function e(p,m){p.matrixAutoUpdate===!0&&p.updateMatrix(),m.value.copy(p.matrix)}function n(p,m){m.color.getRGB(p.fogColor.value,Pp(s)),m.isFog?(p.fogNear.value=m.near,p.fogFar.value=m.far):m.isFogExp2&&(p.fogDensity.value=m.density)}function i(p,m,b,E,M){m.isNodeMaterial?m.uniformsNeedUpdate=!1:m.isMeshBasicMaterial?r(p,m):m.isMeshLambertMaterial?(r(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshToonMaterial?(r(p,m),u(p,m)):m.isMeshPhongMaterial?(r(p,m),h(p,m),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)):m.isMeshStandardMaterial?(r(p,m),d(p,m),m.isMeshPhysicalMaterial&&f(p,m,M)):m.isMeshMatcapMaterial?(r(p,m),g(p,m)):m.isMeshDepthMaterial?r(p,m):m.isMeshDistanceMaterial?(r(p,m),v(p,m)):m.isMeshNormalMaterial?r(p,m):m.isLineBasicMaterial?(a(p,m),m.isLineDashedMaterial&&o(p,m)):m.isPointsMaterial?c(p,m,b,E):m.isSpriteMaterial?l(p,m):m.isShadowMaterial?(p.color.value.copy(m.color),p.opacity.value=m.opacity):m.isShaderMaterial&&(m.uniformsNeedUpdate=!1)}function r(p,m){p.opacity.value=m.opacity,m.color&&p.diffuse.value.copy(m.color),m.emissive&&p.emissive.value.copy(m.emissive).multiplyScalar(m.emissiveIntensity),m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.bumpMap&&(p.bumpMap.value=m.bumpMap,e(m.bumpMap,p.bumpMapTransform),p.bumpScale.value=m.bumpScale,m.side===Be&&(p.bumpScale.value*=-1)),m.normalMap&&(p.normalMap.value=m.normalMap,e(m.normalMap,p.normalMapTransform),p.normalScale.value.copy(m.normalScale),m.side===Be&&p.normalScale.value.negate()),m.displacementMap&&(p.displacementMap.value=m.displacementMap,e(m.displacementMap,p.displacementMapTransform),p.displacementScale.value=m.displacementScale,p.displacementBias.value=m.displacementBias),m.emissiveMap&&(p.emissiveMap.value=m.emissiveMap,e(m.emissiveMap,p.emissiveMapTransform)),m.specularMap&&(p.specularMap.value=m.specularMap,e(m.specularMap,p.specularMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest);const b=t.get(m),E=b.envMap,M=b.envMapRotation;E&&(p.envMap.value=E,p.envMapRotation.value.setFromMatrix4(Xy.makeRotationFromEuler(M)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&p.envMapRotation.value.premultiply(Vp),p.reflectivity.value=m.reflectivity,p.ior.value=m.ior,p.refractionRatio.value=m.refractionRatio),m.lightMap&&(p.lightMap.value=m.lightMap,p.lightMapIntensity.value=m.lightMapIntensity,e(m.lightMap,p.lightMapTransform)),m.aoMap&&(p.aoMap.value=m.aoMap,p.aoMapIntensity.value=m.aoMapIntensity,e(m.aoMap,p.aoMapTransform))}function a(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform))}function o(p,m){p.dashSize.value=m.dashSize,p.totalSize.value=m.dashSize+m.gapSize,p.scale.value=m.scale}function c(p,m,b,E){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.size.value=m.size*b,p.scale.value=E*.5,m.map&&(p.map.value=m.map,e(m.map,p.uvTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function l(p,m){p.diffuse.value.copy(m.color),p.opacity.value=m.opacity,p.rotation.value=m.rotation,m.map&&(p.map.value=m.map,e(m.map,p.mapTransform)),m.alphaMap&&(p.alphaMap.value=m.alphaMap,e(m.alphaMap,p.alphaMapTransform)),m.alphaTest>0&&(p.alphaTest.value=m.alphaTest)}function h(p,m){p.specular.value.copy(m.specular),p.shininess.value=Math.max(m.shininess,1e-4)}function u(p,m){m.gradientMap&&(p.gradientMap.value=m.gradientMap)}function d(p,m){p.metalness.value=m.metalness,m.metalnessMap&&(p.metalnessMap.value=m.metalnessMap,e(m.metalnessMap,p.metalnessMapTransform)),p.roughness.value=m.roughness,m.roughnessMap&&(p.roughnessMap.value=m.roughnessMap,e(m.roughnessMap,p.roughnessMapTransform)),m.envMap&&(p.envMapIntensity.value=m.envMapIntensity)}function f(p,m,b){p.ior.value=m.ior,m.sheen>0&&(p.sheenColor.value.copy(m.sheenColor).multiplyScalar(m.sheen),p.sheenRoughness.value=m.sheenRoughness,m.sheenColorMap&&(p.sheenColorMap.value=m.sheenColorMap,e(m.sheenColorMap,p.sheenColorMapTransform)),m.sheenRoughnessMap&&(p.sheenRoughnessMap.value=m.sheenRoughnessMap,e(m.sheenRoughnessMap,p.sheenRoughnessMapTransform))),m.clearcoat>0&&(p.clearcoat.value=m.clearcoat,p.clearcoatRoughness.value=m.clearcoatRoughness,m.clearcoatMap&&(p.clearcoatMap.value=m.clearcoatMap,e(m.clearcoatMap,p.clearcoatMapTransform)),m.clearcoatRoughnessMap&&(p.clearcoatRoughnessMap.value=m.clearcoatRoughnessMap,e(m.clearcoatRoughnessMap,p.clearcoatRoughnessMapTransform)),m.clearcoatNormalMap&&(p.clearcoatNormalMap.value=m.clearcoatNormalMap,e(m.clearcoatNormalMap,p.clearcoatNormalMapTransform),p.clearcoatNormalScale.value.copy(m.clearcoatNormalScale),m.side===Be&&p.clearcoatNormalScale.value.negate())),m.dispersion>0&&(p.dispersion.value=m.dispersion),m.iridescence>0&&(p.iridescence.value=m.iridescence,p.iridescenceIOR.value=m.iridescenceIOR,p.iridescenceThicknessMinimum.value=m.iridescenceThicknessRange[0],p.iridescenceThicknessMaximum.value=m.iridescenceThicknessRange[1],m.iridescenceMap&&(p.iridescenceMap.value=m.iridescenceMap,e(m.iridescenceMap,p.iridescenceMapTransform)),m.iridescenceThicknessMap&&(p.iridescenceThicknessMap.value=m.iridescenceThicknessMap,e(m.iridescenceThicknessMap,p.iridescenceThicknessMapTransform))),m.transmission>0&&(p.transmission.value=m.transmission,p.transmissionSamplerMap.value=b.texture,p.transmissionSamplerSize.value.set(b.width,b.height),m.transmissionMap&&(p.transmissionMap.value=m.transmissionMap,e(m.transmissionMap,p.transmissionMapTransform)),p.thickness.value=m.thickness,m.thicknessMap&&(p.thicknessMap.value=m.thicknessMap,e(m.thicknessMap,p.thicknessMapTransform)),p.attenuationDistance.value=m.attenuationDistance,p.attenuationColor.value.copy(m.attenuationColor)),m.anisotropy>0&&(p.anisotropyVector.value.set(m.anisotropy*Math.cos(m.anisotropyRotation),m.anisotropy*Math.sin(m.anisotropyRotation)),m.anisotropyMap&&(p.anisotropyMap.value=m.anisotropyMap,e(m.anisotropyMap,p.anisotropyMapTransform))),p.specularIntensity.value=m.specularIntensity,p.specularColor.value.copy(m.specularColor),m.specularColorMap&&(p.specularColorMap.value=m.specularColorMap,e(m.specularColorMap,p.specularColorMapTransform)),m.specularIntensityMap&&(p.specularIntensityMap.value=m.specularIntensityMap,e(m.specularIntensityMap,p.specularIntensityMapTransform))}function g(p,m){m.matcap&&(p.matcap.value=m.matcap)}function v(p,m){const b=t.get(m).light;p.referencePosition.value.setFromMatrixPosition(b.matrixWorld),p.nearDistance.value=b.shadow.camera.near,p.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:i}}function Yy(s,t,e,n){let i={},r={},a=[];const o=s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const w=S.program;n.uniformBlockBinding(M,w)}function l(M,S){let w=i[M.id];w===void 0&&(p(M),w=h(M),i[M.id]=w,M.addEventListener("dispose",b));const R=S.program;n.updateUBOMapping(M,R);const _=t.render.frame;r[M.id]!==_&&(d(M),r[M.id]=_)}function h(M){const S=u();M.__bindingPointIndex=S;const w=s.createBuffer(),R=M.__size,_=M.usage;return s.bindBuffer(s.UNIFORM_BUFFER,w),s.bufferData(s.UNIFORM_BUFFER,R,_),s.bindBuffer(s.UNIFORM_BUFFER,null),s.bindBufferBase(s.UNIFORM_BUFFER,S,w),w}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return zt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=i[M.id],w=M.uniforms,R=M.__cache;s.bindBuffer(s.UNIFORM_BUFFER,S);for(let _=0,A=w.length;_<A;_++){const C=w[_];if(Array.isArray(C))for(let D=0,I=C.length;D<I;D++)f(C[D],_,D,R);else f(C,_,0,R)}s.bindBuffer(s.UNIFORM_BUFFER,null)}function f(M,S,w,R){if(v(M,S,w,R)===!0){const _=M.__offset,A=M.value;if(Array.isArray(A)){let C=0;for(let D=0;D<A.length;D++){const I=A[D],V=m(I);g(I,M.__data,C),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(C+=V.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(A,M.__data,0);s.bufferSubData(s.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,w){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,w)}function v(M,S,w,R){const _=M.value,A=S+"_"+w;if(R[A]===void 0)return typeof _=="number"||typeof _=="boolean"?R[A]=_:ArrayBuffer.isView(_)?R[A]=_.slice():R[A]=_.clone(),!0;{const C=R[A];if(typeof _=="number"||typeof _=="boolean"){if(C!==_)return R[A]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(C.equals(_)===!1)return C.copy(_),!0}}return!1}function p(M){const S=M.uniforms;let w=0;const R=16;for(let A=0,C=S.length;A<C;A++){const D=Array.isArray(S[A])?S[A]:[S[A]];for(let I=0,V=D.length;I<V;I++){const q=D[I],O=Array.isArray(q.value)?q.value:[q.value];for(let W=0,G=O.length;W<G;W++){const Z=O[W],et=m(Z),j=w%R,it=j%et.boundary,ut=j+it;w+=it,ut!==0&&R-ut<et.storage&&(w+=R-ut),q.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=w,w+=et.storage}}}const _=w%R;return _>0&&(w+=R-_),M.__size=w,M.__cache={},this}function m(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?wt("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):wt("WebGLRenderer: Unsupported uniform value type.",M),S}function b(M){const S=M.target;S.removeEventListener("dispose",b);const w=a.indexOf(S.__bindingPointIndex);a.splice(w,1),s.deleteBuffer(i[S.id]),delete i[S.id],delete r[S.id]}function E(){for(const M in i)s.deleteBuffer(i[M]);a=[],i={},r={}}return{bind:c,update:l,dispose:E}}const Ky=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 ii=null;function $y(){return ii===null&&(ii=new Dr(Ky,16,16,Cs,nn),ii.name="DFG_LUT",ii.minFilter=ye,ii.magFilter=ye,ii.wrapS=dn,ii.wrapT=dn,ii.generateMipmaps=!1,ii.needsUpdate=!0),ii}class Zy{constructor(t={}){const{canvas:e=y1(),context:n=null,depth:i=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:c=!0,preserveDrawingBuffer:l=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:f=Dn}=t;this.isWebGLRenderer=!0;let g;if(n!==null){if(typeof WebGLRenderingContext<"u"&&n instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");g=n.getContextAttributes().alpha}else g=a;const v=f,p=new Set([uu,hu,lu]),m=new Set([Dn,Jn,ga,va,au,ou]),b=new Uint32Array(4),E=new Int32Array(4),M=new P;let S=null,w=null;const R=[],_=[];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=gi,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const C=this;let D=!1,I=null,V=null,q=null,O=null;this._outputColorSpace=Rn;let W=0,G=0,Z=null,et=-1,j=null;const it=new le,ut=new le;let Ht=null;const Jt=new vt(0);let kt=0,Y=e.width,rt=e.height,nt=1,z=null,Et=null;const It=new le(0,0,Y,rt),Tt=new le(0,0,Y,rt);let _t=!1;const Nt=new _u;let Ot=!1,Ut=!1;const ee=new Xt,ne=new P,Ee=new le,ve={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let we=!1;function Oe(){return Z===null?nt:1}let N=n;function gn(y,U){return e.getContext(y,U)}try{const y={alpha:!0,depth:i,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${iu}`),e.addEventListener("webglcontextlost",Ae,!1),e.addEventListener("webglcontextrestored",fe,!1),e.addEventListener("webglcontextcreationerror",jn,!1),N===null){const U="webgl2";if(N=gn(U,y),N===null)throw gn(U)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw zt("WebGLRenderer: "+y.message),y}let ie,T,x,F,H,K,st,ot,$,Q,ct,Rt,dt,lt,Lt,Ft,Gt,L,at,J,ht,gt,tt;function At(){ie=new $_(N),ie.init(),ht=new ky(N,ie),T=new H_(N,ie,t,ht),x=new zy(N,ie),T.reversedDepthBuffer&&d&&x.buffers.depth.setReversed(!0),V=N.createFramebuffer(),q=N.createFramebuffer(),O=N.createFramebuffer(),F=new Q_(N),H=new Ey,K=new By(N,ie,x,H,T,ht,F),st=new K_(C),ot=new nv(N),gt=new B_(N,ot),$=new Z_(N,ot,F,gt),Q=new tM(N,$,ot,gt,F),L=new j_(N,T,K),Lt=new G_(H),ct=new by(C,st,ie,T,gt,Lt),Rt=new qy(C,H),dt=new Ay,lt=new Iy(ie),Gt=new z_(C,st,x,Q,g,c),Ft=new Fy(C,Q,T),tt=new Yy(N,F,T,x),at=new k_(N,ie,F),J=new J_(N,ie,F),F.programs=ct.programs,C.capabilities=T,C.extensions=ie,C.properties=H,C.renderLists=dt,C.shadowMap=Ft,C.state=x,C.info=F}At(),v!==Dn&&(A=new nM(v,e.width,e.height,o,i,r));const yt=new Wy(C,N);this.xr=yt,this.getContext=function(){return N},this.getContextAttributes=function(){return N.getContextAttributes()},this.forceContextLoss=function(){const y=ie.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=ie.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return nt},this.setPixelRatio=function(y){y!==void 0&&(nt=y,this.setSize(Y,rt,!1))},this.getSize=function(y){return y.set(Y,rt)},this.setSize=function(y,U,X=!0){if(yt.isPresenting){wt("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,rt=U,e.width=Math.floor(y*nt),e.height=Math.floor(U*nt),X===!0&&(e.style.width=y+"px",e.style.height=U+"px"),A!==null&&A.setSize(e.width,e.height),this.setViewport(0,0,y,U)},this.getDrawingBufferSize=function(y){return y.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(y,U,X){Y=y,rt=U,nt=X,e.width=Math.floor(y*X),e.height=Math.floor(U*X),this.setViewport(0,0,y,U)},this.setEffects=function(y){if(v===Dn){zt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let U=0;U<y.length;U++)if(y[U].isOutputPass===!0){wt("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}A.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(it)},this.getViewport=function(y){return y.copy(It)},this.setViewport=function(y,U,X,B){y.isVector4?It.set(y.x,y.y,y.z,y.w):It.set(y,U,X,B),x.viewport(it.copy(It).multiplyScalar(nt).round())},this.getScissor=function(y){return y.copy(Tt)},this.setScissor=function(y,U,X,B){y.isVector4?Tt.set(y.x,y.y,y.z,y.w):Tt.set(y,U,X,B),x.scissor(ut.copy(Tt).multiplyScalar(nt).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(y){x.setScissorTest(_t=y)},this.setOpaqueSort=function(y){z=y},this.setTransparentSort=function(y){Et=y},this.getClearColor=function(y){return y.copy(Gt.getClearColor())},this.setClearColor=function(){Gt.setClearColor(...arguments)},this.getClearAlpha=function(){return Gt.getClearAlpha()},this.setClearAlpha=function(){Gt.setClearAlpha(...arguments)},this.clear=function(y=!0,U=!0,X=!0){let B=0;if(y){let k=!1;if(Z!==null){const mt=Z.texture.format;k=p.has(mt)}if(k){const mt=Z.texture.type,Mt=m.has(mt),pt=Gt.getClearColor(),bt=Gt.getClearAlpha(),Dt=pt.r,Vt=pt.g,qt=pt.b;Mt?(b[0]=Dt,b[1]=Vt,b[2]=qt,b[3]=bt,N.clearBufferuiv(N.COLOR,0,b)):(E[0]=Dt,E[1]=Vt,E[2]=qt,E[3]=bt,N.clearBufferiv(N.COLOR,0,E))}else B|=N.COLOR_BUFFER_BIT}U&&(B|=N.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),X&&(B|=N.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&N.clear(B)},this.clearColor=function(){this.clear(!0,!1,!1)},this.clearDepth=function(){this.clear(!1,!0,!1)},this.clearStencil=function(){this.clear(!1,!1,!0)},this.setNodesHandler=function(y){y.setRenderer(this),I=y},this.dispose=function(){e.removeEventListener("webglcontextlost",Ae,!1),e.removeEventListener("webglcontextrestored",fe,!1),e.removeEventListener("webglcontextcreationerror",jn,!1),Gt.dispose(),dt.dispose(),lt.dispose(),H.dispose(),st.dispose(),Q.dispose(),gt.dispose(),tt.dispose(),ct.dispose(),yt.dispose(),yt.removeEventListener("sessionstart",Ou),yt.removeEventListener("sessionend",Uu),us.stop()};function Ae(y){y.preventDefault(),Jo("WebGLRenderer: Context Lost."),D=!0}function fe(){Jo("WebGLRenderer: Context Restored."),D=!1;const y=F.autoReset,U=Ft.enabled,X=Ft.autoUpdate,B=Ft.needsUpdate,k=Ft.type;At(),F.autoReset=y,Ft.enabled=U,Ft.autoUpdate=X,Ft.needsUpdate=B,Ft.type=k}function jn(y){zt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function ti(y){const U=y.target;U.removeEventListener("dispose",ti),Dm(U)}function Dm(y){Cm(y),H.remove(y)}function Cm(y){const U=H.get(y).programs;U!==void 0&&(U.forEach(function(X){ct.releaseProgram(X)}),y.isShaderMaterial&&ct.releaseShaderCache(y))}this.renderBufferDirect=function(y,U,X,B,k,mt){U===null&&(U=ve);const Mt=k.isMesh&&k.matrixWorld.determinantAffine()<0,pt=Lm(y,U,X,B,k);x.setMaterial(B,Mt);let bt=X.index,Dt=1;if(B.wireframe===!0){if(bt=$.getWireframeAttribute(X),bt===void 0)return;Dt=2}const Vt=X.drawRange,qt=X.attributes.position;let Ct=Vt.start*Dt,oe=(Vt.start+Vt.count)*Dt;mt!==null&&(Ct=Math.max(Ct,mt.start*Dt),oe=Math.min(oe,(mt.start+mt.count)*Dt)),bt!==null?(Ct=Math.max(Ct,0),oe=Math.min(oe,bt.count)):qt!=null&&(Ct=Math.max(Ct,0),oe=Math.min(oe,qt.count));const Ce=oe-Ct;if(Ce<0||Ce===1/0)return;gt.setup(k,B,pt,X,bt);let Te,he=at;if(bt!==null&&(Te=ot.get(bt),he=J,he.setIndex(Te)),k.isMesh)B.wireframe===!0?(x.setLineWidth(B.wireframeLinewidth*Oe()),he.setMode(N.LINES)):he.setMode(N.TRIANGLES);else if(k.isLine){let Ze=B.linewidth;Ze===void 0&&(Ze=1),x.setLineWidth(Ze*Oe()),k.isLineSegments?he.setMode(N.LINES):k.isLineLoop?he.setMode(N.LINE_LOOP):he.setMode(N.LINE_STRIP)}else k.isPoints?he.setMode(N.POINTS):k.isSprite&&he.setMode(N.TRIANGLES);if(k.isBatchedMesh)if(ie.get("WEBGL_multi_draw"))he.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Ze=k._multiDrawStarts,xt=k._multiDrawCounts,bn=k._multiDrawCount,jt=bt?ot.get(bt).bytesPerElement:1,Cn=H.get(B).currentProgram.getUniforms();for(let ei=0;ei<bn;ei++)Cn.setValue(N,"_gl_DrawID",ei),he.render(Ze[ei]/jt,xt[ei])}else if(k.isInstancedMesh)he.renderInstances(Ct,Ce,k.count);else if(X.isInstancedBufferGeometry){const Ze=X._maxInstanceCount!==void 0?X._maxInstanceCount:1/0,xt=Math.min(X.instanceCount,Ze);he.renderInstances(Ct,Ce,xt)}else he.render(Ct,Ce)};function Nu(y,U,X){y.transparent===!0&&y.side===qn&&y.forceSinglePass===!1?(y.side=Be,y.needsUpdate=!0,Da(y,U,X),y.side=cs,y.needsUpdate=!0,Da(y,U,X),y.side=qn):Da(y,U,X)}this.compile=function(y,U,X=null){X===null&&(X=y),w=lt.get(X),w.init(U),_.push(w),X.traverseVisible(function(k){k.isLight&&k.layers.test(U.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),y!==X&&y.traverseVisible(function(k){k.isLight&&k.layers.test(U.layers)&&(w.pushLight(k),k.castShadow&&w.pushShadow(k))}),w.setupLights();const B=new Set;return y.traverse(function(k){if(!(k.isMesh||k.isPoints||k.isLine||k.isSprite))return;const mt=k.material;if(mt)if(Array.isArray(mt))for(let Mt=0;Mt<mt.length;Mt++){const pt=mt[Mt];Nu(pt,X,k),B.add(pt)}else Nu(mt,X,k),B.add(mt)}),w=_.pop(),B},this.compileAsync=function(y,U,X=null){const B=this.compile(y,U,X);return new Promise(k=>{function mt(){if(B.forEach(function(Mt){H.get(Mt).currentProgram.isReady()&&B.delete(Mt)}),B.size===0){k(y);return}setTimeout(mt,10)}ie.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let xc=null;function Pm(y){xc&&xc(y)}function Ou(){us.stop()}function Uu(){us.start()}const us=new Up;us.setAnimationLoop(Pm),typeof self<"u"&&us.setContext(self),this.setAnimationLoop=function(y){xc=y,yt.setAnimationLoop(y),y===null?us.stop():us.start()},yt.addEventListener("sessionstart",Ou),yt.addEventListener("sessionend",Uu),this.render=function(y,U){if(U!==void 0&&U.isCamera!==!0){zt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(D===!0)return;I!==null&&I.renderStart(y,U);const X=yt.enabled===!0&&yt.isPresenting===!0,B=A!==null&&(Z===null||X)&&A.begin(C,Z);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),U.parent===null&&U.matrixWorldAutoUpdate===!0&&U.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(A===null||A.isCompositing()===!1)&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(U),U=yt.getCamera()),y.isScene===!0&&y.onBeforeRender(C,y,U,Z),w=lt.get(y,_.length),w.init(U),w.state.textureUnits=K.getTextureUnits(),_.push(w),ee.multiplyMatrices(U.projectionMatrix,U.matrixWorldInverse),Nt.setFromProjectionMatrix(ee,fi,U.reversedDepth),Ut=this.localClippingEnabled,Ot=Lt.init(this.clippingPlanes,Ut),S=dt.get(y,R.length),S.init(),R.push(S),yt.enabled===!0&&yt.isPresenting===!0){const Mt=C.xr.getDepthSensingMesh();Mt!==null&&_c(Mt,U,-1/0,C.sortObjects)}_c(y,U,0,C.sortObjects),S.finish(),C.sortObjects===!0&&S.sort(z,Et,U.reversedDepth),we=yt.enabled===!1||yt.isPresenting===!1||yt.hasDepthSensing()===!1,we&&Gt.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ot===!0&&Lt.beginShadows();const k=w.state.shadowsArray;if(Ft.render(k,y,U),Ot===!0&&Lt.endShadows(),(B&&A.hasRenderPass())===!1){const Mt=S.opaque,pt=S.transmissive;if(w.setupLights(),U.isArrayCamera){const bt=U.cameras;if(pt.length>0)for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt];zu(Mt,pt,y,qt)}we&&Gt.render(y);for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt];Fu(S,y,qt,qt.viewport)}}else pt.length>0&&zu(Mt,pt,y,U),we&&Gt.render(y),Fu(S,y,U)}Z!==null&&G===0&&(K.updateMultisampleRenderTarget(Z),K.updateRenderTargetMipmap(Z)),B&&A.end(C),y.isScene===!0&&y.onAfterRender(C,y,U),gt.resetDefaultState(),et=-1,j=null,_.pop(),_.length>0?(w=_[_.length-1],K.setTextureUnits(w.state.textureUnits),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,w.state.camera)):w=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function _c(y,U,X,B){if(y.visible===!1)return;if(y.layers.test(U.layers)){if(y.isGroup)X=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(U);else if(y.isLightProbeGrid)w.pushLightProbeGrid(y);else if(y.isLight)w.pushLight(y),y.castShadow&&w.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Nt.intersectsSprite(y)){B&&Ee.setFromMatrixPosition(y.matrixWorld).applyMatrix4(ee);const Mt=Q.update(y),pt=y.material;pt.visible&&S.push(y,Mt,pt,X,Ee.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Nt.intersectsObject(y))){const Mt=Q.update(y),pt=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),Ee.copy(y.boundingSphere.center)):(Mt.boundingSphere===null&&Mt.computeBoundingSphere(),Ee.copy(Mt.boundingSphere.center)),Ee.applyMatrix4(y.matrixWorld).applyMatrix4(ee)),Array.isArray(pt)){const bt=Mt.groups;for(let Dt=0,Vt=bt.length;Dt<Vt;Dt++){const qt=bt[Dt],Ct=pt[qt.materialIndex];Ct&&Ct.visible&&S.push(y,Mt,Ct,X,Ee.z,qt)}}else pt.visible&&S.push(y,Mt,pt,X,Ee.z,null)}}const mt=y.children;for(let Mt=0,pt=mt.length;Mt<pt;Mt++)_c(mt[Mt],U,X,B)}function Fu(y,U,X,B){const{opaque:k,transmissive:mt,transparent:Mt}=y;w.setupLightsView(X),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,X),B&&x.viewport(it.copy(B)),k.length>0&&Ra(k,U,X),mt.length>0&&Ra(mt,U,X),Mt.length>0&&Ra(Mt,U,X),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function zu(y,U,X,B){if((X.isScene===!0?X.overrideMaterial:null)!==null)return;if(w.state.transmissionRenderTarget[B.id]===void 0){const Ct=ie.has("EXT_color_buffer_half_float")||ie.has("EXT_color_buffer_float");w.state.transmissionRenderTarget[B.id]=new Sn(1,1,{generateMipmaps:!0,type:Ct?nn:Dn,minFilter:ws,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Qt.workingColorSpace})}const mt=w.state.transmissionRenderTarget[B.id],Mt=B.viewport||it;mt.setSize(Mt.z*C.transmissionResolutionScale,Mt.w*C.transmissionResolutionScale);const pt=C.getRenderTarget(),bt=C.getActiveCubeFace(),Dt=C.getActiveMipmapLevel();C.setRenderTarget(mt),C.getClearColor(Jt),kt=C.getClearAlpha(),kt<1&&C.setClearColor(16777215,.5),C.clear(),we&&Gt.render(X);const Vt=C.toneMapping;C.toneMapping=gi;const qt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),w.setupLightsView(B),Ot===!0&&Lt.setGlobalState(C.clippingPlanes,B),Ra(y,X,B),K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt),ie.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let oe=0,Ce=U.length;oe<Ce;oe++){const Te=U[oe],{object:he,geometry:Ze,material:xt,group:bn}=Te;if(xt.side===qn&&he.layers.test(B.layers)){const jt=xt.side;xt.side=Be,xt.needsUpdate=!0,Bu(he,X,B,Ze,xt,bn),xt.side=jt,xt.needsUpdate=!0,Ct=!0}}Ct===!0&&(K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt))}C.setRenderTarget(pt,bt,Dt),C.setClearColor(Jt,kt),qt!==void 0&&(B.viewport=qt),C.toneMapping=Vt}function Ra(y,U,X){const B=U.isScene===!0?U.overrideMaterial:null;for(let k=0,mt=y.length;k<mt;k++){const Mt=y[k],{object:pt,geometry:bt,group:Dt}=Mt;let Vt=Mt.material;Vt.allowOverride===!0&&B!==null&&(Vt=B),pt.layers.test(X.layers)&&Bu(pt,U,X,bt,Vt,Dt)}}function Bu(y,U,X,B,k,mt){y.onBeforeRender(C,U,X,B,k,mt),y.modelViewMatrix.multiplyMatrices(X.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(C,U,X,B,y,mt),k.transparent===!0&&k.side===qn&&k.forceSinglePass===!1?(k.side=Be,k.needsUpdate=!0,C.renderBufferDirect(X,U,B,k,y,mt),k.side=cs,k.needsUpdate=!0,C.renderBufferDirect(X,U,B,k,y,mt),k.side=qn):C.renderBufferDirect(X,U,B,k,y,mt),y.onAfterRender(C,U,X,B,k,mt)}function Da(y,U,X){U.isScene!==!0&&(U=ve);const B=H.get(y),k=w.state.lights,mt=w.state.shadowsArray,Mt=k.state.version,pt=ct.getParameters(y,k.state,mt,U,X,w.state.lightProbeGridArray),bt=ct.getProgramCacheKey(pt);let Dt=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?U.environment:null,B.fog=U.fog;const Vt=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=st.get(y.envMap||B.environment,Vt),B.envMapRotation=B.environment!==null&&y.envMap===null?U.environmentRotation:y.envMapRotation,Dt===void 0&&(y.addEventListener("dispose",ti),Dt=new Map,B.programs=Dt);let qt=Dt.get(bt);if(qt!==void 0){if(B.currentProgram===qt&&B.lightsStateVersion===Mt)return Hu(y,pt),qt}else pt.uniforms=ct.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,X,pt),y.onBeforeCompile(pt,C),qt=ct.acquireProgram(pt,bt),Dt.set(bt,qt),B.uniforms=pt.uniforms;const Ct=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ct.clippingPlanes=Lt.uniform),Hu(y,pt),B.needsLights=Om(y),B.lightsStateVersion=Mt,B.needsLights&&(Ct.ambientLightColor.value=k.state.ambient,Ct.lightProbe.value=k.state.probe,Ct.directionalLights.value=k.state.directional,Ct.directionalLightShadows.value=k.state.directionalShadow,Ct.spotLights.value=k.state.spot,Ct.spotLightShadows.value=k.state.spotShadow,Ct.rectAreaLights.value=k.state.rectArea,Ct.ltc_1.value=k.state.rectAreaLTC1,Ct.ltc_2.value=k.state.rectAreaLTC2,Ct.pointLights.value=k.state.point,Ct.pointLightShadows.value=k.state.pointShadow,Ct.hemisphereLights.value=k.state.hemi,Ct.directionalShadowMatrix.value=k.state.directionalShadowMatrix,Ct.spotLightMatrix.value=k.state.spotLightMatrix,Ct.spotLightMap.value=k.state.spotLightMap,Ct.pointShadowMatrix.value=k.state.pointShadowMatrix),B.lightProbeGrid=w.state.lightProbeGridArray.length>0,B.currentProgram=qt,B.uniformsList=null,qt}function ku(y){if(y.uniformsList===null){const U=y.currentProgram.getUniforms();y.uniformsList=zo.seqWithValue(U.seq,y.uniforms)}return y.uniformsList}function Hu(y,U){const X=H.get(y);X.outputColorSpace=U.outputColorSpace,X.batching=U.batching,X.batchingColor=U.batchingColor,X.instancing=U.instancing,X.instancingColor=U.instancingColor,X.instancingMorph=U.instancingMorph,X.skinning=U.skinning,X.morphTargets=U.morphTargets,X.morphNormals=U.morphNormals,X.morphColors=U.morphColors,X.morphTargetsCount=U.morphTargetsCount,X.numClippingPlanes=U.numClippingPlanes,X.numIntersection=U.numClipIntersection,X.vertexAlphas=U.vertexAlphas,X.vertexTangents=U.vertexTangents,X.toneMapping=U.toneMapping}function Im(y,U){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(U.matrixWorld);for(let X=0,B=y.length;X<B;X++){const k=y[X];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Lm(y,U,X,B,k){U.isScene!==!0&&(U=ve),K.resetTextureUnits();const mt=U.fog,Mt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?U.environment:null,pt=Z===null?C.outputColorSpace:Z.isXRRenderTarget===!0?Z.texture.colorSpace:Qt.workingColorSpace,bt=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Dt=st.get(B.envMap||Mt,bt),Vt=B.vertexColors===!0&&!!X.attributes.color&&X.attributes.color.itemSize===4,qt=!!X.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!X.morphAttributes.position,oe=!!X.morphAttributes.normal,Ce=!!X.morphAttributes.color;let Te=gi;B.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Te=C.toneMapping);const he=X.morphAttributes.position||X.morphAttributes.normal||X.morphAttributes.color,Ze=he!==void 0?he.length:0,xt=H.get(B),bn=w.state.lights;if(Ot===!0&&(Ut===!0||y!==j)){const pe=y===j&&B.id===et;Lt.setState(B,y,pe)}let jt=!1;B.version===xt.__version?(xt.needsLights&&xt.lightsStateVersion!==bn.state.version||xt.outputColorSpace!==pt||k.isBatchedMesh&&xt.batching===!1||!k.isBatchedMesh&&xt.batching===!0||k.isBatchedMesh&&xt.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&xt.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&xt.instancing===!1||!k.isInstancedMesh&&xt.instancing===!0||k.isSkinnedMesh&&xt.skinning===!1||!k.isSkinnedMesh&&xt.skinning===!0||k.isInstancedMesh&&xt.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&xt.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&xt.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&xt.instancingMorph===!1&&k.morphTexture!==null||xt.envMap!==Dt||B.fog===!0&&xt.fog!==mt||xt.numClippingPlanes!==void 0&&(xt.numClippingPlanes!==Lt.numPlanes||xt.numIntersection!==Lt.numIntersection)||xt.vertexAlphas!==Vt||xt.vertexTangents!==qt||xt.morphTargets!==Ct||xt.morphNormals!==oe||xt.morphColors!==Ce||xt.toneMapping!==Te||xt.morphTargetsCount!==Ze||!!xt.lightProbeGrid!=w.state.lightProbeGridArray.length>0)&&(jt=!0):(jt=!0,xt.__version=B.version);let Cn=xt.currentProgram;jt===!0&&(Cn=Da(B,U,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,Cn,xt));let ei=!1,Gi=!1,Os=!1;const ue=Cn.getUniforms(),Pe=xt.uniforms;if(x.useProgram(Cn.program)&&(ei=!0,Gi=!0,Os=!0),B.id!==et&&(et=B.id,Gi=!0),xt.needsLights){const pe=Im(w.state.lightProbeGridArray,k);xt.lightProbeGrid!==pe&&(xt.lightProbeGrid=pe,Gi=!0)}if(ei||j!==y){x.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ue.setValue(N,"projectionMatrix",y.projectionMatrix),ue.setValue(N,"viewMatrix",y.matrixWorldInverse);const Wi=ue.map.cameraPosition;Wi!==void 0&&Wi.setValue(N,ne.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ue.setValue(N,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ue.setValue(N,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,Gi=!0,Os=!0)}if(xt.needsLights&&(bn.state.directionalShadowMap.length>0&&ue.setValue(N,"directionalShadowMap",bn.state.directionalShadowMap,K),bn.state.spotShadowMap.length>0&&ue.setValue(N,"spotShadowMap",bn.state.spotShadowMap,K),bn.state.pointShadowMap.length>0&&ue.setValue(N,"pointShadowMap",bn.state.pointShadowMap,K)),k.isSkinnedMesh){ue.setOptional(N,k,"bindMatrix"),ue.setOptional(N,k,"bindMatrixInverse");const pe=k.skeleton;pe&&(pe.boneTexture===null&&pe.computeBoneTexture(),ue.setValue(N,"boneTexture",pe.boneTexture,K))}k.isBatchedMesh&&(ue.setOptional(N,k,"batchingTexture"),ue.setValue(N,"batchingTexture",k._matricesTexture,K),ue.setOptional(N,k,"batchingIdTexture"),ue.setValue(N,"batchingIdTexture",k._indirectTexture,K),ue.setOptional(N,k,"batchingColorTexture"),k._colorsTexture!==null&&ue.setValue(N,"batchingColorTexture",k._colorsTexture,K));const Vi=X.morphAttributes;if((Vi.position!==void 0||Vi.normal!==void 0||Vi.color!==void 0)&&L.update(k,X,Cn),(Gi||xt.receiveShadow!==k.receiveShadow)&&(xt.receiveShadow=k.receiveShadow,ue.setValue(N,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&U.environment!==null&&(Pe.envMapIntensity.value=U.environmentIntensity),Pe.dfgLUT!==void 0&&(Pe.dfgLUT.value=$y()),Gi){if(ue.setValue(N,"toneMappingExposure",C.toneMappingExposure),xt.needsLights&&Nm(Pe,Os),mt&&B.fog===!0&&Rt.refreshFogUniforms(Pe,mt),Rt.refreshMaterialUniforms(Pe,B,nt,rt,w.state.transmissionRenderTarget[y.id]),xt.needsLights&&xt.lightProbeGrid){const pe=xt.lightProbeGrid;Pe.probesSH.value=pe.texture,Pe.probesMin.value.copy(pe.boundingBox.min),Pe.probesMax.value.copy(pe.boundingBox.max),Pe.probesResolution.value.copy(pe.resolution)}zo.upload(N,ku(xt),Pe,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(zo.upload(N,ku(xt),Pe,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ue.setValue(N,"center",k.center),ue.setValue(N,"modelViewMatrix",k.modelViewMatrix),ue.setValue(N,"normalMatrix",k.normalMatrix),ue.setValue(N,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const pe=B.uniformsGroups;for(let Wi=0,Us=pe.length;Wi<Us;Wi++){const Gu=pe[Wi];tt.update(Gu,Cn),tt.bind(Gu,Cn)}}return Cn}function Nm(y,U){y.ambientLightColor.needsUpdate=U,y.lightProbe.needsUpdate=U,y.directionalLights.needsUpdate=U,y.directionalLightShadows.needsUpdate=U,y.pointLights.needsUpdate=U,y.pointLightShadows.needsUpdate=U,y.spotLights.needsUpdate=U,y.spotLightShadows.needsUpdate=U,y.rectAreaLights.needsUpdate=U,y.hemisphereLights.needsUpdate=U}function Om(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return W},this.getActiveMipmapLevel=function(){return G},this.getRenderTarget=function(){return Z},this.setRenderTargetTextures=function(y,U,X){const B=H.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),H.get(y.texture).__webglTexture=U,H.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:X,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,U){const X=H.get(y);X.__webglFramebuffer=U,X.__useDefaultFramebuffer=U===void 0},this.setRenderTarget=function(y,U=0,X=0){Z=y,W=U,G=X;let B=null,k=!1,mt=!1;if(y){const pt=H.get(y);if(pt.__useDefaultFramebuffer!==void 0){x.bindFramebuffer(N.FRAMEBUFFER,pt.__webglFramebuffer),it.copy(y.viewport),ut.copy(y.scissor),Ht=y.scissorTest,x.viewport(it),x.scissor(ut),x.setScissorTest(Ht),et=-1;return}else if(pt.__webglFramebuffer===void 0)K.setupRenderTarget(y);else if(pt.__hasExternalTextures)K.rebindTextures(y,H.get(y.texture).__webglTexture,H.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Vt=y.depthTexture;if(pt.__boundDepthTexture!==Vt){if(Vt!==null&&H.has(Vt)&&(y.width!==Vt.image.width||y.height!==Vt.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const bt=y.texture;(bt.isData3DTexture||bt.isDataArrayTexture||bt.isCompressedArrayTexture)&&(mt=!0);const Dt=H.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Dt[U])?B=Dt[U][X]:B=Dt[U],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=H.get(y).__webglMultisampledFramebuffer:Array.isArray(Dt)?B=Dt[X]:B=Dt,it.copy(y.viewport),ut.copy(y.scissor),Ht=y.scissorTest}else it.copy(It).multiplyScalar(nt).floor(),ut.copy(Tt).multiplyScalar(nt).floor(),Ht=_t;if(X!==0&&(B=V),x.bindFramebuffer(N.FRAMEBUFFER,B)&&x.drawBuffers(y,B),x.viewport(it),x.scissor(ut),x.setScissorTest(Ht),k){const pt=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_CUBE_MAP_POSITIVE_X+U,pt.__webglTexture,X)}else if(mt){const pt=U;for(let bt=0;bt<y.textures.length;bt++){const Dt=H.get(y.textures[bt]);N.framebufferTextureLayer(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0+bt,Dt.__webglTexture,X,pt)}}else if(y!==null&&X!==0){const pt=H.get(y.texture);N.framebufferTexture2D(N.FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,pt.__webglTexture,X)}et=-1},this.readRenderTargetPixels=function(y,U,X,B,k,mt,Mt,pt=0){if(!(y&&y.isWebGLRenderTarget)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let bt=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(bt=bt[Mt]),bt){x.bindFramebuffer(N.FRAMEBUFFER,bt);try{const Dt=y.textures[pt],Vt=Dt.format,qt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Vt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(qt)){zt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}U>=0&&U<=y.width-B&&X>=0&&X<=y.height-k&&N.readPixels(U,X,B,k,ht.convert(Vt),ht.convert(qt),mt)}finally{const Dt=Z!==null?H.get(Z).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,Dt)}}},this.readRenderTargetPixelsAsync=async function(y,U,X,B,k,mt,Mt,pt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let bt=H.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&Mt!==void 0&&(bt=bt[Mt]),bt)if(U>=0&&U<=y.width-B&&X>=0&&X<=y.height-k){x.bindFramebuffer(N.FRAMEBUFFER,bt);const Dt=y.textures[pt],Vt=Dt.format,qt=Dt.type;if(y.textures.length>1&&N.readBuffer(N.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Vt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(qt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=N.createBuffer();N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.bufferData(N.PIXEL_PACK_BUFFER,mt.byteLength,N.STREAM_READ),N.readPixels(U,X,B,k,ht.convert(Vt),ht.convert(qt),0);const oe=Z!==null?H.get(Z).__webglFramebuffer:null;x.bindFramebuffer(N.FRAMEBUFFER,oe);const Ce=N.fenceSync(N.SYNC_GPU_COMMANDS_COMPLETE,0);return N.flush(),await S1(N,Ce,4),N.bindBuffer(N.PIXEL_PACK_BUFFER,Ct),N.getBufferSubData(N.PIXEL_PACK_BUFFER,0,mt),N.deleteBuffer(Ct),N.deleteSync(Ce),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,U=null,X=0){const B=Math.pow(2,-X),k=Math.floor(y.image.width*B),mt=Math.floor(y.image.height*B),Mt=U!==null?U.x:0,pt=U!==null?U.y:0;K.setTexture2D(y,0),N.copyTexSubImage2D(N.TEXTURE_2D,X,0,0,Mt,pt,k,mt),x.unbindTexture()},this.copyTextureToTexture=function(y,U,X=null,B=null,k=0,mt=0){let Mt,pt,bt,Dt,Vt,qt,Ct,oe,Ce;const Te=y.isCompressedTexture?y.mipmaps[mt]:y.image;if(X!==null)Mt=X.max.x-X.min.x,pt=X.max.y-X.min.y,bt=X.isBox3?X.max.z-X.min.z:1,Dt=X.min.x,Vt=X.min.y,qt=X.isBox3?X.min.z:0;else{const Pe=Math.pow(2,-k);Mt=Math.floor(Te.width*Pe),pt=Math.floor(Te.height*Pe),y.isDataArrayTexture?bt=Te.depth:y.isData3DTexture?bt=Math.floor(Te.depth*Pe):bt=1,Dt=0,Vt=0,qt=0}B!==null?(Ct=B.x,oe=B.y,Ce=B.z):(Ct=0,oe=0,Ce=0);const he=ht.convert(U.format),Ze=ht.convert(U.type);let xt;U.isData3DTexture?(K.setTexture3D(U,0),xt=N.TEXTURE_3D):U.isDataArrayTexture||U.isCompressedArrayTexture?(K.setTexture2DArray(U,0),xt=N.TEXTURE_2D_ARRAY):(K.setTexture2D(U,0),xt=N.TEXTURE_2D),x.activeTexture(N.TEXTURE0),x.pixelStorei(N.UNPACK_FLIP_Y_WEBGL,U.flipY),x.pixelStorei(N.UNPACK_PREMULTIPLY_ALPHA_WEBGL,U.premultiplyAlpha),x.pixelStorei(N.UNPACK_ALIGNMENT,U.unpackAlignment);const bn=x.getParameter(N.UNPACK_ROW_LENGTH),jt=x.getParameter(N.UNPACK_IMAGE_HEIGHT),Cn=x.getParameter(N.UNPACK_SKIP_PIXELS),ei=x.getParameter(N.UNPACK_SKIP_ROWS),Gi=x.getParameter(N.UNPACK_SKIP_IMAGES);x.pixelStorei(N.UNPACK_ROW_LENGTH,Te.width),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,Te.height),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Dt),x.pixelStorei(N.UNPACK_SKIP_ROWS,Vt),x.pixelStorei(N.UNPACK_SKIP_IMAGES,qt);const Os=y.isDataArrayTexture||y.isData3DTexture,ue=U.isDataArrayTexture||U.isData3DTexture;if(y.isDepthTexture){const Pe=H.get(y),Vi=H.get(U),pe=H.get(Pe.__renderTarget),Wi=H.get(Vi.__renderTarget);x.bindFramebuffer(N.READ_FRAMEBUFFER,pe.__webglFramebuffer),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,Wi.__webglFramebuffer);for(let Us=0;Us<bt;Us++)Os&&(N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(y).__webglTexture,k,qt+Us),N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,H.get(U).__webglTexture,mt,Ce+Us)),N.blitFramebuffer(Dt,Vt,Mt,pt,Ct,oe,Mt,pt,N.DEPTH_BUFFER_BIT,N.NEAREST);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||H.has(y)){const Pe=H.get(y),Vi=H.get(U);x.bindFramebuffer(N.READ_FRAMEBUFFER,q),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,O);for(let pe=0;pe<bt;pe++)Os?N.framebufferTextureLayer(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Pe.__webglTexture,k,qt+pe):N.framebufferTexture2D(N.READ_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Pe.__webglTexture,k),ue?N.framebufferTextureLayer(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,Vi.__webglTexture,mt,Ce+pe):N.framebufferTexture2D(N.DRAW_FRAMEBUFFER,N.COLOR_ATTACHMENT0,N.TEXTURE_2D,Vi.__webglTexture,mt),k!==0?N.blitFramebuffer(Dt,Vt,Mt,pt,Ct,oe,Mt,pt,N.COLOR_BUFFER_BIT,N.NEAREST):ue?N.copyTexSubImage3D(xt,mt,Ct,oe,Ce+pe,Dt,Vt,Mt,pt):N.copyTexSubImage2D(xt,mt,Ct,oe,Dt,Vt,Mt,pt);x.bindFramebuffer(N.READ_FRAMEBUFFER,null),x.bindFramebuffer(N.DRAW_FRAMEBUFFER,null)}else ue?y.isDataTexture||y.isData3DTexture?N.texSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Ze,Te.data):U.isCompressedArrayTexture?N.compressedTexSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Te.data):N.texSubImage3D(xt,mt,Ct,oe,Ce,Mt,pt,bt,he,Ze,Te):y.isDataTexture?N.texSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Mt,pt,he,Ze,Te.data):y.isCompressedTexture?N.compressedTexSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Te.width,Te.height,he,Te.data):N.texSubImage2D(N.TEXTURE_2D,mt,Ct,oe,Mt,pt,he,Ze,Te);x.pixelStorei(N.UNPACK_ROW_LENGTH,bn),x.pixelStorei(N.UNPACK_IMAGE_HEIGHT,jt),x.pixelStorei(N.UNPACK_SKIP_PIXELS,Cn),x.pixelStorei(N.UNPACK_SKIP_ROWS,ei),x.pixelStorei(N.UNPACK_SKIP_IMAGES,Gi),mt===0&&U.generateMipmaps&&N.generateMipmap(xt),x.unbindTexture()},this.initRenderTarget=function(y){H.get(y).__webglFramebuffer===void 0&&K.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?K.setTextureCube(y,0):y.isData3DTexture?K.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?K.setTexture2DArray(y,0):K.setTexture2D(y,0),x.unbindTexture()},this.resetState=function(){W=0,G=0,Z=null,x.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return fi}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Qt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Qt._getUnpackColorSpace()}}const mc=`
|
|
4626
4626
|
vec3 encodeSrgb(vec3 linear) {
|
|
4627
4627
|
vec3 clamped = max(linear, vec3(0.0));
|
|
4628
4628
|
vec3 low = clamped * 12.92;
|
|
4629
4629
|
vec3 high = 1.055 * pow(clamped, vec3(1.0 / 2.4)) - 0.055;
|
|
4630
4630
|
return mix(low, high, step(vec3(0.0031308), clamped));
|
|
4631
4631
|
}
|
|
4632
|
-
`;class
|
|
4632
|
+
`;class Jy{frameTarget;filmTarget;quadScene=new uc;quadCamera=new Ir(-1,1,1,-1,0,1);addMaterial;developMaterial;quad;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.frameTarget=new Sn(this.width,this.height,{type:nn}),this.filmTarget=new Sn(this.width,this.height,{type:nn});const n=`
|
|
4633
4633
|
varying vec2 vUv;
|
|
4634
4634
|
void main() {
|
|
4635
4635
|
vUv = position.xy * 0.5 + 0.5;
|
|
@@ -4652,7 +4652,7 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
4652
4652
|
void main() {
|
|
4653
4653
|
gl_FragColor = vec4(encodeSrgb(texture2D(uFilm, vUv).rgb * uGain), 1.0);
|
|
4654
4654
|
}
|
|
4655
|
-
`,blending:mi,depthTest:!1,depthWrite:!1}),this.quad=new $t(new Hi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(t){const e=t.getRenderTarget();t.setRenderTarget(this.filmTarget),t.setClearColor(0,1),t.clear(!0,!0,!0),t.setRenderTarget(e)}add(t,e){this.addMaterial.uniforms.uShare.value=e,this.quad.material=this.addMaterial;const n=t.getRenderTarget(),i=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.filmTarget),t.render(this.quadScene,this.quadCamera),t.setRenderTarget(n),t.autoClear=i}develop(t,e=1){this.developMaterial.uniforms.uGain.value=e,this.quad.material=this.developMaterial,t.setRenderTarget(null),t.render(this.quadScene,this.quadCamera)}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const Ch=Math.PI/180,N0=180/Math.PI;function Aa(s,t,e){return Math.max(t,Math.min(e,s))}const Qi=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function ol(s,t,e){return s+(t-s)*e}function ec(s,t,e){return[ol(s[0],t[0],e),ol(s[1],t[1],e),ol(s[2],t[2],e)]}function Ph(s){const t=Math.max(Qi[0].altitudeDeg,Math.min(Qi[Qi.length-1].altitudeDeg,s));for(let n=0;n<Qi.length-1;n++){const i=Qi[n],r=Qi[n+1];if(t>=i.altitudeDeg&&t<=r.altitudeDeg){const a=(t-i.altitudeDeg)/(r.altitudeDeg-i.altitudeDeg);return{zenith:ec(i.zenith,r.zenith,a),horizon:ec(i.horizon,r.horizon,a)}}}const e=Qi[Qi.length-1];return{zenith:e.zenith,horizon:e.horizon}}const O0=-18,U0=-4,
|
|
4655
|
+
`,blending:mi,depthTest:!1,depthWrite:!1}),this.quad=new $t(new Hi(2,2),this.addMaterial),this.quadScene.add(this.quad)}get instantTarget(){return this.frameTarget}open(t){const e=t.getRenderTarget();t.setRenderTarget(this.filmTarget),t.setClearColor(0,1),t.clear(!0,!0,!0),t.setRenderTarget(e)}add(t,e){this.addMaterial.uniforms.uShare.value=e,this.quad.material=this.addMaterial;const n=t.getRenderTarget(),i=t.autoClear;t.autoClear=!1,t.setRenderTarget(this.filmTarget),t.render(this.quadScene,this.quadCamera),t.setRenderTarget(n),t.autoClear=i}develop(t,e=1){this.developMaterial.uniforms.uGain.value=e,this.quad.material=this.developMaterial,t.setRenderTarget(null),t.render(this.quadScene,this.quadCamera)}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.frameTarget.setSize(this.width,this.height),this.filmTarget.setSize(this.width,this.height)}dispose(){this.frameTarget.dispose(),this.filmTarget.dispose(),this.addMaterial.dispose(),this.developMaterial.dispose(),this.quad.geometry.dispose(),this.quadScene.clear()}}const Ch=Math.PI/180,N0=180/Math.PI;function Aa(s,t,e){return Math.max(t,Math.min(e,s))}const Qi=[{altitudeDeg:-90,zenith:[0,0,.02],horizon:[.01,.01,.03]},{altitudeDeg:-18,zenith:[.01,.01,.05],horizon:[.03,.02,.08]},{altitudeDeg:-6,zenith:[.02,.03,.12],horizon:[.25,.12,.15]},{altitudeDeg:0,zenith:[.05,.1,.35],horizon:[.9,.55,.35]},{altitudeDeg:8,zenith:[.1,.22,.55],horizon:[.82,.6,.45]},{altitudeDeg:25,zenith:[.15,.38,.78],horizon:[.76,.82,.91]},{altitudeDeg:90,zenith:[.15,.45,.9],horizon:[.7,.8,.95]}];function ol(s,t,e){return s+(t-s)*e}function ec(s,t,e){return[ol(s[0],t[0],e),ol(s[1],t[1],e),ol(s[2],t[2],e)]}function Ph(s){const t=Math.max(Qi[0].altitudeDeg,Math.min(Qi[Qi.length-1].altitudeDeg,s));for(let n=0;n<Qi.length-1;n++){const i=Qi[n],r=Qi[n+1];if(t>=i.altitudeDeg&&t<=r.altitudeDeg){const a=(t-i.altitudeDeg)/(r.altitudeDeg-i.altitudeDeg);return{zenith:ec(i.zenith,r.zenith,a),horizon:ec(i.horizon,r.horizon,a)}}}const e=Qi[Qi.length-1];return{zenith:e.zenith,horizon:e.horizon}}const O0=-18,U0=-4,Qy=1.8;function Wp(s,t=0){if(s<=O0)return Bo+t;if(s>=0)return U0+t;const e=s/O0;return Bo-(Bo-U0)*(1-e)**Qy+t}const F0=-1.5,Bo=6.5,jy=1.6;function cl(s,t=Bo){const e=Math.max(t,F0+1),n=(e-s)/(e-F0);return Aa(n,0,1)**jy}function cn(s,t,e){const n=s*Ch,i=t*Ch,r=e*Math.cos(n);return{x:r*Math.sin(i),y:e*Math.sin(n),z:-r*Math.cos(i)}}function t3(s,t,e){const n=Math.sqrt(s*s+t*t+e*e),i=n===0?0:Math.asin(Aa(t/n,-1,1))*N0,r=(Math.atan2(s,-e)*N0+360)%360;return{altitudeDeg:i,azimuthDeg:r}}function e3(s,t){const e=Math.abs(s-t)%360;return e>180?360-e:e}function n3(s,t,e,n){const i=Math.max(0,1-e3(s,e)/i3),r=Math.exp(-Math.max(0,t)/s3),a=n>0?Math.max(0,1-n/r3):Math.max(0,1-Math.abs(n+a3)/o3);return i*r*a}const i3=90,s3=12,r3=8,a3=2,o3=12;function c3(s,t,e,n){const{zenith:i,horizon:r}=Ph(n),a=Aa((s+90)/180,0,1),o=ec(r,i,a),c=n3(t,s,e,n);if(c<=0)return o;const l=Ph(n+l3).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return ec(o,h,c)}const l3=6;function ll(s){return .12+.88*s}const h3=-4;function u3(s){return Math.max(0,h3-s)}const d3=6,f3=60;function p3(s){return Math.min(f3,d3*Math.sqrt(s))}const m3=3,g3=.55;function v3(s){return g3*Aa(s/m3,0,1)}function Xp(s){const t=Math.max(s,-4),e=Math.sin(t*Ch)+.50572*Math.pow(t+6.07995,-1.6364);return Aa(1/e,1,40)}function gs(s){const t=Xp(s)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function x3(s){return M3*(Xp(Math.max(s,0))-1)}function _3(s){return Math.pow(10,-.4*x3(s))}const M3=5/37,qp=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function y3(s){return qp.findIndex(t=>s<=t.maxBrightness)}const S3=.25,z0=.3,b3=2.2;function E3(s,{phase:t,speedFactor:e},n){const r=1+S3*(z0+(1-z0)*s)*Math.sin(n*b3*e+t);return Math.min(1,Math.max(0,r))}/**
|
|
4656
4656
|
@preserve
|
|
4657
4657
|
|
|
4658
4658
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4683,11 +4683,11 @@ vec3 encodeSrgb(vec3 linear) {
|
|
|
4683
4683
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
4684
4684
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
4685
4685
|
* @license MIT
|
|
4686
|
-
*/const Au=173.1446326846693,bs=14959787069098932e-8,ae=.017453292519943295,B0=.26179938779914946,vi=57.29577951308232,Yp=3.819718634205488,b3=365.24217,k0=new Date("2000-01-01T12:00:00Z"),Ai=2*Math.PI,ji=3600*(180/Math.PI),hr=484813681109536e-20,Kp=10800*60,E3=2*Kp,H0=7292115e-11,w3=Kp/Math.PI,A3=-.17-5*Math.log10(w3),Ih=.996647180302104,T3=Ih*Ih,Lh=6378.1366,R3=Lh/bs,$p=81.30056,Tu=.0002959122082855911,Nh=2825345909524226e-22,Oh=8459715185680659e-23,Uh=1292024916781969e-23,Fh=1524358900784276e-23;function nc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function Ke(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function rr(s){return s-Math.floor(s)}function D3(s,t){const e=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*t.x+s.y*t.y+s.z*t.z)/Math.sqrt(e*n);return i<=-1?180:i>=1?0:vi*Math.acos(i)}var St;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(St||(St={}));const C3=[St.Star1,St.Star2,St.Star3,St.Star4,St.Star5,St.Star6,St.Star7,St.Star8],P3=[{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 I3(s){const t=C3.indexOf(s);return t>=0?P3[t]:null}function Ru(s){const t=I3(s);return t&&t.dist>0?t:null}var mn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(mn||(mn={}));const pi={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 L3(s){var t,e,n,i,r,a,o;const c=2e3+(s-14)/b3;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,i=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-i/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,o=n*i,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,i=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*i+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,i=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*i):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,i=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let N3=L3;function G0(s){return s+N3(s)/86400}class xr{constructor(t){if(t instanceof xr){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()-k0.getTime())/e,this.tt=G0(this.ut);return}if(Number.isFinite(t)){this.date=new Date(k0.getTime()+t*e),this.ut=t,this.tt=G0(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 xr(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new xr(this.ut+t)}}function Ve(s){return s instanceof xr?s:new xr(s)}function O3(s){function t(d){return d%E3*hr}const e=s.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),i=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Zp(s){var t=s.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var go;function Ta(s){if(!go||Math.abs(go.tt-s.tt)>1e-6){const t=O3(s),e=Zp(s),n=e+t.deps/3600;go={tt:s.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ae)/15,mobl:e,tobl:n}}return go}function U3(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[t[0],t[1]*n-t[2]*i,t[1]*i+t[2]*n]}function F3(s,t){return U3(Zp(s),t)}function z3(s){const t=s.tt/36525;function e(Tt,_t){const Nt=[];let Ot;for(Ot=0;Ot<=_t-Tt;++Ot)Nt.push(0);return{min:Tt,array:Nt}}function n(Tt,_t,Nt,Ot){const Ut=[];for(let ee=0;ee<=_t-Tt;++ee)Ut.push(e(Nt,Ot));return{min:Tt,array:Ut}}function i(Tt,_t,Nt){const Ot=Tt.array[_t-Tt.min];return Ot.array[Nt-Ot.min]}function r(Tt,_t,Nt,Ot){const Ut=Tt.array[_t-Tt.min];Ut.array[Nt-Ut.min]=Ot}let a,o,c,l,h,u,d,f,g,v,p,m,b,E,M,S,w,R,_,A,C,D,I,V=n(-6,6,1,4),q=n(-6,6,1,4);function O(Tt,_t){return i(V,Tt,_t)}function W(Tt,_t){return i(q,Tt,_t)}function G(Tt,_t,Nt){return r(V,Tt,_t,Nt)}function Z(Tt,_t,Nt){return r(q,Tt,_t,Nt)}function et(Tt,_t,Nt,Ot,Ut){Ut(Tt*Nt-_t*Ot,_t*Nt+Tt*Ot)}function j(Tt){return Math.sin(Ai*Tt)}d=t*t,g=0,I=0,p=0,m=3422.7;var it=j(.19833+.05611*t),ut=j(.27869+.04508*t),Ht=j(.16827-.36903*t),Jt=j(.34734-5.37261*t),kt=j(.10498-5.37899*t),Y=j(.42681-.41855*t),rt=j(.14943-5.37511*t);for(R=.84*it+.31*ut+14.27*Ht+7.26*Jt+.28*kt+.24*Y,_=2.94*it+.31*ut+14.27*Ht+9.34*Jt+1.12*kt+.83*Y,A=-6.4*it-1.89*Y,C=.21*it+.31*ut+14.27*Ht-88.7*Jt-15.3*kt+.24*Y-1.86*rt,D=R-A,f=-3332e-9*j(.59734-5.37261*t)-539e-9*j(.35498-5.37899*t)-64e-9*j(.39943-5.37511*t),b=Ai*rr(.60643382+1336.85522467*t-313e-8*d)+R/ji,E=Ai*rr(.37489701+1325.55240982*t+2565e-8*d)+_/ji,M=Ai*rr(.99312619+99.99735956*t-44e-8*d)+A/ji,S=Ai*rr(.25909118+1342.2278298*t-892e-8*d)+C/ji,w=Ai*rr(.82736186+1236.85308708*t-397e-8*d)+D/ji,h=1;h<=4;++h){switch(h){case 1:c=E,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=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(c)*l),Z(0,h,0),Z(1,h,Math.sin(c)*l),u=2;u<=o;++u)et(O(u-1,h),W(u-1,h),O(1,h),W(1,h),(Tt,_t)=>(G(u,h,Tt),Z(u,h,_t)));for(u=1;u<=o;++u)G(-u,h,O(u,h)),Z(-u,h,-W(u,h))}function nt(Tt,_t,Nt,Ot){for(var Ut={x:1,y:0},ee=[0,Tt,_t,Nt,Ot],ne=1;ne<=4;++ne)ee[ne]!==0&&et(Ut.x,Ut.y,O(ee[ne],ne),W(ee[ne],ne),(Ee,ve)=>(Ut.x=Ee,Ut.y=ve));return Ut}function z(Tt,_t,Nt,Ot,Ut,ee,ne,Ee){var ve=nt(Ut,ee,ne,Ee);g+=Tt*ve.y,I+=_t*ve.y,p+=Nt*ve.x,m+=Ot*ve.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 Et(Tt,_t,Nt,Ot,Ut){return Tt*nt(_t,Nt,Ot,Ut).y}v=0,v+=Et(-526.069,0,0,1,-2),v+=Et(-3.352,0,0,1,-4),v+=Et(44.297,1,0,1,-2),v+=Et(-6,1,0,1,-4),v+=Et(20.599,-1,0,1,0),v+=Et(-30.598,-1,0,1,-2),v+=Et(-24.649,-2,0,1,0),v+=Et(-2,-2,0,1,-2),v+=Et(-22.571,0,1,1,-2),v+=Et(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*t)+.31*j(.0466-125.1025*t)+.35*j(.5785-25.1042*t)+.66*j(.4591+1335.8075*t)+.64*j(.313-91.568*t)+1.14*j(.148+1331.2898*t)+.21*j(.5918+1056.5859*t)+.44*j(.5784+1322.8595*t)+.24*j(.2275-5.7374*t)+.28*j(.2965+2.6929*t)+.33*j(.3132+6.3368*t),a=S+I/ji;let It=(1.000002708+139.978*f)*(18518.511+1.189+p)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Ai*rr((b+g/ji)/Ai),geo_eclip_lat:Math.PI/(180*3600)*It,distance_au:ji*R3/(.999953253*m)}}function Jp(s,t){return[s.rot[0][0]*t[0]+s.rot[1][0]*t[1]+s.rot[2][0]*t[2],s.rot[0][1]*t[0]+s.rot[1][1]*t[1]+s.rot[2][1]*t[2],s.rot[0][2]*t[0]+s.rot[1][2]*t[1]+s.rot[2][2]*t[2]]}function ic(s,t,e){const n=Qp(t,e);return Jp(n,s)}function Qp(s,t){const e=s.tt/36525;let n=84381.406,i=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=hr,i*=hr,r*=hr,a*=hr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),g=Math.cos(a),v=g*h-l*f*d,p=g*l*c+f*d*h*c-o*f*u,m=g*l*o+f*d*h*o+c*f*u,b=-f*h-l*g*d,E=-f*l*c+g*d*h*c-o*g*u,M=-f*l*o+g*d*h*o+c*g*u,S=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(t===mn.Into2000)return new ls([[v,p,m],[b,E,M],[S,w,R]]);if(t===mn.From2000)return new ls([[v,b,S],[p,E,w],[m,M,R]]);throw"Invalid precess direction"}function B3(s){const t=.779057273264+.00273781191135448*s.ut,e=s.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let vo;function Du(s){if(!vo||vo.tt!==s.tt){const t=s.tt/36525;let e=15*Ta(s).ee;const n=B3(s);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),vo={tt:s.tt,st:r}}return vo.st}function jp(s,t){const e=s.latitude*ae,n=Math.sin(e),i=Math.cos(e),r=1/Math.hypot(i,Ih*n),a=T3*r,o=s.height/1e3,c=Lh*r+o,l=Lh*a+o,h=(15*t+s.longitude)*ae,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/bs,c*i*u/bs,l*n/bs],vel:[-H0*c*i*u*86400/bs,H0*c*i*d*86400/bs,0]}}function zh(s,t,e){const n=tm(t,e);return Jp(n,s)}function tm(s,t){const e=Ta(s),n=e.mobl*ae,i=e.tobl*ae,r=e.dpsi*hr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,v=u*c,p=h*a*c+o*l,m=h*o*c-a*l,b=u*l,E=h*a*l-o*c,M=h*o*l+a*c;if(t===mn.From2000)return new ls([[d,v,b],[f,p,E],[g,m,M]]);if(t===mn.Into2000)return new ls([[d,f,g],[v,p,m],[b,E,M]]);throw"Invalid precess direction"}function Cu(s,t,e){return e===mn.Into2000?ic(zh(s,t,e),t,e):zh(ic(s,t,e),t,e)}function k3(s,t){const e=Du(s),n=jp(t,e).pos;return Cu(n,s,mn.Into2000)}class ge{constructor(t,e,n,i){this.x=t,this.y=e,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class rs{constructor(t,e,n,i,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class Pu{constructor(t,e,n){this.lat=Ke(t),this.lon=Ke(e),this.dist=Ke(n)}}class Bh{constructor(t,e,n,i){this.ra=Ke(t),this.dec=Ke(e),this.dist=Ke(n),this.vec=i}}class ls{constructor(t){this.rot=t}}class H3{constructor(t,e,n,i){this.azimuth=Ke(t),this.altitude=Ke(e),this.ra=Ke(n),this.dec=Ke(i)}}class G3{constructor(t,e,n){this.vec=t,this.elat=Ke(e),this.elon=Ke(n)}}function em(s,t){return new ge(s[0],s[1],s[2],t)}function V3(s,t){const e=em(s,t),n=e.x*e.x+e.y*e.y,i=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Bh(0,e.z<0?-90:90,i,e)}let r=Yp*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=vi*Math.atan2(s[2],Math.sqrt(n));return new Bh(r,a,i,e)}function hl(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[n*t[0]+i*t[1],n*t[1]-i*t[0],t[2]]}function nm(s,t,e,n,i){let r=Ve(s);Iu(t),Ke(e),Ke(n);const a=Math.sin(t.latitude*ae),o=Math.cos(t.latitude*ae),c=Math.sin(t.longitude*ae),l=Math.cos(t.longitude*ae),h=Math.sin(n*ae),u=Math.cos(n*ae),d=Math.sin(e*B0),f=Math.cos(e*B0);let g=[o*l,o*c,a],v=[-a*l,-a*c,o],p=[c,-l,0];const m=-15*Du(r);let b=hl(m,g),E=hl(m,v),M=hl(m,p),S=[u*f,u*d,h];const w=S[0]*b[0]+S[1]*b[1]+S[2]*b[2],R=S[0]*E[0]+S[1]*E[1]+S[2]*E[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(R,_),C;A>0?(C=-vi*Math.atan2(_,R),C<0&&(C+=360)):C=0;let D=vi*Math.atan2(A,w),I=e,V=n;if(i){let q=D,O=fS(i,90-D);if(D-=O,O>0&&D>3e-4){const W=Math.sin(D*ae),G=Math.cos(D*ae),Z=Math.sin(q*ae),et=Math.cos(q*ae),j=[];for(let it=0;it<3;++it)j.push((S[it]-et*b[it])/Z*W+b[it]*G);A=Math.hypot(j[0],j[1]),A>0?(I=Yp*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,V=vi*Math.atan2(j[2],A)}}return new H3(C,90-D,I,V)}function Iu(s){if(!(s instanceof Lu))throw`Not an instance of the Observer class: ${s}`;if(Ke(s.latitude),Ke(s.longitude),Ke(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Lu{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,Iu(this)}}function W3(s){const t=Ve(s).AddDays(-1/Au),e=Mr(pi.Earth,t),n=[-e.x,-e.y,-e.z],[i,r,a]=Cu(n,t,mn.From2000),o=ae*Ta(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ge(i,r,a,t);return im(h,c,l)}function X3(s,t,e,n,i){Iu(e),nc(n),nc(i);const r=Ve(t),a=k3(r,e),o=$h(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Cu(c,r,mn.From2000);return V3(l,r)}function q3(s,t,e){const n=Ve(s),i=Du(n);let r=jp(t,i).pos;return em(r,n)}function im(s,t,e){const n=s.x,i=s.y*t+s.z*e,r=-s.y*e+s.z*t,a=Math.hypot(n,i);let o=0;a>0&&(o=vi*Math.atan2(i,n),o<0&&(o+=360));let c=vi*Math.atan2(r,a),l=new ge(n,i,r,s.t);return new G3(l,c,o)}function kh(s){const t=Ta(s.t),e=[s.x,s.y,s.z],n=ic(e,s.t,mn.From2000),[i,r,a]=zh(n,s.t,mn.From2000),o=new ge(i,r,a,s.t),c=t.tobl*ae;return im(o,Math.cos(c),Math.sin(c))}function Tr(s){const t=Ve(s),e=z3(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),i=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=F3(t,i),a=ic(r,t,mn.Into2000);return new ge(a[0],a[1],a[2],t)}function sm(s){const t=Ve(s),e=1e-5,n=t.AddDays(-e),i=t.AddDays(+e),r=Tr(n),a=Tr(i);return new rs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function Y3(s){const t=Ve(s),e=sm(t),n=1+$p;return new rs(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function _r(s,t,e){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=Ai),i+=o,n*=t}return i}function ul(s,t){let e=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-e*o,n=e,e*=t,++r}return i}const na=365250,Hh=0,Gh=1,Vh=2;function Wh(s){return new je(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function rm(s,t,e){const n=e*Math.cos(t),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,e*Math.sin(t)]}function Mr(s,t){const e=t.tt/na,n=_r(s[Hh],e,!0),i=_r(s[Gh],e,!1),r=_r(s[Vh],e,!1),a=rm(n,i,r);return Wh(a).ToAstroVector(t)}function Xh(s,t){const e=t/na,n=_r(s[Hh],e,!0),i=_r(s[Gh],e,!1),r=_r(s[Vh],e,!1),a=ul(s[Hh],e),o=ul(s[Gh],e),c=ul(s[Vh],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),f=+(c*u*l)-r*d*l*o-r*u*h*a,g=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,p=rm(n,i,r),m=[f/na,g/na,v/na],b=Wh(p),E=Wh(m);return new Is(t,b,E)}function xo(s,t,e,n){const i=n/(n+Tu),r=Mr(pi[e],t);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function K3(s){const t=new ge(0,0,0,s);return xo(t,s,St.Jupiter,Nh),xo(t,s,St.Saturn,Oh),xo(t,s,St.Uranus,Uh),xo(t,s,St.Neptune,Fh),t}const qh=51,$3=29200,ur=146,Ti=201,Ts=[[-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 je{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new je(this.x,this.y,this.z)}ToAstroVector(t){return new ge(this.x,this.y,this.z,t)}static zero(){return new je(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new je(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new je(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 je(t*this.x,t*this.y,t*this.z)}div(t){return new je(this.x/t,this.y/t,this.z/t)}mean(t){return new je((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new je(-this.x,-this.y,-this.z)}}class Is{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new Is(this.tt,this.r,this.v)}sub(t){return new Is(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function Z3(s){let[t,[e,n,i],[r,a,o]]=s;return new Is(t,new je(e,n,i),new je(r,a,o))}function _o(s,t,e,n){const i=n/(n+Tu),r=Xh(pi[e],t);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function Kr(s,t,e){const n=e.sub(s),i=n.quadrature();return n.mul(t/(i*Math.sqrt(i)))}class gc{constructor(t){let e=new Is(t,new je(0,0,0),new je(0,0,0));this.Jupiter=_o(e,t,St.Jupiter,Nh),this.Saturn=_o(e,t,St.Saturn,Oh),this.Uranus=_o(e,t,St.Uranus,Uh),this.Neptune=_o(e,t,St.Neptune,Fh),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 Is(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=Kr(t,Tu,this.Sun.r);return e.incr(Kr(t,Nh,this.Jupiter.r)),e.incr(Kr(t,Oh,this.Saturn.r)),e.incr(Kr(t,Uh,this.Uranus.r)),e.incr(Kr(t,Fh,this.Neptune.r)),e}}class vc{constructor(t,e,n,i){this.tt=t,this.r=e,this.v=n,this.a=i}clone(){return new vc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class am{constructor(t,e){this.bary=t,this.grav=e}}function sc(s,t,e,n){return new je(t.x+s*(e.x+s*n.x/2),t.y+s*(e.y+s*n.y/2),t.z+s*(e.z+s*n.z/2))}function V0(s,t,e){return new je(t.x+s*e.x,t.y+s*e.y,t.z+s*e.z)}function Yh(s,t){const e=s-t.tt,n=new gc(s),i=sc(e,t.r,t.v,t.a),r=n.Acceleration(i).mean(t.a),a=sc(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new vc(s,a,o,c);return new am(n,l)}const J3=[];function om(s,t){const e=Math.floor(s);return e<0?0:e>=t?t-1:e}function Kh(s){const t=Z3(s),e=new gc(t.tt),n=t.r.add(e.Sun.r),i=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new vc(t.tt,n,i,r);return new am(e,a)}function Q3(s,t){const e=Ts[0][0];if(t<e||t>Ts[qh-1][0])return null;const n=om((t-e)/$3,qh-1);if(!s[n]){const r=s[n]=[];r[0]=Kh(Ts[n]).grav,r[Ti-1]=Kh(Ts[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Ti-1;++a)r[a]=Yh(o+=ur,r[a-1]).grav;o=r[Ti-1].tt;var i=[];for(i[Ti-1]=r[Ti-1],a=Ti-2;a>0;--a)i[a]=Yh(o-=ur,i[a+1]).grav;for(a=Ti-2;a>0;--a){const c=a/(Ti-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function W0(s,t,e){let n=Kh(s);const i=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<i;++r)n=Yh(r+1===i?t:n.grav.tt+e,n.grav);return n}function cm(s,t){let e,n,i;const r=Q3(J3,s.tt);if(r){const a=om((s.tt-r[0].tt)/ur,Ti-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=sc(s.tt-o.tt,o.r,o.v,l),u=V0(s.tt-o.tt,o.v,l),d=sc(s.tt-c.tt,c.r,c.v,l),f=V0(s.tt-c.tt,c.v,l),g=(s.tt-o.tt)/ur;e=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;s.tt<Ts[0][0]?a=W0(Ts[0],s.tt,-ur):a=W0(Ts[qh-1],s.tt,+ur),e=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new gc(s.tt)),e=e.sub(i.Sun.r),n=n.sub(i.Sun.v),new rs(e.x,e.y,e.z,n.x,n.y,n.z,s)}function os(s,t){var e=Ve(t);if(s in pi)return Mr(pi[s],e);if(s===St.Pluto){const a=cm(e);return new ge(a.x,a.y,a.z,e)}if(s===St.Sun)return new ge(0,0,0,e);if(s===St.Moon){var n=Mr(pi.Earth,e),i=Tr(e);return new ge(n.x+i.x,n.y+i.y,n.z+i.z,e)}if(s===St.EMB){const a=Mr(pi.Earth,e),o=Tr(e),c=1+$p;return new ge(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(s===St.SSB)return K3(e);const r=Ru(s);if(r){const a=new Pu(r.dec,15*r.ra,r.dist);return hm(a,e)}throw`HelioVector: Unknown body "${s}"`}function j3(s,t){let e=t,n=0;for(let i=0;i<10;++i){const r=s(e),a=r.Length()/Au;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class tS{constructor(t,e,n,i){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=i}Position(t){this.aberration&&(this.observerPos=os(this.observerBody,t));const e=os(this.targetBody,t);return new ge(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function eS(s,t,e,n){nc(n);const i=Ve(s);if(Ru(e)){const o=os(e,i);if(n){const l=iS(t,i),h=new ge(o.x-l.x,o.y-l.y,o.z-l.z,i),u=Au/h.Length();return new ge(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=os(t,i);return new ge(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new ge(0,0,0,i):r=os(t,i);const a=new tS(t,e,n,r);return j3(o=>a.Position(o),i)}function $h(s,t,e){nc(e);const n=Ve(t);switch(s){case St.Earth:return new ge(0,0,0,n);case St.Moon:return Tr(n);default:const i=eS(n,St.Earth,s,e);return i.t=n,i}}function nS(s,t){return new rs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,t)}function iS(s,t){const e=Ve(t);switch(s){case St.Sun:return new rs(0,0,0,0,0,0,e);case St.SSB:const n=new gc(e.tt);return new rs(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case St.Mercury:case St.Venus:case St.Earth:case St.Mars:case St.Jupiter:case St.Saturn:case St.Uranus:case St.Neptune:const i=Xh(pi[s],e.tt);return nS(i,e);case St.Pluto:return cm(e);case St.Moon:case St.EMB:const r=Xh(pi.Earth,e.tt),a=s==St.Moon?sm(e):Y3(e);return new rs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if(Ru(s)){const o=os(s,e);return new rs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${s}"`}}function sS(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function rS(s,t,e){if(s===St.Earth||t===St.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Ve(e),i=$h(s,n,!1),r=kh(i),a=$h(t,n,!1),o=kh(a);return sS(r.elon-o.elon)}function aS(s,t,e,n){let i,r=0,a=0,o=0;switch(s){case St.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case St.Venus:t<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case St.Mars:i=-1.52,r=1.6;break;case St.Jupiter:i=-9.4,r=.5;break;case St.Uranus:i=-7.19,r=.25;break;case St.Neptune:i=-6.87;break;case St.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=t/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function oS(s,t,e,n,i){const r=kh(n),a=ae*28.06,o=ae*(169.51+382e-7*i.tt),c=ae*r.elat,l=ae*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:vi*h}}function cS(s,t,e){let n=s*ae,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/bs;let c=e/o;return a+=5*Math.log10(t*c),a}class lS{constructor(t,e,n,i,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ae*n))/2}}function lm(s,t){if(s===St.Earth)throw"The illumination of the Earth is not defined.";const e=Ve(t),n=Mr(pi.Earth,e);let i,r,a,o;s===St.Sun?(a=new ge(-n.x,-n.y,-n.z,e),r=new ge(0,0,0,e),i=0):(s===St.Moon?(a=Tr(e),r=new ge(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=os(s,t),a=new ge(r.x-n.x,r.y-n.y,r.z-n.z,e)),i=D3(a,r));let c=a.Length(),l=r.Length(),h;if(s===St.Sun)o=A3+5*Math.log10(c);else if(s===St.Moon)o=cS(i,l,c);else if(s===St.Saturn){const u=oS(i,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=aS(s,i,l,c);return new lS(e,o,i,l,c,a,r,h)}function hS(s){return rS(St.Moon,St.Sun,s)}var X0;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(X0||(X0={}));function uS(s,t){return new ls([[t.rot[0][0]*s.rot[0][0]+t.rot[1][0]*s.rot[0][1]+t.rot[2][0]*s.rot[0][2],t.rot[0][1]*s.rot[0][0]+t.rot[1][1]*s.rot[0][1]+t.rot[2][1]*s.rot[0][2],t.rot[0][2]*s.rot[0][0]+t.rot[1][2]*s.rot[0][1]+t.rot[2][2]*s.rot[0][2]],[t.rot[0][0]*s.rot[1][0]+t.rot[1][0]*s.rot[1][1]+t.rot[2][0]*s.rot[1][2],t.rot[0][1]*s.rot[1][0]+t.rot[1][1]*s.rot[1][1]+t.rot[2][1]*s.rot[1][2],t.rot[0][2]*s.rot[1][0]+t.rot[1][2]*s.rot[1][1]+t.rot[2][2]*s.rot[1][2]],[t.rot[0][0]*s.rot[2][0]+t.rot[1][0]*s.rot[2][1]+t.rot[2][0]*s.rot[2][2],t.rot[0][1]*s.rot[2][0]+t.rot[1][1]*s.rot[2][1]+t.rot[2][1]*s.rot[2][2],t.rot[0][2]*s.rot[2][0]+t.rot[1][2]*s.rot[2][1]+t.rot[2][2]*s.rot[2][2]]])}function hm(s,t){t=Ve(t);const e=s.lat*ae,n=s.lon*ae,i=s.dist*Math.cos(e);return new ge(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(e),t)}function um(s){const t=dS(s);return new Bh(t.lon/15,t.lat,t.dist,s)}function dS(s){const t=s.x*s.x+s.y*s.y,e=Math.sqrt(t+s.z*s.z);let n,i;if(t===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=vi*Math.atan2(s.y,s.x),i<0&&(i+=360),n=vi*Math.atan2(s.z,Math.sqrt(t));return new Pu(n,i,e)}function fS(s,t){let e;if(Ke(t),t<-90||t>90)return 0;if(s==="normal"||s==="jplhor"){let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ae)/60,s==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!s)e=0;else throw`Invalid refraction option: ${s}`;return e}function ko(s,t){return new ge(s.rot[0][0]*t.x+s.rot[1][0]*t.y+s.rot[2][0]*t.z,s.rot[0][1]*t.x+s.rot[1][1]*t.y+s.rot[2][1]*t.z,s.rot[0][2]*t.x+s.rot[1][2]*t.y+s.rot[2][2]*t.z,t.t)}function pS(){return new ls([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function mS(){return new ls([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function gS(s){s=Ve(s);const t=Qp(s,mn.From2000),e=tm(s,mn.From2000);return uS(t,e)}function vS(s){const e=Ta(Ve(s)).tobl*ae,n=Math.cos(e),i=Math.sin(e);return new ls([[1,0,0],[0,+n,+i],[0,-i,+n]])}var q0;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(q0||(q0={}));var Y0;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Y0||(Y0={}));const xS=["Venus","Mars","Jupiter","Saturn"];function dm(s){return new Lu(s.lat,s.lng,s.elevationM)}function Rr(s,t,e,n,i=!0){const r=nm(e,dm(n),s,t,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function dl(s,t,e){const n=dm(e),i=X3(St[s],t,n,!0,!0),r=nm(t,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function fl(s,t){return lm(St[s],t).mag}function _S(s){const t=hS(s),e=lm(St.Moon,s);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const MS=2e3,yS=3,SS=20;function K0(s,t,e){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??MS,r=s.month??(n?1:yS),a=s.day??(n?1:SS),o=e??Math.round(t/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Es{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Es.patch(e.fragmentShader)}}static patch(t){return t.replace(Es.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
4686
|
+
*/const Au=173.1446326846693,bs=14959787069098932e-8,ae=.017453292519943295,B0=.26179938779914946,vi=57.29577951308232,Yp=3.819718634205488,w3=365.24217,k0=new Date("2000-01-01T12:00:00Z"),Ai=2*Math.PI,ji=3600*(180/Math.PI),hr=484813681109536e-20,Kp=10800*60,A3=2*Kp,H0=7292115e-11,T3=Kp/Math.PI,R3=-.17-5*Math.log10(T3),Ih=.996647180302104,D3=Ih*Ih,Lh=6378.1366,C3=Lh/bs,$p=81.30056,Tu=.0002959122082855911,Nh=2825345909524226e-22,Oh=8459715185680659e-23,Uh=1292024916781969e-23,Fh=1524358900784276e-23;function nc(s){if(s!==!0&&s!==!1)throw console.trace(),`Value is not boolean: ${s}`;return s}function Ke(s){if(!Number.isFinite(s))throw console.trace(),`Value is not a finite number: ${s}`;return s}function rr(s){return s-Math.floor(s)}function P3(s,t){const e=s.x*s.x+s.y*s.y+s.z*s.z;if(Math.abs(e)<1e-8)throw"AngleBetween: first vector is too short.";const n=t.x*t.x+t.y*t.y+t.z*t.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const i=(s.x*t.x+s.y*t.y+s.z*t.z)/Math.sqrt(e*n);return i<=-1?180:i>=1?0:vi*Math.acos(i)}var St;(function(s){s.Sun="Sun",s.Moon="Moon",s.Mercury="Mercury",s.Venus="Venus",s.Earth="Earth",s.Mars="Mars",s.Jupiter="Jupiter",s.Saturn="Saturn",s.Uranus="Uranus",s.Neptune="Neptune",s.Pluto="Pluto",s.SSB="SSB",s.EMB="EMB",s.Star1="Star1",s.Star2="Star2",s.Star3="Star3",s.Star4="Star4",s.Star5="Star5",s.Star6="Star6",s.Star7="Star7",s.Star8="Star8"})(St||(St={}));const I3=[St.Star1,St.Star2,St.Star3,St.Star4,St.Star5,St.Star6,St.Star7,St.Star8],L3=[{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 N3(s){const t=I3.indexOf(s);return t>=0?L3[t]:null}function Ru(s){const t=N3(s);return t&&t.dist>0?t:null}var mn;(function(s){s[s.From2000=0]="From2000",s[s.Into2000=1]="Into2000"})(mn||(mn={}));const pi={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 O3(s){var t,e,n,i,r,a,o;const c=2e3+(s-14)/w3;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*i+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*i-.005050998*r+.0083572073*a):c<1700?(t=c-1600,e=t*t,n=t*e,120-.9808*t-.01532*e+n/7129):c<1800?(t=c-1700,e=t*t,n=t*e,i=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-i/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,i=e*e,r=e*n,a=n*n,o=n*i,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*i+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,i=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*i+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,i=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*i):c<1941?(t=c-1920,e=t*t,n=t*e,21.2+.84493*t-.0761*e+.0020936*n):c<1961?(t=c-1950,e=t*t,n=t*e,29.07+.407*t-e/233+n/2547):c<1986?(t=c-1975,e=t*t,n=t*e,45.45+1.067*t-e/260-n/718):c<2005?(t=c-2e3,e=t*t,n=t*e,i=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*i+2373599e-11*r):c<2050?(t=c-2e3,62.92+.32217*t+.005589*t*t):c<2150?(t=(c-1820)/100,-20+32*t*t-.5628*(2150-c)):(t=(c-1820)/100,-20+32*t*t)}let U3=O3;function G0(s){return s+U3(s)/86400}class xr{constructor(t){if(t instanceof xr){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()-k0.getTime())/e,this.tt=G0(this.ut);return}if(Number.isFinite(t)){this.date=new Date(k0.getTime()+t*e),this.ut=t,this.tt=G0(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 xr(t);for(;;){const n=t-e.tt;if(Math.abs(n)<1e-12)return e;e=e.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(t){return new xr(this.ut+t)}}function Ve(s){return s instanceof xr?s:new xr(s)}function F3(s){function t(d){return d%A3*hr}const e=s.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),i=t(335779.526232+e*17395272628478e-4),r=t(107226070369e-5+e*1602961601209e-3),a=t(450160.398036-e*69628905431e-4);let o=Math.sin(a),c=Math.cos(a),l=(-172064161-174666*e)*o+33386*c,h=(92052331+9086*e)*c+15377*o,u=2*(i-r+a);return o=Math.sin(u),c=Math.cos(u),l+=(-13170906-1675*e)*o-13696*c,h+=(5730336-3015*e)*c-4587*o,u=2*(i+a),o=Math.sin(u),c=Math.cos(u),l+=(-2276413-234*e)*o+2796*c,h+=(978459-485*e)*c+1374*o,u=2*a,o=Math.sin(u),c=Math.cos(u),l+=(2074554+207*e)*o-698*c,h+=(-897492+470*e)*c-291*o,o=Math.sin(n),c=Math.cos(n),l+=(1475877-3633*e)*o+11817*c,h+=(73871-184*e)*c-1924*o,{dpsi:-135e-6+l*1e-7,deps:388e-6+h*1e-7}}function Zp(s){var t=s.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var go;function Ta(s){if(!go||Math.abs(go.tt-s.tt)>1e-6){const t=F3(s),e=Zp(s),n=e+t.deps/3600;go={tt:s.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ae)/15,mobl:e,tobl:n}}return go}function z3(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[t[0],t[1]*n-t[2]*i,t[1]*i+t[2]*n]}function B3(s,t){return z3(Zp(s),t)}function k3(s){const t=s.tt/36525;function e(Tt,_t){const Nt=[];let Ot;for(Ot=0;Ot<=_t-Tt;++Ot)Nt.push(0);return{min:Tt,array:Nt}}function n(Tt,_t,Nt,Ot){const Ut=[];for(let ee=0;ee<=_t-Tt;++ee)Ut.push(e(Nt,Ot));return{min:Tt,array:Ut}}function i(Tt,_t,Nt){const Ot=Tt.array[_t-Tt.min];return Ot.array[Nt-Ot.min]}function r(Tt,_t,Nt,Ot){const Ut=Tt.array[_t-Tt.min];Ut.array[Nt-Ut.min]=Ot}let a,o,c,l,h,u,d,f,g,v,p,m,b,E,M,S,w,R,_,A,C,D,I,V=n(-6,6,1,4),q=n(-6,6,1,4);function O(Tt,_t){return i(V,Tt,_t)}function W(Tt,_t){return i(q,Tt,_t)}function G(Tt,_t,Nt){return r(V,Tt,_t,Nt)}function Z(Tt,_t,Nt){return r(q,Tt,_t,Nt)}function et(Tt,_t,Nt,Ot,Ut){Ut(Tt*Nt-_t*Ot,_t*Nt+Tt*Ot)}function j(Tt){return Math.sin(Ai*Tt)}d=t*t,g=0,I=0,p=0,m=3422.7;var it=j(.19833+.05611*t),ut=j(.27869+.04508*t),Ht=j(.16827-.36903*t),Jt=j(.34734-5.37261*t),kt=j(.10498-5.37899*t),Y=j(.42681-.41855*t),rt=j(.14943-5.37511*t);for(R=.84*it+.31*ut+14.27*Ht+7.26*Jt+.28*kt+.24*Y,_=2.94*it+.31*ut+14.27*Ht+9.34*Jt+1.12*kt+.83*Y,A=-6.4*it-1.89*Y,C=.21*it+.31*ut+14.27*Ht-88.7*Jt-15.3*kt+.24*Y-1.86*rt,D=R-A,f=-3332e-9*j(.59734-5.37261*t)-539e-9*j(.35498-5.37899*t)-64e-9*j(.39943-5.37511*t),b=Ai*rr(.60643382+1336.85522467*t-313e-8*d)+R/ji,E=Ai*rr(.37489701+1325.55240982*t+2565e-8*d)+_/ji,M=Ai*rr(.99312619+99.99735956*t-44e-8*d)+A/ji,S=Ai*rr(.25909118+1342.2278298*t-892e-8*d)+C/ji,w=Ai*rr(.82736186+1236.85308708*t-397e-8*d)+D/ji,h=1;h<=4;++h){switch(h){case 1:c=E,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=w,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(G(0,h,1),G(1,h,Math.cos(c)*l),Z(0,h,0),Z(1,h,Math.sin(c)*l),u=2;u<=o;++u)et(O(u-1,h),W(u-1,h),O(1,h),W(1,h),(Tt,_t)=>(G(u,h,Tt),Z(u,h,_t)));for(u=1;u<=o;++u)G(-u,h,O(u,h)),Z(-u,h,-W(u,h))}function nt(Tt,_t,Nt,Ot){for(var Ut={x:1,y:0},ee=[0,Tt,_t,Nt,Ot],ne=1;ne<=4;++ne)ee[ne]!==0&&et(Ut.x,Ut.y,O(ee[ne],ne),W(ee[ne],ne),(Ee,ve)=>(Ut.x=Ee,Ut.y=ve));return Ut}function z(Tt,_t,Nt,Ot,Ut,ee,ne,Ee){var ve=nt(Ut,ee,ne,Ee);g+=Tt*ve.y,I+=_t*ve.y,p+=Nt*ve.x,m+=Ot*ve.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 Et(Tt,_t,Nt,Ot,Ut){return Tt*nt(_t,Nt,Ot,Ut).y}v=0,v+=Et(-526.069,0,0,1,-2),v+=Et(-3.352,0,0,1,-4),v+=Et(44.297,1,0,1,-2),v+=Et(-6,1,0,1,-4),v+=Et(20.599,-1,0,1,0),v+=Et(-30.598,-1,0,1,-2),v+=Et(-24.649,-2,0,1,0),v+=Et(-2,-2,0,1,-2),v+=Et(-22.571,0,1,1,-2),v+=Et(10.985,0,-1,1,-2),g+=.82*j(.7736-62.5512*t)+.31*j(.0466-125.1025*t)+.35*j(.5785-25.1042*t)+.66*j(.4591+1335.8075*t)+.64*j(.313-91.568*t)+1.14*j(.148+1331.2898*t)+.21*j(.5918+1056.5859*t)+.44*j(.5784+1322.8595*t)+.24*j(.2275-5.7374*t)+.28*j(.2965+2.6929*t)+.33*j(.3132+6.3368*t),a=S+I/ji;let It=(1.000002708+139.978*f)*(18518.511+1.189+p)*Math.sin(a)-6.24*Math.sin(3*a)+v;return{geo_eclip_lon:Ai*rr((b+g/ji)/Ai),geo_eclip_lat:Math.PI/(180*3600)*It,distance_au:ji*C3/(.999953253*m)}}function Jp(s,t){return[s.rot[0][0]*t[0]+s.rot[1][0]*t[1]+s.rot[2][0]*t[2],s.rot[0][1]*t[0]+s.rot[1][1]*t[1]+s.rot[2][1]*t[2],s.rot[0][2]*t[0]+s.rot[1][2]*t[1]+s.rot[2][2]*t[2]]}function ic(s,t,e){const n=Qp(t,e);return Jp(n,s)}function Qp(s,t){const e=s.tt/36525;let n=84381.406,i=((((-951e-10*e+132851e-9)*e-.00114045)*e-1.0790069)*e+5038.481507)*e,r=((((3337e-10*e-467e-9)*e-.00772503)*e+.0512623)*e-.025754)*e+n,a=((((-56e-9*e+170663e-9)*e-.00121197)*e-2.3814292)*e+10.556403)*e;n*=hr,i*=hr,r*=hr,a*=hr;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-i),h=Math.cos(-i),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),g=Math.cos(a),v=g*h-l*f*d,p=g*l*c+f*d*h*c-o*f*u,m=g*l*o+f*d*h*o+c*f*u,b=-f*h-l*g*d,E=-f*l*c+g*d*h*c-o*g*u,M=-f*l*o+g*d*h*o+c*g*u,S=l*u,w=-u*h*c-o*d,R=-u*h*o+d*c;if(t===mn.Into2000)return new ls([[v,p,m],[b,E,M],[S,w,R]]);if(t===mn.From2000)return new ls([[v,b,S],[p,E,w],[m,M,R]]);throw"Invalid precess direction"}function H3(s){const t=.779057273264+.00273781191135448*s.ut,e=s.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let vo;function Du(s){if(!vo||vo.tt!==s.tt){const t=s.tt/36525;let e=15*Ta(s).ee;const n=H3(s);let r=((e+.014506+((((-368e-10*t-29956e-9)*t-44e-8)*t+1.3915817)*t+4612.156534)*t)/3600+n)%360/15;r<0&&(r+=24),vo={tt:s.tt,st:r}}return vo.st}function jp(s,t){const e=s.latitude*ae,n=Math.sin(e),i=Math.cos(e),r=1/Math.hypot(i,Ih*n),a=D3*r,o=s.height/1e3,c=Lh*r+o,l=Lh*a+o,h=(15*t+s.longitude)*ae,u=Math.sin(h),d=Math.cos(h);return{pos:[c*i*d/bs,c*i*u/bs,l*n/bs],vel:[-H0*c*i*u*86400/bs,H0*c*i*d*86400/bs,0]}}function zh(s,t,e){const n=tm(t,e);return Jp(n,s)}function tm(s,t){const e=Ta(s),n=e.mobl*ae,i=e.tobl*ae,r=e.dpsi*hr,a=Math.cos(n),o=Math.sin(n),c=Math.cos(i),l=Math.sin(i),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,v=u*c,p=h*a*c+o*l,m=h*o*c-a*l,b=u*l,E=h*a*l-o*c,M=h*o*l+a*c;if(t===mn.From2000)return new ls([[d,v,b],[f,p,E],[g,m,M]]);if(t===mn.Into2000)return new ls([[d,f,g],[v,p,m],[b,E,M]]);throw"Invalid precess direction"}function Cu(s,t,e){return e===mn.Into2000?ic(zh(s,t,e),t,e):zh(ic(s,t,e),t,e)}function G3(s,t){const e=Du(s),n=jp(t,e).pos;return Cu(n,s,mn.Into2000)}class ge{constructor(t,e,n,i){this.x=t,this.y=e,this.z=n,this.t=i}Length(){return Math.hypot(this.x,this.y,this.z)}}class rs{constructor(t,e,n,i,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=i,this.vy=r,this.vz=a,this.t=o}}class Pu{constructor(t,e,n){this.lat=Ke(t),this.lon=Ke(e),this.dist=Ke(n)}}class Bh{constructor(t,e,n,i){this.ra=Ke(t),this.dec=Ke(e),this.dist=Ke(n),this.vec=i}}class ls{constructor(t){this.rot=t}}class V3{constructor(t,e,n,i){this.azimuth=Ke(t),this.altitude=Ke(e),this.ra=Ke(n),this.dec=Ke(i)}}class W3{constructor(t,e,n){this.vec=t,this.elat=Ke(e),this.elon=Ke(n)}}function em(s,t){return new ge(s[0],s[1],s[2],t)}function X3(s,t){const e=em(s,t),n=e.x*e.x+e.y*e.y,i=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new Bh(0,e.z<0?-90:90,i,e)}let r=Yp*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=vi*Math.atan2(s[2],Math.sqrt(n));return new Bh(r,a,i,e)}function hl(s,t){const e=s*ae,n=Math.cos(e),i=Math.sin(e);return[n*t[0]+i*t[1],n*t[1]-i*t[0],t[2]]}function nm(s,t,e,n,i){let r=Ve(s);Iu(t),Ke(e),Ke(n);const a=Math.sin(t.latitude*ae),o=Math.cos(t.latitude*ae),c=Math.sin(t.longitude*ae),l=Math.cos(t.longitude*ae),h=Math.sin(n*ae),u=Math.cos(n*ae),d=Math.sin(e*B0),f=Math.cos(e*B0);let g=[o*l,o*c,a],v=[-a*l,-a*c,o],p=[c,-l,0];const m=-15*Du(r);let b=hl(m,g),E=hl(m,v),M=hl(m,p),S=[u*f,u*d,h];const w=S[0]*b[0]+S[1]*b[1]+S[2]*b[2],R=S[0]*E[0]+S[1]*E[1]+S[2]*E[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let A=Math.hypot(R,_),C;A>0?(C=-vi*Math.atan2(_,R),C<0&&(C+=360)):C=0;let D=vi*Math.atan2(A,w),I=e,V=n;if(i){let q=D,O=mS(i,90-D);if(D-=O,O>0&&D>3e-4){const W=Math.sin(D*ae),G=Math.cos(D*ae),Z=Math.sin(q*ae),et=Math.cos(q*ae),j=[];for(let it=0;it<3;++it)j.push((S[it]-et*b[it])/Z*W+b[it]*G);A=Math.hypot(j[0],j[1]),A>0?(I=Yp*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,V=vi*Math.atan2(j[2],A)}}return new V3(C,90-D,I,V)}function Iu(s){if(!(s instanceof Lu))throw`Not an instance of the Observer class: ${s}`;if(Ke(s.latitude),Ke(s.longitude),Ke(s.height),s.latitude<-90||s.latitude>90)throw`Latitude ${s.latitude} is out of range. Must be -90..+90.`;return s}class Lu{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,Iu(this)}}function q3(s){const t=Ve(s).AddDays(-1/Au),e=Mr(pi.Earth,t),n=[-e.x,-e.y,-e.z],[i,r,a]=Cu(n,t,mn.From2000),o=ae*Ta(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ge(i,r,a,t);return im(h,c,l)}function Y3(s,t,e,n,i){Iu(e),nc(n),nc(i);const r=Ve(t),a=G3(r,e),o=$h(s,r,i),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=Cu(c,r,mn.From2000);return X3(l,r)}function K3(s,t,e){const n=Ve(s),i=Du(n);let r=jp(t,i).pos;return em(r,n)}function im(s,t,e){const n=s.x,i=s.y*t+s.z*e,r=-s.y*e+s.z*t,a=Math.hypot(n,i);let o=0;a>0&&(o=vi*Math.atan2(i,n),o<0&&(o+=360));let c=vi*Math.atan2(r,a),l=new ge(n,i,r,s.t);return new W3(l,c,o)}function kh(s){const t=Ta(s.t),e=[s.x,s.y,s.z],n=ic(e,s.t,mn.From2000),[i,r,a]=zh(n,s.t,mn.From2000),o=new ge(i,r,a,s.t),c=t.tobl*ae;return im(o,Math.cos(c),Math.sin(c))}function Tr(s){const t=Ve(s),e=k3(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),i=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=B3(t,i),a=ic(r,t,mn.Into2000);return new ge(a[0],a[1],a[2],t)}function sm(s){const t=Ve(s),e=1e-5,n=t.AddDays(-e),i=t.AddDays(+e),r=Tr(n),a=Tr(i);return new rs((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*e),(a.y-r.y)/(2*e),(a.z-r.z)/(2*e),t)}function $3(s){const t=Ve(s),e=sm(t),n=1+$p;return new rs(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function _r(s,t,e){let n=1,i=0;for(let r of s){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=Ai),i+=o,n*=t}return i}function ul(s,t){let e=1,n=0,i=0,r=0;for(let a of s){let o=0,c=0;for(let[l,h,u]of a){let d=h+t*u;o+=l*u*Math.sin(d),r>0&&(c+=l*Math.cos(d))}i+=r*n*c-e*o,n=e,e*=t,++r}return i}const na=365250,Hh=0,Gh=1,Vh=2;function Wh(s){return new je(s[0]+44036e-11*s[1]-190919e-12*s[2],-479966e-12*s[0]+.917482137087*s[1]-.397776982902*s[2],.397776982902*s[1]+.917482137087*s[2])}function rm(s,t,e){const n=e*Math.cos(t),i=Math.cos(s),r=Math.sin(s);return[n*i,n*r,e*Math.sin(t)]}function Mr(s,t){const e=t.tt/na,n=_r(s[Hh],e,!0),i=_r(s[Gh],e,!1),r=_r(s[Vh],e,!1),a=rm(n,i,r);return Wh(a).ToAstroVector(t)}function Xh(s,t){const e=t/na,n=_r(s[Hh],e,!0),i=_r(s[Gh],e,!1),r=_r(s[Vh],e,!1),a=ul(s[Hh],e),o=ul(s[Gh],e),c=ul(s[Vh],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(i),d=Math.sin(i),f=+(c*u*l)-r*d*l*o-r*u*h*a,g=+(c*u*h)-r*d*h*o+r*u*l*a,v=+(c*d)+r*u*o,p=rm(n,i,r),m=[f/na,g/na,v/na],b=Wh(p),E=Wh(m);return new Is(t,b,E)}function xo(s,t,e,n){const i=n/(n+Tu),r=Mr(pi[e],t);s.x+=i*r.x,s.y+=i*r.y,s.z+=i*r.z}function Z3(s){const t=new ge(0,0,0,s);return xo(t,s,St.Jupiter,Nh),xo(t,s,St.Saturn,Oh),xo(t,s,St.Uranus,Uh),xo(t,s,St.Neptune,Fh),t}const qh=51,J3=29200,ur=146,Ti=201,Ts=[[-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 je{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new je(this.x,this.y,this.z)}ToAstroVector(t){return new ge(this.x,this.y,this.z,t)}static zero(){return new je(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new je(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new je(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 je(t*this.x,t*this.y,t*this.z)}div(t){return new je(this.x/t,this.y/t,this.z/t)}mean(t){return new je((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new je(-this.x,-this.y,-this.z)}}class Is{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new Is(this.tt,this.r,this.v)}sub(t){return new Is(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function Q3(s){let[t,[e,n,i],[r,a,o]]=s;return new Is(t,new je(e,n,i),new je(r,a,o))}function _o(s,t,e,n){const i=n/(n+Tu),r=Xh(pi[e],t);return s.r.incr(r.r.mul(i)),s.v.incr(r.v.mul(i)),r}function Kr(s,t,e){const n=e.sub(s),i=n.quadrature();return n.mul(t/(i*Math.sqrt(i)))}class gc{constructor(t){let e=new Is(t,new je(0,0,0),new je(0,0,0));this.Jupiter=_o(e,t,St.Jupiter,Nh),this.Saturn=_o(e,t,St.Saturn,Oh),this.Uranus=_o(e,t,St.Uranus,Uh),this.Neptune=_o(e,t,St.Neptune,Fh),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 Is(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=Kr(t,Tu,this.Sun.r);return e.incr(Kr(t,Nh,this.Jupiter.r)),e.incr(Kr(t,Oh,this.Saturn.r)),e.incr(Kr(t,Uh,this.Uranus.r)),e.incr(Kr(t,Fh,this.Neptune.r)),e}}class vc{constructor(t,e,n,i){this.tt=t,this.r=e,this.v=n,this.a=i}clone(){return new vc(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class am{constructor(t,e){this.bary=t,this.grav=e}}function sc(s,t,e,n){return new je(t.x+s*(e.x+s*n.x/2),t.y+s*(e.y+s*n.y/2),t.z+s*(e.z+s*n.z/2))}function V0(s,t,e){return new je(t.x+s*e.x,t.y+s*e.y,t.z+s*e.z)}function Yh(s,t){const e=s-t.tt,n=new gc(s),i=sc(e,t.r,t.v,t.a),r=n.Acceleration(i).mean(t.a),a=sc(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new vc(s,a,o,c);return new am(n,l)}const j3=[];function om(s,t){const e=Math.floor(s);return e<0?0:e>=t?t-1:e}function Kh(s){const t=Q3(s),e=new gc(t.tt),n=t.r.add(e.Sun.r),i=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new vc(t.tt,n,i,r);return new am(e,a)}function tS(s,t){const e=Ts[0][0];if(t<e||t>Ts[qh-1][0])return null;const n=om((t-e)/J3,qh-1);if(!s[n]){const r=s[n]=[];r[0]=Kh(Ts[n]).grav,r[Ti-1]=Kh(Ts[n+1]).grav;let a,o=r[0].tt;for(a=1;a<Ti-1;++a)r[a]=Yh(o+=ur,r[a-1]).grav;o=r[Ti-1].tt;var i=[];for(i[Ti-1]=r[Ti-1],a=Ti-2;a>0;--a)i[a]=Yh(o-=ur,i[a+1]).grav;for(a=Ti-2;a>0;--a){const c=a/(Ti-1);r[a].r=r[a].r.mul(1-c).add(i[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(i[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(i[a].a.mul(c))}}return s[n]}function W0(s,t,e){let n=Kh(s);const i=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<i;++r)n=Yh(r+1===i?t:n.grav.tt+e,n.grav);return n}function cm(s,t){let e,n,i;const r=tS(j3,s.tt);if(r){const a=om((s.tt-r[0].tt)/ur,Ti-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=sc(s.tt-o.tt,o.r,o.v,l),u=V0(s.tt-o.tt,o.v,l),d=sc(s.tt-c.tt,c.r,c.v,l),f=V0(s.tt-c.tt,c.v,l),g=(s.tt-o.tt)/ur;e=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;s.tt<Ts[0][0]?a=W0(Ts[0],s.tt,-ur):a=W0(Ts[qh-1],s.tt,+ur),e=a.grav.r,n=a.grav.v,i=a.bary}return i||(i=new gc(s.tt)),e=e.sub(i.Sun.r),n=n.sub(i.Sun.v),new rs(e.x,e.y,e.z,n.x,n.y,n.z,s)}function os(s,t){var e=Ve(t);if(s in pi)return Mr(pi[s],e);if(s===St.Pluto){const a=cm(e);return new ge(a.x,a.y,a.z,e)}if(s===St.Sun)return new ge(0,0,0,e);if(s===St.Moon){var n=Mr(pi.Earth,e),i=Tr(e);return new ge(n.x+i.x,n.y+i.y,n.z+i.z,e)}if(s===St.EMB){const a=Mr(pi.Earth,e),o=Tr(e),c=1+$p;return new ge(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(s===St.SSB)return Z3(e);const r=Ru(s);if(r){const a=new Pu(r.dec,15*r.ra,r.dist);return hm(a,e)}throw`HelioVector: Unknown body "${s}"`}function eS(s,t){let e=t,n=0;for(let i=0;i<10;++i){const r=s(e),a=r.Length()/Au;if(a>1)throw"Object is too distant for light-travel solver.";const o=t.AddDays(-a);if(n=Math.abs(o.tt-e.tt),n<1e-9)return r;e=o}throw`Light-travel time solver did not converge: dt = ${n}`}class nS{constructor(t,e,n,i){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=i}Position(t){this.aberration&&(this.observerPos=os(this.observerBody,t));const e=os(this.targetBody,t);return new ge(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function iS(s,t,e,n){nc(n);const i=Ve(s);if(Ru(e)){const o=os(e,i);if(n){const l=rS(t,i),h=new ge(o.x-l.x,o.y-l.y,o.z-l.z,i),u=Au/h.Length();return new ge(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,i)}const c=os(t,i);return new ge(o.x-c.x,o.y-c.y,o.z-c.z,i)}let r;n?r=new ge(0,0,0,i):r=os(t,i);const a=new nS(t,e,n,r);return eS(o=>a.Position(o),i)}function $h(s,t,e){nc(e);const n=Ve(t);switch(s){case St.Earth:return new ge(0,0,0,n);case St.Moon:return Tr(n);default:const i=iS(n,St.Earth,s,e);return i.t=n,i}}function sS(s,t){return new rs(s.r.x,s.r.y,s.r.z,s.v.x,s.v.y,s.v.z,t)}function rS(s,t){const e=Ve(t);switch(s){case St.Sun:return new rs(0,0,0,0,0,0,e);case St.SSB:const n=new gc(e.tt);return new rs(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,e);case St.Mercury:case St.Venus:case St.Earth:case St.Mars:case St.Jupiter:case St.Saturn:case St.Uranus:case St.Neptune:const i=Xh(pi[s],e.tt);return sS(i,e);case St.Pluto:return cm(e);case St.Moon:case St.EMB:const r=Xh(pi.Earth,e.tt),a=s==St.Moon?sm(e):$3(e);return new rs(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,e);default:if(Ru(s)){const o=os(s,e);return new rs(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${s}"`}}function aS(s){for(;s<0;)s+=360;for(;s>=360;)s-=360;return s}function oS(s,t,e){if(s===St.Earth||t===St.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Ve(e),i=$h(s,n,!1),r=kh(i),a=$h(t,n,!1),o=kh(a);return aS(r.elon-o.elon)}function cS(s,t,e,n){let i,r=0,a=0,o=0;switch(s){case St.Mercury:i=-.6,r=4.98,a=-4.88,o=3.02;break;case St.Venus:t<163.6?(i=-4.47,r=1.03,a=.57,o=.13):(i=.98,r=-1.02);break;case St.Mars:i=-1.52,r=1.6;break;case St.Jupiter:i=-9.4,r=.5;break;case St.Uranus:i=-7.19,r=.25;break;case St.Neptune:i=-6.87;break;case St.Pluto:i=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${s}`}const c=t/100;let l=i+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function lS(s,t,e,n,i){const r=kh(n),a=ae*28.06,o=ae*(169.51+382e-7*i.tt),c=ae*r.elat,l=ae*r.elon,h=Math.asin(Math.sin(c)*Math.cos(a)-Math.cos(c)*Math.sin(a)*Math.sin(l-o)),u=Math.sin(Math.abs(h));let d=-9+.044*s;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:vi*h}}function hS(s,t,e){let n=s*ae,i=n*n,r=i*i,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/bs;let c=e/o;return a+=5*Math.log10(t*c),a}class uS{constructor(t,e,n,i,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=i,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ae*n))/2}}function lm(s,t){if(s===St.Earth)throw"The illumination of the Earth is not defined.";const e=Ve(t),n=Mr(pi.Earth,e);let i,r,a,o;s===St.Sun?(a=new ge(-n.x,-n.y,-n.z,e),r=new ge(0,0,0,e),i=0):(s===St.Moon?(a=Tr(e),r=new ge(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=os(s,t),a=new ge(r.x-n.x,r.y-n.y,r.z-n.z,e)),i=P3(a,r));let c=a.Length(),l=r.Length(),h;if(s===St.Sun)o=R3+5*Math.log10(c);else if(s===St.Moon)o=hS(i,l,c);else if(s===St.Saturn){const u=lS(i,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=cS(s,i,l,c);return new uS(e,o,i,l,c,a,r,h)}function dS(s){return oS(St.Moon,St.Sun,s)}var X0;(function(s){s[s.Pericenter=0]="Pericenter",s[s.Apocenter=1]="Apocenter"})(X0||(X0={}));function fS(s,t){return new ls([[t.rot[0][0]*s.rot[0][0]+t.rot[1][0]*s.rot[0][1]+t.rot[2][0]*s.rot[0][2],t.rot[0][1]*s.rot[0][0]+t.rot[1][1]*s.rot[0][1]+t.rot[2][1]*s.rot[0][2],t.rot[0][2]*s.rot[0][0]+t.rot[1][2]*s.rot[0][1]+t.rot[2][2]*s.rot[0][2]],[t.rot[0][0]*s.rot[1][0]+t.rot[1][0]*s.rot[1][1]+t.rot[2][0]*s.rot[1][2],t.rot[0][1]*s.rot[1][0]+t.rot[1][1]*s.rot[1][1]+t.rot[2][1]*s.rot[1][2],t.rot[0][2]*s.rot[1][0]+t.rot[1][2]*s.rot[1][1]+t.rot[2][2]*s.rot[1][2]],[t.rot[0][0]*s.rot[2][0]+t.rot[1][0]*s.rot[2][1]+t.rot[2][0]*s.rot[2][2],t.rot[0][1]*s.rot[2][0]+t.rot[1][1]*s.rot[2][1]+t.rot[2][1]*s.rot[2][2],t.rot[0][2]*s.rot[2][0]+t.rot[1][2]*s.rot[2][1]+t.rot[2][2]*s.rot[2][2]]])}function hm(s,t){t=Ve(t);const e=s.lat*ae,n=s.lon*ae,i=s.dist*Math.cos(e);return new ge(i*Math.cos(n),i*Math.sin(n),s.dist*Math.sin(e),t)}function um(s){const t=pS(s);return new Bh(t.lon/15,t.lat,t.dist,s)}function pS(s){const t=s.x*s.x+s.y*s.y,e=Math.sqrt(t+s.z*s.z);let n,i;if(t===0){if(s.z===0)throw"Zero-length vector not allowed.";i=0,n=s.z<0?-90:90}else i=vi*Math.atan2(s.y,s.x),i<0&&(i+=360),n=vi*Math.atan2(s.z,Math.sqrt(t));return new Pu(n,i,e)}function mS(s,t){let e;if(Ke(t),t<-90||t>90)return 0;if(s==="normal"||s==="jplhor"){let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ae)/60,s==="normal"&&t<-1&&(e*=(t+90)/89)}else if(!s)e=0;else throw`Invalid refraction option: ${s}`;return e}function ko(s,t){return new ge(s.rot[0][0]*t.x+s.rot[1][0]*t.y+s.rot[2][0]*t.z,s.rot[0][1]*t.x+s.rot[1][1]*t.y+s.rot[2][1]*t.z,s.rot[0][2]*t.x+s.rot[1][2]*t.y+s.rot[2][2]*t.z,t.t)}function gS(){return new ls([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function vS(){return new ls([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function xS(s){s=Ve(s);const t=Qp(s,mn.From2000),e=tm(s,mn.From2000);return fS(t,e)}function _S(s){const e=Ta(Ve(s)).tobl*ae,n=Math.cos(e),i=Math.sin(e);return new ls([[1,0,0],[0,+n,+i],[0,-i,+n]])}var q0;(function(s){s.Penumbral="penumbral",s.Partial="partial",s.Annular="annular",s.Total="total"})(q0||(q0={}));var Y0;(function(s){s[s.Invalid=0]="Invalid",s[s.Ascending=1]="Ascending",s[s.Descending=-1]="Descending"})(Y0||(Y0={}));const MS=["Venus","Mars","Jupiter","Saturn"];function dm(s){return new Lu(s.lat,s.lng,s.elevationM)}function Rr(s,t,e,n,i=!0){const r=nm(e,dm(n),s,t,i?"normal":void 0);return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function dl(s,t,e){const n=dm(e),i=Y3(St[s],t,n,!0,!0),r=nm(t,n,i.ra,i.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function fl(s,t){return lm(St[s],t).mag}function yS(s){const t=dS(s),e=lm(St.Moon,s);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const SS=2e3,bS=3,ES=20;function K0(s,t,e){if(s.year===void 0&&s.month===void 0&&s.day===void 0&&s.hour===void 0)return;const n=s.year!==void 0,i=s.year??SS,r=s.month??(n?1:bS),a=s.day??(n?1:ES),o=e??Math.round(t/15);return new Date(Date.UTC(i,r-1,a,(s.hour??12)-o,s.minute??0,s.second??0))}class Es{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(t){t.transparent=!0,t.depthWrite=!1,t.onBeforeCompile=e=>{e.fragmentShader=Es.patch(e.fragmentShader)}}static patch(t){return t.replace(Es.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
4687
4687
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
4688
4688
|
if ( distanceFromCentre > ${Es.RIM.toFixed(2)} ) discard;
|
|
4689
4689
|
float glare = 1.0 - smoothstep( ${Es.CORE.toFixed(2)}, ${Es.RIM.toFixed(2)}, distanceFromCentre );
|
|
4690
|
-
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const bS=[{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}],ia=64,Xe=ia+1,$0=512,ES=900,wS=700/900,AS=0,TS=.01;function RS(s,t,e){return{north:Pi(0,-e,s,t).lat,south:Pi(0,e,s,t).lat,east:Pi(e,0,s,t).lng,west:Pi(-e,0,s,t).lng}}async function DS(s,t,e,n=ES){const i=n,r=n*wS,a=RS(s,t,i),o={width:Xe,height:Xe},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:$0,height:$0})]),h=Math.floor(Xe/2),u=c.heights[h*Xe+h],d=new Float32Array(Xe*Xe*3),f=new Float32Array(Xe*Xe*2),g=new Float32Array(Xe*Xe*4);for(let S=0;S<Xe;S++){const w=S/(Xe-1),R=a.north+(a.south-a.north)*w;for(let _=0;_<Xe;_++){const A=_/(Xe-1),C=a.west+(a.east-a.west)*A,{x:D,z:I}=un(R,C,s,t),V=c.heights[S*Xe+_],q=AS+TS+(V-u),O=S*Xe+_;d[O*3]=D,d[O*3+1]=q,d[O*3+2]=I;const W=ip(l.bounds,C,R);f[O*2]=W.x,f[O*2+1]=W.y;const G=Math.max(Math.abs(D),Math.abs(I)),Z=1-CS((G-r)/(i-r),0,1);g[O*4]=1,g[O*4+1]=1,g[O*4+2]=1,g[O*4+3]=Z}}const v=new Uint16Array(ia*ia*6);let p=0;for(let S=0;S<ia;S++)for(let w=0;w<ia;w++){const R=S*Xe+w,_=R+1,A=R+Xe,C=A+1;v[p++]=R,v[p++]=A,v[p++]=_,v[p++]=_,v[p++]=A,v[p++]=C}const m=new be;m.setAttribute("position",new de(d,3)),m.setAttribute("uv",new de(f,2)),m.setAttribute("color",new de(g,4)),m.setIndex(new de(v,1)),m.computeVertexNormals();const b=new _i(l.source);b.flipY=!1;const E=new ba({map:b,color:new vt(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new $t(m,E);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution}}function CS(s,t,e){return Math.max(t,Math.min(e,s))}const PS=18,IS=.55,LS=.5,NS=`
|
|
4690
|
+
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const wS=[{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}],ia=64,Xe=ia+1,$0=512,AS=900,TS=700/900,RS=0,DS=.01;function CS(s,t,e){return{north:Pi(0,-e,s,t).lat,south:Pi(0,e,s,t).lat,east:Pi(e,0,s,t).lng,west:Pi(-e,0,s,t).lng}}async function PS(s,t,e,n=AS){const i=n,r=n*TS,a=CS(s,t,i),o={width:Xe,height:Xe},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:$0,height:$0})]),h=Math.floor(Xe/2),u=c.heights[h*Xe+h],d=new Float32Array(Xe*Xe*3),f=new Float32Array(Xe*Xe*2),g=new Float32Array(Xe*Xe*4);for(let S=0;S<Xe;S++){const w=S/(Xe-1),R=a.north+(a.south-a.north)*w;for(let _=0;_<Xe;_++){const A=_/(Xe-1),C=a.west+(a.east-a.west)*A,{x:D,z:I}=un(R,C,s,t),V=c.heights[S*Xe+_],q=RS+DS+(V-u),O=S*Xe+_;d[O*3]=D,d[O*3+1]=q,d[O*3+2]=I;const W=ip(l.bounds,C,R);f[O*2]=W.x,f[O*2+1]=W.y;const G=Math.max(Math.abs(D),Math.abs(I)),Z=1-IS((G-r)/(i-r),0,1);g[O*4]=1,g[O*4+1]=1,g[O*4+2]=1,g[O*4+3]=Z}}const v=new Uint16Array(ia*ia*6);let p=0;for(let S=0;S<ia;S++)for(let w=0;w<ia;w++){const R=S*Xe+w,_=R+1,A=R+Xe,C=A+1;v[p++]=R,v[p++]=A,v[p++]=_,v[p++]=_,v[p++]=A,v[p++]=C}const m=new be;m.setAttribute("position",new de(d,3)),m.setAttribute("uv",new de(f,2)),m.setAttribute("color",new de(g,4)),m.setIndex(new de(v,1)),m.computeVertexNormals();const b=new _i(l.source);b.flipY=!1;const E=new ba({map:b,color:new vt(1,1,1),vertexColors:!0,transparent:!0,fog:!0}),M=new $t(m,E);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution}}function IS(s,t,e){return Math.max(t,Math.min(e,s))}const LS=18,NS=.55,OS=.5,US=`
|
|
4691
4691
|
attribute float aSpeed;
|
|
4692
4692
|
uniform float uTime;
|
|
4693
4693
|
uniform float uOverallSpeed;
|
|
@@ -4745,9 +4745,9 @@ void main() {
|
|
|
4745
4745
|
vec2 travel = vec2((ahead.x - here.x) * uAspect, ahead.y - here.y);
|
|
4746
4746
|
// Straight down is the texture's own orientation, so that is the zero.
|
|
4747
4747
|
vSlant = length(travel) < 1e-6 ? 0.0 : atan(travel.x, -travel.y);
|
|
4748
|
-
gl_PointSize = uPixelSize / dist + vNearBlur * ${
|
|
4748
|
+
gl_PointSize = uPixelSize / dist + vNearBlur * ${LS.toFixed(1)};
|
|
4749
4749
|
}
|
|
4750
|
-
`,
|
|
4750
|
+
`,FS=`
|
|
4751
4751
|
precision mediump float;
|
|
4752
4752
|
uniform sampler2D uTexture;
|
|
4753
4753
|
uniform vec3 uColor;
|
|
@@ -4783,11 +4783,11 @@ void main() {
|
|
|
4783
4783
|
// defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
|
|
4784
4784
|
// both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
|
|
4785
4785
|
// one right in the middle distance.
|
|
4786
|
-
vec3 color = mix(uColor, uHazeColor, vHaze * ${
|
|
4786
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * ${NS.toFixed(2)});
|
|
4787
4787
|
float blur = max(vNearBlur, vHaze);
|
|
4788
|
-
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${
|
|
4788
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${OS.toFixed(2)}));
|
|
4789
4789
|
}
|
|
4790
|
-
`;function
|
|
4790
|
+
`;function zS(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const BS=.14,Z0=4.5;let Mo;function kS(){if(Mo)return Mo;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createImageData(s,s),i=s/2,r=s*BS,a=s-r;for(let o=0;o<s;o++)for(let c=0;c<s;c++){const l=c+.5-i,h=o+.5<r?o+.5-r:o+.5>a?o+.5-a:0,u=Math.hypot(l,h),d=Math.exp(-(u*u)/(2*Z0*Z0)),f=(o*s+c)*4;n.data[f]=255,n.data[f+1]=255,n.data[f+2]=255,n.data[f+3]=Math.round(255*Math.min(1,d))}return e.putImageData(n,0,0),Mo=new _i(t),Mo}function HS(s){const t=zS(s.seed),e=new Float32Array(s.count*3),n=new Float32Array(s.count),i=s.radiusM;for(let l=0;l<s.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*s.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*s.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new be;r.setAttribute("position",new de(e,3)),r.setAttribute("aSpeed",new de(n,1)),r.setDrawRange(0,s.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:s.overallSpeed},uPixelSize:{value:s.pixelSize},uOpacity:{value:s.opacity},uColor:{value:s.color},uUvSquash:{value:1},uSpeedStreak:{value:s.speedStreak},uWindOffset:{value:new Pt(0,0)},uDropVelocity:{value:new P(0,-1,0)},uAspect:{value:1},uHeight:{value:s.heightM},uBottomY:{value:s.bottomYM},uHalfWidth:{value:i},uTexture:{value:kS()},uNearFocusDistance:{value:s.nearFocusDistanceM},uHazeDistance:{value:s.hazeDistanceM},uHazeColor:{value:s.hazeColor}},o=new De({uniforms:a,vertexShader:US,fragmentShader:FS,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Fo(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const GS=`
|
|
4791
4791
|
varying vec3 vDir;
|
|
4792
4792
|
|
|
4793
4793
|
void main() {
|
|
@@ -4822,7 +4822,20 @@ float fbm(vec3 p) {
|
|
|
4822
4822
|
amp *= 0.55;
|
|
4823
4823
|
}
|
|
4824
4824
|
return sum;
|
|
4825
|
-
}
|
|
4825
|
+
}
|
|
4826
|
+
|
|
4827
|
+
// The shape fields are noise, and noise clusters: the water deck's runs from 0.23 to 0.76 with
|
|
4828
|
+
// nearly everything between 0.33 and 0.67, the ice deck's tighter still. A threshold of 1 - coverage
|
|
4829
|
+
// on such a field drew NOTHING under a third of cover, a hundredth of the sky at 30%, and half of it
|
|
4830
|
+
// at 50% by coincidence alone — a recording stating 12% cloud showed a clear sky under three chips
|
|
4831
|
+
// saying otherwise. The threshold is the field's own quantile instead, so that a coverage IS the
|
|
4832
|
+
// fraction of sky covered: a logistic fit of the distribution measured over twenty thousand
|
|
4833
|
+
// directions (see WATER_FIELD_MEAN and the others), 0.5513 being sqrt(3)/pi, what turns a standard
|
|
4834
|
+
// deviation into a logistic scale.
|
|
4835
|
+
float coverageThreshold(float coverage, float mean, float spread) {
|
|
4836
|
+
float c = clamp(coverage, 0.001, 0.999);
|
|
4837
|
+
return mean - spread * 0.5513 * log(c / (1.0 - c));
|
|
4838
|
+
}`,pm=.495,mm=.075,VS=.5,WS=.047,XS=`
|
|
4826
4839
|
float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
|
|
4827
4840
|
if (coverage <= 0.0 || dir.y <= 0.02) return 0.0;
|
|
4828
4841
|
vec3 planePos = dir * (layerHeight / max(dir.y, 0.04));
|
|
@@ -4833,7 +4846,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
|
|
|
4833
4846
|
float fibre = fbm(drawnOut) * 0.5 + 0.5;
|
|
4834
4847
|
float wisp = fbm(drawnOut * 3.1 + 7.0) * 0.5 + 0.5;
|
|
4835
4848
|
float shape = fibre * 0.72 + wisp * 0.28;
|
|
4836
|
-
float threshold =
|
|
4849
|
+
float threshold = coverageThreshold(coverage, ${VS.toFixed(3)}, ${WS.toFixed(3)});
|
|
4837
4850
|
float present = smoothstep(threshold - 0.10, threshold + 0.10, shape);
|
|
4838
4851
|
// GRADED, not a mask. A pure threshold saturates to 1 everywhere once the veil is thick — which
|
|
4839
4852
|
// is exactly the sky a reader tested, 88 per cent cover — and the halo went back to being the
|
|
@@ -4842,7 +4855,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
|
|
|
4842
4855
|
// is what makes a halo brighter along one arc than another even under total cover.
|
|
4843
4856
|
return present * (0.30 + 0.70 * smoothstep(0.25, 0.85, shape));
|
|
4844
4857
|
}
|
|
4845
|
-
`,
|
|
4858
|
+
`,qS=`
|
|
4846
4859
|
precision highp float;
|
|
4847
4860
|
uniform vec3 sunDir;
|
|
4848
4861
|
uniform vec3 sunColor;
|
|
@@ -4935,7 +4948,7 @@ void main() {
|
|
|
4935
4948
|
// Below coverage's own noise threshold: a broken/patchy ceiling with real sky-colored gaps,
|
|
4936
4949
|
// exactly like a real transition from scattered to overcast. remap-by-threshold, same technique
|
|
4937
4950
|
// as the reference skill's own cloudDensity coverage control.
|
|
4938
|
-
float threshold =
|
|
4951
|
+
float threshold = coverageThreshold(coverage, ${pm.toFixed(3)}, ${mm.toFixed(3)});
|
|
4939
4952
|
float alpha = smoothstep(threshold - 0.08, threshold + 0.08, shape);
|
|
4940
4953
|
// This is what actually guarantees "total overcast, no sky visible" at cloudCover=1: force full
|
|
4941
4954
|
// opacity everywhere as coverage approaches its max, overriding the noise field's own local value
|
|
@@ -4964,7 +4977,7 @@ void main() {
|
|
|
4964
4977
|
|
|
4965
4978
|
gl_FragColor = vec4(color, alpha);
|
|
4966
4979
|
}
|
|
4967
|
-
`;function J0(s,t,e,n=0){const i={sunDir:{value:new P(0,1,0)},sunColor:{value:new vt(1,1,1)},ambientColor:{value:new vt(.5,.5,.5)},baseColor:{value:s},coverage:{value:t},layerHeight:{value:e},fibrous:{value:n}};return{material:new De({uniforms:i,vertexShader:kS,fragmentShader:GS,transparent:!0,depthWrite:!1,depthTest:!0,side:Be}),uniforms:i}}const VS=1.5;function Q0(s){const t=Math.PI/2-VS*Math.PI/180;return new pn(s,48,24,0,Math.PI*2,0,t)}class Ue{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,n){const i=t*127.1+e*311.7+n*74.7,r=t*269.5+e*183.3+n*246.1,a=t*113.5+e*271.9+n*124.6;return[Ue.fract(Math.sin(i)*43758.5453)*2-1,Ue.fract(Math.sin(r)*43758.5453)*2-1,Ue.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,n){const i=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-i,c=e-r,l=n-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,p,m)=>{const[b,E,M]=Ue.hash3(i+v,r+p,a+m);return b*(o-v)+E*(c-p)+M*(l-m)},g=(v,p,m)=>v+(p-v)*m;return g(g(g(f(0,0,0),f(1,0,0),h),g(f(0,1,0),f(1,1,0),h),u),g(g(f(0,0,1),f(1,0,1),h),g(f(0,1,1),f(1,1,1),h),u),d)}static fbm(t,e,n){let i=0,r=Ue.GAIN;for(let a=0;a<Ue.OCTAVES;a++)i+=Ue.noise3D(t,e,n)*r,t*=Ue.LACUNARITY,e*=Ue.LACUNARITY,n*=Ue.LACUNARITY,r*=Ue.GAIN;return i}static worley(t,e,n){const i=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-i,c=e-r,l=n-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[g,v,p]=Ue.hash3(i+u,r+d,a+f),m=u+(g*.5+.5)-o,b=d+(v*.5+.5)-c,E=f+(p*.5+.5)-l;h=Math.min(h,m*m+b*b+E*E)}return Math.sqrt(h)}static alphaAt(t,e,n){if(n<=0)return 0;const i=Math.abs(t.y);if(i<.026)return 0;const r=e/Math.max(i,.04),a=t.x*r,o=t.y*r,c=t.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Ue.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Ue.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Ue.fbm(l+91.7,h+91.7,u+91.7)*40,v=Ue.fbm(d*.014,f*.014,g*.014)*.5+.5,p=1-Ue.worley(d*.011,f*.011,g*.011),m=v+(p-v)*.4,b=1-n,E=(S,w,R)=>{const _=Math.min(1,Math.max(0,(R-S)/(w-S)));return _*_*(3-2*_)},M=E(b-.08,b+.08,m);return M+(1-M)*E(.82,1,n)}}class Ls{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return Ls.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(Ls.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class Zt{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*Zt.anchor()}static anchor(){return Ls.fromMagPerArcsec2(Zt.PEAK_MAG_PER_ARCSEC2)/Zt.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Zt.NEAR_LIMIT_KPC),d=Math.log(Zt.FAR_LIMIT_KPC)-u;for(let f=0;f<Zt.STEPS;f++){const g=Math.exp(u+d*f/(Zt.STEPS-1)),v=g-h;h=g;const p=g-v/2,m=Zt.SUN_RADIUS_KPC+p*r,b=p*a,E=Zt.SUN_HEIGHT_KPC+p*o,M=Math.hypot(m,b),S=Math.exp(-(M-Zt.SUN_RADIUS_KPC)/Zt.DISK_SCALE_LENGTH_KPC-Math.abs(E)/Zt.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(M,E/Zt.BULGE_FLATTENING),R=Zt.BULGE_TO_LOCAL_DISK*Math.exp(-w/Zt.BULGE_SCALE_KPC);if(c+=(S+R)*v*10**(-.4*l),l+=Zt.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-Zt.SUN_RADIUS_KPC)/Zt.DUST_SCALE_LENGTH_KPC-(Math.abs(E)-Zt.SUN_HEIGHT_KPC)/Zt.DUST_SCALE_HEIGHT_KPC)*v,l>Zt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Zt.LONGITUDE_STEPS*Zt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Zt.LATITUDE_STEPS}walk(t){const e=Zt.LONGITUDE_STEPS,n=Math.min(Zt.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=Ls.latitudeOfRowCoord((this.walked+.5)/Zt.LATITUDE_STEPS);for(let r=0;r<e;r++)this.values[this.walked*e+r]=this.radianceTowards(360*(r+.5)/e,i)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const e=Zt.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Zt.LONGITUDE_STEPS,height:Zt.LATITUDE_STEPS,data:n}}}class Me{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Me.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(Me.NEAR_LIMIT_AU),d=Math.log(Me.FAR_LIMIT_AU)-u;for(let f=0;f<Me.STEPS;f++){const g=Math.exp(u+d*f/(Me.STEPS-1)),v=g-h;h=g;const p=g-v/2,m=1+p*r,b=p*a,E=p*o,M=Math.hypot(m,b,E);if(M<Me.SUBLIMATION_AU)continue;const S=E/M,w=M**-1.3*Math.exp(-2.6*Math.abs(S)),R=(c-p)/M;l+=w*this.scattering(R)*v/(M*M)}return l}scattering(t){let e=0;for(let n=0;n<Me.LOBE_ASYMMETRY.length;n++){const i=Me.LOBE_ASYMMETRY[n],r=1+i*i-2*i*t;e+=Me.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return e}values=new Float32Array(Me.LONGITUDE_STEPS*Me.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Me.LATITUDE_STEPS}walk(t){const e=Me.LONGITUDE_STEPS,n=Math.min(Me.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=Ls.latitudeOfRowCoord((this.walked+.5)/Me.LATITUDE_STEPS);for(let r=0;r<e;r++){const a=Ls.angleOfColumnCoord((r+.5)/e);this.values[this.walked*e+r]=this.radianceTowards(a,i)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:Me.LONGITUDE_STEPS,height:Me.LATITUDE_STEPS,data:n}}}class Kt{static get NANOLAMBERTS_PER_S10(){return Kt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Kt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(t){const e=Kt.TWILIGHT;for(let n=0;n<e.length-1;n++){const i=e[n],r=e[n+1];if(t<=i.sunAltitudeDeg&&t>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-t)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Kt.NANOLAMBERT_OFFSET-Kt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Kt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Kt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Kt.EXTINCTION_PER_AIR_MASS*Kt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Kt.toNanolamberts(Kt.moonlessMagPerArcsec2(t))-Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Kt.scatteringAt(90-t)*Kt.scatteredFraction(90);return Kt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,n,i){return Kt.scatteringAt(n)*Kt.moonOutput(t,e)*Kt.scatteredFraction(i)}static moonOutput(t,e){if(e<=0)return 0;const n=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Kt.EXTINCTION_PER_AIR_MASS*Kt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,n){const i=Kt.scatteredFraction(n),r=Kt.scatteringAt(t.separationDeg)*Kt.twilightOutput(t.altitudeDeg)*i,a=Kt.scatteringAt(e.separationDeg)*Kt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*i;return Kt.fromNanolamberts(Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class Vn{static RADIUS=890;static WORK_BUDGET_MS=6;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;galaxy=new Zt;dust=new Me;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;workHandle;repaint;constructor(){this.milkyWayTexels=new Uint16Array(Zt.LONGITUDE_STEPS*Zt.LATITUDE_STEPS*4),this.milkyWayTexture=Vn.buildTexture(this.milkyWayTexels,Zt.LONGITUDE_STEPS,Zt.LATITUDE_STEPS,Wo),this.zodiacalTexels=new Uint16Array(Me.LONGITUDE_STEPS*Me.LATITUDE_STEPS*4),this.zodiacalTexture=Vn.buildTexture(this.zodiacalTexels,Me.LONGITUDE_STEPS,Me.LATITUDE_STEPS,dn),this.material=new De({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Bt},uEclipticPole:{value:new P(0,1,0)},uSunLongitude:{value:new P(1,0,0)},uMoonDirection:{value:new P(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new P(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new P(0,0,0)},uMilkyWayTint:{value:new P(...Vn.MILKY_WAY_TINT)},uZodiacalTint:{value:new P(...Vn.ZODIACAL_TINT)},uReady:{value:0},uEncodeDestination:{value:1}},vertexShader:`
|
|
4980
|
+
`;function J0(s,t,e,n=0){const i={sunDir:{value:new P(0,1,0)},sunColor:{value:new vt(1,1,1)},ambientColor:{value:new vt(.5,.5,.5)},baseColor:{value:s},coverage:{value:t},layerHeight:{value:e},fibrous:{value:n}};return{material:new De({uniforms:i,vertexShader:GS,fragmentShader:qS,transparent:!0,depthWrite:!1,depthTest:!0,side:Be}),uniforms:i}}const YS=1.5;function Q0(s){const t=Math.PI/2-YS*Math.PI/180;return new pn(s,48,24,0,Math.PI*2,0,t)}class Ie{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,n){const i=t*127.1+e*311.7+n*74.7,r=t*269.5+e*183.3+n*246.1,a=t*113.5+e*271.9+n*124.6;return[Ie.fract(Math.sin(i)*43758.5453)*2-1,Ie.fract(Math.sin(r)*43758.5453)*2-1,Ie.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,n){const i=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-i,c=e-r,l=n-a,h=o*o*(3-2*o),u=c*c*(3-2*c),d=l*l*(3-2*l),f=(v,p,m)=>{const[b,E,M]=Ie.hash3(i+v,r+p,a+m);return b*(o-v)+E*(c-p)+M*(l-m)},g=(v,p,m)=>v+(p-v)*m;return g(g(g(f(0,0,0),f(1,0,0),h),g(f(0,1,0),f(1,1,0),h),u),g(g(f(0,0,1),f(1,0,1),h),g(f(0,1,1),f(1,1,1),h),u),d)}static thresholdFor(t,e,n){const i=Math.min(.999,Math.max(.001,t));return e-n*(Math.sqrt(3)/Math.PI)*Math.log(i/(1-i))}static fbm(t,e,n){let i=0,r=Ie.GAIN;for(let a=0;a<Ie.OCTAVES;a++)i+=Ie.noise3D(t,e,n)*r,t*=Ie.LACUNARITY,e*=Ie.LACUNARITY,n*=Ie.LACUNARITY,r*=Ie.GAIN;return i}static worley(t,e,n){const i=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-i,c=e-r,l=n-a;let h=1/0;for(let u=-1;u<=1;u++)for(let d=-1;d<=1;d++)for(let f=-1;f<=1;f++){const[g,v,p]=Ie.hash3(i+u,r+d,a+f),m=u+(g*.5+.5)-o,b=d+(v*.5+.5)-c,E=f+(p*.5+.5)-l;h=Math.min(h,m*m+b*b+E*E)}return Math.sqrt(h)}static alphaAt(t,e,n){if(n<=0)return 0;const i=Math.abs(t.y);if(i<.026)return 0;const r=e/Math.max(i,.04),a=t.x*r,o=t.y*r,c=t.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Ie.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Ie.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Ie.fbm(l+91.7,h+91.7,u+91.7)*40,v=Ie.fbm(d*.014,f*.014,g*.014)*.5+.5,p=1-Ie.worley(d*.011,f*.011,g*.011),m=v+(p-v)*.4,b=Ie.thresholdFor(n,pm,mm),E=(S,w,R)=>{const _=Math.min(1,Math.max(0,(R-S)/(w-S)));return _*_*(3-2*_)},M=E(b-.08,b+.08,m);return M+(1-M)*E(.82,1,n)}}class Ls{static S10_MAG_PER_ARCSEC2=10+2.5*Math.log10(3600*3600);static toMagPerArcsec2(t){return Ls.S10_MAG_PER_ARCSEC2-2.5*Math.log10(Math.max(t,1e-12))}static fromMagPerArcsec2(t){return 10**(.4*(Ls.S10_MAG_PER_ARCSEC2-t))}static latitudeOfRowCoord(t){const e=2*t-1;return 90*Math.sign(e)*e*e}static rowCoordOfLatitude(t){return(Math.sign(t)*Math.sqrt(Math.min(Math.abs(t),90)/90)+1)/2}static angleOfColumnCoord(t){return 180*t*t}static columnCoordOfAngle(t){return Math.sqrt(Math.min(Math.max(t,0),180)/180)}}class Zt{static LONGITUDE_STEPS=256;static LATITUDE_STEPS=128;static SUN_RADIUS_KPC=8.2;static SUN_HEIGHT_KPC=.02;static DISK_SCALE_LENGTH_KPC=2.6;static DISK_SCALE_HEIGHT_KPC=.3;static BULGE_SCALE_KPC=.5;static BULGE_FLATTENING=.6;static BULGE_TO_LOCAL_DISK=20;static DUST_SCALE_LENGTH_KPC=3.5;static DUST_SCALE_HEIGHT_KPC=.1;static EXTINCTION_MAG_PER_KPC=.8;static NEAR_LIMIT_KPC=.01;static FAR_LIMIT_KPC=40;static STEPS=192;static OPAQUE_MAG=15;static PEAK_MAG_PER_ARCSEC2=21;static PEAK_RADIANCE=6.278;static PEAK_LONGITUDE_DEG=0;static PEAK_LATITUDE_DEG=4.5;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*Zt.anchor()}static anchor(){return Ls.fromMagPerArcsec2(Zt.PEAK_MAG_PER_ARCSEC2)/Zt.PEAK_RADIANCE}radianceTowards(t,e){return this.trace(t,e).light}extinctionTowards(t,e){return this.trace(t,e).extinctionMag}trace(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=Math.cos(i)*Math.sin(n),o=Math.sin(i);let c=0,l=0,h=0;const u=Math.log(Zt.NEAR_LIMIT_KPC),d=Math.log(Zt.FAR_LIMIT_KPC)-u;for(let f=0;f<Zt.STEPS;f++){const g=Math.exp(u+d*f/(Zt.STEPS-1)),v=g-h;h=g;const p=g-v/2,m=Zt.SUN_RADIUS_KPC+p*r,b=p*a,E=Zt.SUN_HEIGHT_KPC+p*o,M=Math.hypot(m,b),S=Math.exp(-(M-Zt.SUN_RADIUS_KPC)/Zt.DISK_SCALE_LENGTH_KPC-Math.abs(E)/Zt.DISK_SCALE_HEIGHT_KPC),w=Math.hypot(M,E/Zt.BULGE_FLATTENING),R=Zt.BULGE_TO_LOCAL_DISK*Math.exp(-w/Zt.BULGE_SCALE_KPC);if(c+=(S+R)*v*10**(-.4*l),l+=Zt.EXTINCTION_MAG_PER_KPC*Math.exp(-(M-Zt.SUN_RADIUS_KPC)/Zt.DUST_SCALE_LENGTH_KPC-(Math.abs(E)-Zt.SUN_HEIGHT_KPC)/Zt.DUST_SCALE_HEIGHT_KPC)*v,l>Zt.OPAQUE_MAG)break}return{light:c,extinctionMag:l}}values=new Float32Array(Zt.LONGITUDE_STEPS*Zt.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Zt.LATITUDE_STEPS}walk(t){const e=Zt.LONGITUDE_STEPS,n=Math.min(Zt.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=Ls.latitudeOfRowCoord((this.walked+.5)/Zt.LATITUDE_STEPS);for(let r=0;r<e;r++)this.values[this.walked*e+r]=this.radianceTowards(360*(r+.5)/e,i)}}harvest(){let t=Number.POSITIVE_INFINITY;for(const i of this.values)i<t&&(t=i);const e=Zt.anchor(),n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-t)*e;return{width:Zt.LONGITUDE_STEPS,height:Zt.LATITUDE_STEPS,data:n}}}class Me{static LONGITUDE_STEPS=128;static LATITUDE_STEPS=96;static RADIAL_FALLOFF=1.3;static FAN_EXPONENT=2.6;static SUBLIMATION_AU=.1;static NEAR_LIMIT_AU=.004;static FAR_LIMIT_AU=8;static STEPS=224;static LOBE_ASYMMETRY=[.7,-.2,-.81];static LOBE_WEIGHT=[.665,.33,.00541];static RIGHT_ANGLE_S10=200;static POLE_S10=77;surfaceBrightnessS10(t,e){return this.radianceTowards(t,e)*this.anchor()}anchored;anchor(){return this.anchored===void 0&&(this.anchored=Me.RIGHT_ANGLE_S10/this.radianceTowards(90,0)),this.anchored}radianceTowards(t,e){const n=t*Math.PI/180,i=e*Math.PI/180,r=-Math.cos(i)*Math.cos(n),a=-Math.cos(i)*Math.sin(n),o=Math.sin(i),c=-r;let l=0,h=0;const u=Math.log(Me.NEAR_LIMIT_AU),d=Math.log(Me.FAR_LIMIT_AU)-u;for(let f=0;f<Me.STEPS;f++){const g=Math.exp(u+d*f/(Me.STEPS-1)),v=g-h;h=g;const p=g-v/2,m=1+p*r,b=p*a,E=p*o,M=Math.hypot(m,b,E);if(M<Me.SUBLIMATION_AU)continue;const S=E/M,w=M**-1.3*Math.exp(-2.6*Math.abs(S)),R=(c-p)/M;l+=w*this.scattering(R)*v/(M*M)}return l}scattering(t){let e=0;for(let n=0;n<Me.LOBE_ASYMMETRY.length;n++){const i=Me.LOBE_ASYMMETRY[n],r=1+i*i-2*i*t;e+=Me.LOBE_WEIGHT[n]*(1-i*i)/(4*Math.PI*r**1.5)}return e}values=new Float32Array(Me.LONGITUDE_STEPS*Me.LATITUDE_STEPS);walked=0;get done(){return this.walked>=Me.LATITUDE_STEPS}walk(t){const e=Me.LONGITUDE_STEPS,n=Math.min(Me.LATITUDE_STEPS,this.walked+t);for(;this.walked<n;this.walked++){const i=Ls.latitudeOfRowCoord((this.walked+.5)/Me.LATITUDE_STEPS);for(let r=0;r<e;r++){const a=Ls.angleOfColumnCoord((r+.5)/e);this.values[this.walked*e+r]=this.radianceTowards(a,i)}}}harvest(){const t=this.anchor();let e=Number.POSITIVE_INFINITY;for(const i of this.values)i<e&&(e=i);const n=new Float32Array(this.values.length);for(let i=0;i<n.length;i++)n[i]=(this.values[i]-e)*t;return{width:Me.LONGITUDE_STEPS,height:Me.LATITUDE_STEPS,data:n}}}class Kt{static get NANOLAMBERTS_PER_S10(){return Kt.toNanolamberts(10+2.5*Math.log10(3600*3600))}static nanolambertsOfS10(t){return t*Kt.NANOLAMBERTS_PER_S10}static TWILIGHT=[{sunAltitudeDeg:90,magPerArcsec2:3.5},{sunAltitudeDeg:10,magPerArcsec2:4.2},{sunAltitudeDeg:0,magPerArcsec2:7.5},{sunAltitudeDeg:-4,magPerArcsec2:13},{sunAltitudeDeg:-6,magPerArcsec2:15.6},{sunAltitudeDeg:-8,magPerArcsec2:17.2},{sunAltitudeDeg:-10,magPerArcsec2:18.5},{sunAltitudeDeg:-12,magPerArcsec2:19.7},{sunAltitudeDeg:-14,magPerArcsec2:20.8},{sunAltitudeDeg:-16,magPerArcsec2:21.6},{sunAltitudeDeg:-18,magPerArcsec2:21.9},{sunAltitudeDeg:-24,magPerArcsec2:22}];static moonlessMagPerArcsec2(t){const e=Kt.TWILIGHT;for(let n=0;n<e.length-1;n++){const i=e[n],r=e[n+1];if(t<=i.sunAltitudeDeg&&t>=r.sunAltitudeDeg){const a=(i.sunAltitudeDeg-t)/(i.sunAltitudeDeg-r.sunAltitudeDeg);return i.magPerArcsec2+(r.magPerArcsec2-i.magPerArcsec2)*a}}return t>0?e[0].magPerArcsec2:e[e.length-1].magPerArcsec2}static toNanolamberts(t){return 34.08*Math.exp(Kt.NANOLAMBERT_OFFSET-Kt.PER_MAGNITUDE*t)}static fromNanolamberts(t){return(Kt.NANOLAMBERT_OFFSET-Math.log(Math.max(t,1e-6)/34.08))/Kt.PER_MAGNITUDE}static NANOLAMBERT_OFFSET=20.7233;static PER_MAGNITUDE=Math.LN10/2.5;static airMass(t){const e=Math.cos(Math.max(t,0)*Math.PI/180);return 1/Math.sqrt(Math.max(1-.96*e*e,.001))}static EXTINCTION_PER_AIR_MASS=.172;static scatteringAt(t){const e=Math.min(Math.max(t,0),180)*Math.PI/180;return 10**5.36*(1.06+Math.cos(e)**2)+10**(6.15-Math.min(t,180)/40)}static scatteredFraction(t){return 1-10**(-.4*Kt.EXTINCTION_PER_AIR_MASS*Kt.airMass(t))}static AIRGLOW_MAG_PER_ARCSEC2=22;static twilightExcessNanolamberts(t){return Math.max(0,Kt.toNanolamberts(Kt.moonlessMagPerArcsec2(t))-Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2))}static twilightOutput(t){const e=Kt.scatteringAt(90-t)*Kt.scatteredFraction(90);return Kt.twilightExcessNanolamberts(t)/e}static moonNanolamberts(t,e,n,i){return Kt.scatteringAt(n)*Kt.moonOutput(t,e)*Kt.scatteredFraction(i)}static moonOutput(t,e){if(e<=0)return 0;const n=Math.min(Math.abs(t),180);return 10**(-.4*(3.84+.026*n+4e-9*n**4))*10**(-.4*Kt.EXTINCTION_PER_AIR_MASS*Kt.airMass(e))}static phaseAngleOf(t){return Math.acos(Math.min(Math.max(2*t-1,-1),1))*180/Math.PI}static magPerArcsec2(t,e,n){const i=Kt.scatteredFraction(n),r=Kt.scatteringAt(t.separationDeg)*Kt.twilightOutput(t.altitudeDeg)*i,a=Kt.scatteringAt(e.separationDeg)*Kt.moonOutput(e.phaseAngleDeg,e.altitudeDeg)*i;return Kt.fromNanolamberts(Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2)+r+a)}}class Vn{static RADIUS=890;static WORK_BUDGET_MS=6;static TOO_BRIGHT_MAG_PER_ARCSEC2=16;static MILKY_WAY_TINT=[.9,.94,1];static ZODIACAL_TINT=[1,.97,.9];object;material;galaxy=new Zt;dust=new Me;milkyWayTexture;zodiacalTexture;milkyWayTexels;zodiacalTexels;workHandle;repaint;constructor(){this.milkyWayTexels=new Uint16Array(Zt.LONGITUDE_STEPS*Zt.LATITUDE_STEPS*4),this.milkyWayTexture=Vn.buildTexture(this.milkyWayTexels,Zt.LONGITUDE_STEPS,Zt.LATITUDE_STEPS,Wo),this.zodiacalTexels=new Uint16Array(Me.LONGITUDE_STEPS*Me.LATITUDE_STEPS*4),this.zodiacalTexture=Vn.buildTexture(this.zodiacalTexels,Me.LONGITUDE_STEPS,Me.LATITUDE_STEPS,dn),this.material=new De({uniforms:{uMilkyWay:{value:this.milkyWayTexture},uZodiacal:{value:this.zodiacalTexture},uGalactic:{value:new Bt},uEclipticPole:{value:new P(0,1,0)},uSunLongitude:{value:new P(1,0,0)},uMoonDirection:{value:new P(0,-1,0)},uMoonOutput:{value:0},uSunDirection:{value:new P(0,-1,0)},uTwilightOutput:{value:0},uAirglowNanolamberts:{value:Kt.toNanolamberts(Kt.AIRGLOW_MAG_PER_ARCSEC2)},uSkyColor:{value:new P(0,0,0)},uMilkyWayTint:{value:new P(...Vn.MILKY_WAY_TINT)},uZodiacalTint:{value:new P(...Vn.ZODIACAL_TINT)},uReady:{value:0},uEncodeDestination:{value:1}},vertexShader:`
|
|
4968
4981
|
varying vec3 vDirection;
|
|
4969
4982
|
void main() {
|
|
4970
4983
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5079,13 +5092,13 @@ void main() {
|
|
|
5079
5092
|
vec3 onEncoded = encodeSrgb(uSkyColor + light) - encodeSrgb(uSkyColor);
|
|
5080
5093
|
gl_FragColor = vec4(mix(light, onEncoded, uEncodeDestination), 1.0);
|
|
5081
5094
|
}
|
|
5082
|
-
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(Vn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,n,i){const r=new Dr(t,e,n,fn,nn);return r.minFilter=ye,r.magFilter=ye,r.wrapS=i,r.wrapT=dn,r.needsUpdate=!0,r}set onReady(t){this.repaint=t}update(t){if(Kt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<Vn.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(t.galactic),n.uEclipticPole.value.copy(t.eclipticPole).normalize(),n.uSunLongitude.value.copy(t.sunLongitude).normalize(),n.uMoonDirection.value.copy(t.moon.direction).normalize(),n.uSunDirection.value.copy(t.sunDirection).normalize(),n.uMoonOutput.value=Kt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),n.uTwilightOutput.value=Kt.twilightOutput(t.sunAltitudeDeg),n.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{this.workHandle=void 0;const e=performance.now()+Vn.WORK_BUDGET_MS;for(;performance.now()<e&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Vn.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Vn.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(t,e){for(let n=0;n<e.data.length;n++)t[n*4]=as.toHalfFloat(Kt.nanolambertsOfS10(e.data[n])),t[n*4+3]=as.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Wn{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(t,e){return{centre:Wn.at(Wn.GALACTIC_CENTRE,t,e),rotation:Wn.at(Wn.GALACTIC_ROTATION,t,e),pole:Wn.at(Wn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Wn.at(Wn.ECLIPTIC_POLE,t,e)}static at(t,e,n){return Rr(t.raHours,t.decDeg,e,n,!1)}}const
|
|
5095
|
+
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(Vn.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}static buildTexture(t,e,n,i){const r=new Dr(t,e,n,fn,nn);return r.minFilter=ye,r.magFilter=ye,r.wrapS=i,r.wrapT=dn,r.needsUpdate=!0,r}set onReady(t){this.repaint=t}update(t){if(Kt.moonlessMagPerArcsec2(t.sunAltitudeDeg)<Vn.TOO_BRIGHT_MAG_PER_ARCSEC2){this.object.visible=!1,this.stopWork();return}const n=this.material.uniforms;n.uGalactic.value.copy(t.galactic),n.uEclipticPole.value.copy(t.eclipticPole).normalize(),n.uSunLongitude.value.copy(t.sunLongitude).normalize(),n.uMoonDirection.value.copy(t.moon.direction).normalize(),n.uSunDirection.value.copy(t.sunDirection).normalize(),n.uMoonOutput.value=Kt.moonOutput(t.moon.phaseAngleDeg,t.moon.altitudeDeg),n.uTwilightOutput.value=Kt.twilightOutput(t.sunAltitudeDeg),n.uSkyColor.value.copy(t.skyColor),this.object.visible=!0,n.uReady.value<.5&&this.scheduleWork()}setDestinationEncoded(t){this.material.uniforms.uEncodeDestination.value=t?1:0}hide(){this.object.visible=!1,this.stopWork()}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{this.workHandle=void 0;const e=performance.now()+Vn.WORK_BUDGET_MS;for(;performance.now()<e&&!(this.galaxy.done&&this.dust.done);)this.galaxy.walk(1),this.dust.walk(1);if(this.galaxy.done&&this.dust.done){this.publish();return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0}publish(){Vn.fill(this.milkyWayTexels,this.galaxy.harvest()),this.milkyWayTexture.needsUpdate=!0,Vn.fill(this.zodiacalTexels,this.dust.harvest()),this.zodiacalTexture.needsUpdate=!0,this.material.uniforms.uReady.value=1,this.repaint?.()}static fill(t,e){for(let n=0;n<e.data.length;n++)t[n*4]=as.toHalfFloat(Kt.nanolambertsOfS10(e.data[n])),t[n*4+3]=as.toHalfFloat(1)}dispose(){this.stopWork(),this.milkyWayTexture.dispose(),this.zodiacalTexture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Wn{static GALACTIC_CENTRE={raHours:266.4051/15,decDeg:-28.936175};static GALACTIC_ROTATION={raHours:318.00448/15,decDeg:48.32964};static GALACTIC_POLE={raHours:192.85948/15,decDeg:27.12825};static ECLIPTIC_POLE={raHours:18,decDeg:90-23.439291};static galactic(t,e){return{centre:Wn.at(Wn.GALACTIC_CENTRE,t,e),rotation:Wn.at(Wn.GALACTIC_ROTATION,t,e),pole:Wn.at(Wn.GALACTIC_POLE,t,e)}}static eclipticPole(t,e){return Wn.at(Wn.ECLIPTIC_POLE,t,e)}static at(t,e,n){return Rr(t.raHours,t.decDeg,e,n,!1)}}const KS=`
|
|
5083
5096
|
varying vec2 vUv;
|
|
5084
5097
|
void main() {
|
|
5085
5098
|
vUv = uv;
|
|
5086
5099
|
gl_Position = vec4(position, 1.0);
|
|
5087
5100
|
}
|
|
5088
|
-
|
|
5101
|
+
`,$S=`
|
|
5089
5102
|
// Based on https://www.shadertoy.com/view/4sX3Rs
|
|
5090
5103
|
uniform float uTime;
|
|
5091
5104
|
uniform vec2 uLensPosition;
|
|
@@ -5515,7 +5528,7 @@ void main()
|
|
|
5515
5528
|
// stays what it always was for the optional artifacts.
|
|
5516
5529
|
gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
|
|
5517
5530
|
}
|
|
5518
|
-
`;let yo;function
|
|
5531
|
+
`;let yo;function ZS(){if(yo)return yo;const s=256,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,s,s);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[i,r,a,o]of n){const c=e.createRadialGradient(i*s,r*s,0,i*s,r*s,a*s);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,s,s)}return yo=new _i(t),yo}function JS(){const s={uTime:{value:0},uResolution:{value:new Pt(1,1)},uLensPosition:{value:new Pt(0,0)},uColorGain:{value:new vt(55,55,51)},uOpacity:{value:.5},uFlareIntensity:{value:0},uStarPoints:{value:0},uTanHalfFov:{value:Math.tan(Math.PI/6)},uSourceRadiusDeg:{value:.265},uVeilStrength:{value:0},uDazzleColour:{value:new vt(1,1,1)},uFlareSize:{value:.0025},uFlareSpeed:{value:.4},uFlareShape:{value:1.2},uHaloScale:{value:.5},uGhostScale:{value:.3},uAnimated:{value:!1},uAnamorphic:{value:!1},uSecondaryGhosts:{value:!0},uStarBurst:{value:!0},uAdditionalStreaks:{value:!0},uLensDirtTexture:{value:ZS()}},t=new De({uniforms:s,vertexShader:KS,fragmentShader:$S,transparent:!0,depthWrite:!1,depthTest:!1,blending:Zn,fog:!1,name:"LensFlareShader"}),e=new $t(new Hi(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:s}}class ca{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new uc;quadCamera=new Ir(-1,1,1,-1,0,1);material;width;height;constructor(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target=new Sn(this.width,this.height,{type:nn}),this.material=new De({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Pt(this.width,this.height)},uEncodeOutput:{value:1}},vertexShader:`
|
|
5519
5532
|
varying vec2 vNdc;
|
|
5520
5533
|
void main() {
|
|
5521
5534
|
vNdc = position.xy;
|
|
@@ -5641,7 +5654,7 @@ void main()
|
|
|
5641
5654
|
`,fragmentShader:`
|
|
5642
5655
|
precision highp float;
|
|
5643
5656
|
${fm}
|
|
5644
|
-
${
|
|
5657
|
+
${XS}
|
|
5645
5658
|
varying vec3 vDirection;
|
|
5646
5659
|
uniform vec3 uSource;
|
|
5647
5660
|
uniform vec3 uUp;
|
|
@@ -5682,7 +5695,7 @@ void main()
|
|
|
5682
5695
|
// display fades at the edge of a fibre instead of ending on a cut line.
|
|
5683
5696
|
gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
|
|
5684
5697
|
}
|
|
5685
|
-
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(ri.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,i,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<ri.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=ri.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<ri.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(ri.RAYS_PER_FRAME);const e=this.sky.tracedRays>=ri.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=as.toHalfFloat(e[i]),this.texels[n+1]=as.toHalfFloat(e[i+1]),this.texels[n+2]=as.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class
|
|
5698
|
+
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(ri.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}set onReady(t){this.onRepaint=t}update(t,e,n,i,r,a){const o=this.material.uniforms;if(n<=0){o.uStrength.value=0,this.object.visible=!1,this.stopWork();return}o.uSource.value.set(t.x,t.y,t.z).normalize(),o.uStrength.value=n,o.uTint.value.set(i[0],i[1],i[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=this.everDisplayed,this.requestMap(e,a)}requestMap(t,e){!(!(Math.abs(t-this.mappedAltitudeDeg)<ri.ALTITUDE_STEP_DEG)||e!==this.mappedAlignment)||this.tracingFor(t,e)||(this.pendingAltitudeDeg=t,this.pendingAlignment=e,this.sky.begin(t,e),this.tracing=!0,this.nextGlimpse=ri.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<ri.ALTITUDE_STEP_DEG&&e===this.pendingAlignment}scheduleWork(){if(this.workHandle!==void 0)return;const t=()=>{if(this.workHandle=void 0,!this.tracing)return;this.sky.trace(ri.RAYS_PER_FRAME);const e=this.sky.tracedRays>=ri.RAYS,n=this.refining&&this.sky.tracedRays>=this.nextGlimpse;if(n&&(this.nextGlimpse*=2),(e||n)&&this.publish(),e){this.tracing=!1,this.refining=!1,this.mappedAltitudeDeg=this.pendingAltitudeDeg,this.mappedAlignment=this.pendingAlignment;return}this.workHandle=requestAnimationFrame(t)};this.workHandle=requestAnimationFrame(t)}stopWork(){this.workHandle!==void 0&&cancelAnimationFrame(this.workHandle),this.workHandle=void 0,this.tracing=!1}publish(){const e=this.sky.harvest().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=as.toHalfFloat(e[i]),this.texels[n+1]=as.toHalfFloat(e[i+1]),this.texels[n+2]=as.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.everDisplayed=!0,this.object.visible=this.material.uniforms.uStrength.value>0,this.onRepaint?.()}dispose(){this.stopWork(),this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class Le{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new yr;previous=Le.emergences();current=Le.emergences();tally=new Float32Array(Le.BINS*3);radiance=new Float32Array(Le.BINS*3);scratch=new Float32Array(Le.BINS*3);static emergences(){return Array.from({length:yr.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of Kn.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Le.BINS,data:this.radiance,binDeg:180/Le.BINS}}sweep(t){this.drop.refractiveIndex=Ye.indexAt(t.wavelengthNm);const e=Le.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const i=1/e;for(let r=1;r<=e;r++){const a=this.drop.trace(Math.sqrt(r/e),this.current);for(let o=0;o<Math.min(a,n);o++){const c=this.previous[o],l=this.current[o];c.chords===l.chords&&this.deposit(c.scatteringAngle,l.scatteringAngle,(c.weight+l.weight)/2*i,t)}n=a,this.copyInto(this.current,this.previous)}}copyInto(t,e){for(let n=0;n<t.length;n++)e[n].chords=t[n].chords,e[n].scatteringAngle=t[n].scatteringAngle,e[n].weight=t[n].weight}deposit(t,e,n,i){if(n<=0)return;const r=Le.BINS,a=Math.PI/r,o=Math.min(t,e),c=Math.max(t,e),l=c-o,h=Math.min(r-1,Math.max(0,Math.floor(o/a))),u=Math.min(r-1,Math.max(0,Math.floor(c/a)));if(l<=0||h===u){this.add(h,n,i);return}for(let d=h;d<=u;d++){const f=Math.min(c,(d+1)*a)-Math.max(o,d*a);f>0&&this.add(d,n*f/l,i)}}add(t,e,n){const i=t*3,r=e*Kn.SAMPLES.length;this.tally[i]+=r*n.r,this.tally[i+1]+=r*n.g,this.tally[i+2]+=r*n.b}toRadiance(){const t=Le.BINS,e=Math.PI/t;for(let n=0;n<t;n++){const i=2*Math.PI*(Math.cos(n*e)-Math.cos((n+1)*e)),r=i>0?this.backwardShare((n+.5)*(180/t))/i:0,a=n*3;this.radiance[a]=this.tally[a]*r,this.radiance[a+1]=this.tally[a+1]*r,this.radiance[a+2]=this.tally[a+2]*r}}backwardShare(t){const e=180-t;if(e<=Le.FULL_UNTIL_DEG)return 1;if(e>=Le.FADED_BY_DEG)return 0;const n=(e-Le.FULL_UNTIL_DEG)/(Le.FADED_BY_DEG-Le.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const t=Le.BINS,e=Le.SOURCE_RADIUS_DEG*t/180,n=Math.max(1,Math.ceil(e)),i=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);i.push(c),r+=c}if(!(r<=0)){this.scratch.set(this.radiance);for(let a=0;a<t;a++){let o=0,c=0,l=0;for(let u=-n;u<=n;u++){const d=Math.min(t-1,Math.max(0,a+u))*3,f=i[u+n];o+=this.scratch[d]*f,c+=this.scratch[d+1]*f,l+=this.scratch[d+2]*f}const h=a*3;this.radiance[h]=o/r,this.radiance[h+1]=c/r,this.radiance[h+2]=l/r}}}}class ha{static RADIUS=880;static GAIN=.22;static MOON_SATURATION=.15;object;material;sky=new Le;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Le.BINS*4),this.texture=new Dr(this.texels,Le.BINS,1,fn,nn),this.texture.minFilter=ye,this.texture.magFilter=ye,this.texture.wrapS=dn,this.texture.wrapT=dn,this.texture.needsUpdate=!0,this.material=new De({uniforms:{uSource:{value:new P(0,1,0)},uStrength:{value:0},uTint:{value:new P(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:ha.GAIN}},vertexShader:`
|
|
5686
5699
|
varying vec3 vDirection;
|
|
5687
5700
|
void main() {
|
|
5688
5701
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5710,7 +5723,7 @@ void main()
|
|
|
5710
5723
|
light = mix(vec3(grey), light, uSaturation);
|
|
5711
5724
|
gl_FragColor = vec4(light * uStrength, 1.0);
|
|
5712
5725
|
}
|
|
5713
|
-
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(ha.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,i){const r=this.material.uniforms;if(e<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(t.x,t.y,t.z).normalize(),r.uStrength.value=e,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=i?1:ha.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=as.toHalfFloat(e[i]),this.texels[n+1]=as.toHalfFloat(e[i+1]),this.texels[n+2]=as.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class pm{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 Rs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:i,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new pm(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(i-20)/52)),f=Rs.MAX_DURATION_MS-d*(Rs.MAX_DURATION_MS-Rs.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,p)=>v.t-p.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class qe{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=qe.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(qe.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=qe.MAX_CONCURRENT*qe.SEGMENTS*qe.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new be;e.setAttribute("position",new de(this.positions,3)),e.setAttribute("color",new de(this.colors,3)),e.setDrawRange(0,0),this.object=new $t(e,new Oi({vertexColors:!0,transparent:!0,blending:Zn,depthWrite:!1,fog:!1,side:qn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Rs.aliveAt(this.meteors,t).slice(0,qe.MAX_CONCURRENT);let i=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=cn(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),g=this.turn(l,h,r.bearingDeg),v=(.15+.85*r.brightness)*f,p=E=>v*E**1.6,m=E=>this.onSphere(c,g,d+(u-d)*E),b=E=>qe.RADIUS*((qe.MIN_HALF_WIDTH_DEG+qe.BRIGHT_HALF_WIDTH_DEG*r.brightness*E)*Math.PI/180);for(let E=1;E<qe.POINTS;E++){const M=(E-1)/qe.SEGMENTS,S=E/qe.SEGMENTS;i=this.pushRibbon(i,m(M),m(S),b(M),b(S),p(M),p(S))}}e.setDrawRange(0,i),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=cn(e.altitudeDeg,e.azimuthDeg,1),[i,r]=this.basisAround(n),a=this.turn(i,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<qe.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),g=this.across(e,c,i,u),v=this.across(n,c,r,u),p=(m,b)=>m===0?b:0;t=this.push(t,d,p(h,a)),t=this.push(t,f,p(h,o)),t=this.push(t,g,p(u,a)),t=this.push(t,f,p(h,o)),t=this.push(t,v,p(u,o)),t=this.push(t,g,p(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.9,this.colors[i+1]=r*.95,this.colors[i+2]=r,t+1}turn(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:(t.x*r+e.x*a)*qe.RADIUS,y:(t.y*r+e.y*a)*qe.RADIUS,z:(t.z*r+e.z*a)*qe.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const pl=Math.PI/180;function Le(s,t,e,n,i=!1){const r=i?new Oi({color:new vt(...e)}):new ba({color:new vt(...e)}),a=new $t(t,r);return a.position.y=n,a.userData={emissive:i},a.castShadow=!i,a.receiveShadow=!i,s.add(a),a}const j0=.25,KS=.002,$S=20;function ZS(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const mm=[.32,.32,.3],gm=[1,.85,.5],vm=[.25,.25,.25],xm=[1,.97,.85],JS=[.55,.68,.72],li=.03,hi=.05,_m={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 ln(s,t){return s?.[t]}function ui(s,t,e,n,i,r,a,o){if(o===void 0)return;const c=new ba({color:new vt(...JS),transparent:!0,opacity:o/100}),l=new $t(new Bn(t,e,n),c);l.position.set(i,r,a),s.add(l)}const Nn=.05,ml=[.6,.58,.53],tf=[.5,.5,.48];function dr(s,t,e,n,i,r,a,o){const c=new ba({color:new vt(...o),side:Be}),l=new $t(new Bn(t,e,n),c);l.position.set(i,r,a),s.add(l)}function QS(s,t,e,n,i,r,a,o,c){const l=(n-r)/2,h=(g,v,p,m)=>{g<=0||(t?dr(s,g,v,Nn,p,o+m,a,c):dr(s,Nn,v,g,a,o+m,p,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...i].sort((g,v)=>g.center-v.center);let d=-e/2;for(const g of u){const p=g.center-g.main/2-d;h(p,r,d+p/2,0),d=g.center+g.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function Mm(s,t,e,n,i,r,a,o,c,l){const h=(n+i)/2,u=i-n,d=(f,g,v,p)=>{f.length===0?g?dr(s,v,u,Nn,0,h,p,ml):dr(s,Nn,u,v,p,h,0,ml):QS(s,g,v,u,f,r,p,h,ml)};d(a,!0,t*2,-e+Nn),d(o,!0,t*2,e-Nn),d(c,!1,e*2,-t+Nn),d(l,!1,e*2,t-Nn),dr(s,t*2,Nn,e*2,0,n+Nn,0,tf),dr(s,t*2,Nn,e*2,0,i-Nn,0,tf)}function Zh(s,t,e,n){switch(s){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-di};case"front-right":return{x:t-n,z:-di};case"behind-left":return{x:-(t-n),z:di};case"behind-right":return{x:t-n,z:di}}}function ym(s,t,e,n,i,r,a){const o=jh();o.scale.setScalar(n),o.rotation.y=_m[t];const{x:c,z:l}=Zh(t,i,r,a);o.position.set(c,e,l),s.add(o)}const Jh=6,Qh=6,es=3,$r=1.4,Zr=es*.5,Sm=1.2,bm=.35,jS=.75,tb=1.6;function ef(s,t,e,n){const i=new en,r=Math.max(1,s+1),a=r*es;Le(i,new Bn(Jh,a,Qh),[.55,.54,.5],a/2);const o=Jh/2,c=Qh/2;for(let l=0;l<r;l++){const h=l*es+es/2;ui(i,$r,Zr,hi,0,h,-c-li,ln(t,"front")),ui(i,$r,Zr,hi,0,h,c+li,ln(t,"behind")),ui(i,hi,Zr,$r,-o-li,h,0,ln(t,"left")),ui(i,hi,Zr,$r,o+li,h,0,ln(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);ym(i,e,l*es,.72,o,c,Sm);const h=u=>ln(t,u)!==void 0?[{main:$r,center:0}]:[];Mm(i,o,c,l*es,(l+1)*es,Zr,h("front"),h("behind"),h("left"),h("right"))}return i}function nf(){const s=new en;return Le(s,new ki(.15,.22,2,8),[.32,.22,.14],1),Le(s,new Sa(1.4,3,8),[.16,.32,.14],3.5),s}const sf=.275,eb=.35,nb=.9,ib=34,sb=8,rb=1.4;function rf(){const s=new en,t=new pn(sf,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,eb/sf,1);const e=hn.repeatOnGrid(t,ib,nb,sb,rb),n=Le(s,e,[.26,.28,.22],0);return n.castShadow=!1,t.dispose(),s}function af(){const s=new en,t=new pn(1,7,3,0,Math.PI*2,0,Math.PI/2);return Le(s,t,[.38,.36,.32],0),s}function of(s){const t=new en;return Le(t,new ki(.05,.08,5,8),[.28,.28,.3],2.5),Le(t,new pn(.25,12,8),s?gm:mm,5.1,!0),t}const ab=[.08,.08,.08],ts=.8,cr=1,si=1.7,gl=.6,vs=.4,So=1.2,ar=.7,di=.5,ob=si;function cf(s,t,e){const n=new en;Le(n,new Bn(1.8,1.4,4.2),[.45,.14,.14],.7),Le(n,new Bn(ts*2,gl,cr*2),[.4,.12,.12],si);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Le(n,new ki(.4,.4,.3,12),ab,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const i=s?xm:vm;for(const r of[-.7,.7])Le(n,new pn(.15,8,6),i,.7,!0).position.set(r,.7,-2.1);if(ui(n,So,vs,hi,0,si,-cr-li,ln(t,"front")),ui(n,So,vs,hi,0,si,cr+li,ln(t,"behind")),ui(n,hi,vs,ar,-ts-li,si,-di,ln(t,"front-left")),ui(n,hi,vs,ar,-ts-li,si,di,ln(t,"behind-left")),ui(n,hi,vs,ar,ts+li,si,-di,ln(t,"front-right")),ui(n,hi,vs,ar,ts+li,si,di,ln(t,"behind-right")),e){ym(n,e,jS,.5,ts,cr,bm);const r=(c,l)=>{const h=[];return ln(t,c)!==void 0&&h.push({main:ar,center:-di}),ln(t,l)!==void 0&&h.push({main:ar,center:di}),h},a=ln(t,"front")!==void 0?[{main:So,center:0}]:[],o=ln(t,"behind")!==void 0?[{main:So,center:0}]:[];Mm(n,ts,cr,si-gl/2,si+gl/2,vs,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const lf=new Map;function hf(s,t){if(!s)return;const e=[[s.lengthM,t.lengthM],[s.heightM,t.heightM],[s.widthM,t.widthM]];for(const[n,i]of e)if(n!==void 0&&i>1e-6)return n/i}function vl(s,t){return t>1e-6?s/t:1}const Em=[.95,.9,.82],uf=[.72,.74,.78];function df(){const s=new en;Le(s,new ki(.25,.3,1.5,10),uf,.75),Le(s,new pn(.26,10,8),uf,1.74);const t=Le(s,new Sa(.07,.16,8),Em,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,s}function jh(){const s=new en;Le(s,new ki(.25,.3,1.5,10),[.3,.3,.35],.75),Le(s,new pn(.22,10,8),[.62,.52,.46],1.72);const t=Le(s,new Sa(.07,.16,8),Em,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,s}const cb=17,ff=18.5,xl=[.16,.16,.18];function pf(){const s=new en,t=Le(s,new ki(1.8,1.8,ff*2,10),xl,0);t.rotation.x=Math.PI/2,Le(s,new Bn(cb*2,.5,4.5),xl,0);const e=Le(s,new Bn(.4,5.5,4),xl,3);return e.position.z=-ff+2,s}class hn{static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=t.kind==="vehicle"?Zh(e,ts,cr,bm):Zh(e,Jh/2,Qh/2,Sm),r=t.kind==="vehicle"?ob:(t.occupiedFloor??0)*es+tb,a=(t.headingDeg??0)-_m[e]/pl,o=this.scaleFor(t);return{x:n*o.x,z:i*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(hn.BODY_NAME)??t}static repeatOnGrid(t,e,n,i,r){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*i,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),g=-((e-1)*n)/2,v=-((i-1)*r)/2;let p=0;for(let b=0;b<i;b++)for(let E=0;E<e;E++,p++){const M=v+b*r,S=g+E*n;for(let w=0;w<l;w++){const R=(p*l+w)*3;u[R]=a.getX(w)+M,u[R+1]=a.getY(w),u[R+2]=a.getZ(w)+S,d[R]=o.getX(w),d[R+1]=o.getY(w),d[R+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[p*c.count+w]=c.getX(w)+p*l}const m=new be;return m.setAttribute("position",new Se(u,3)),m.setAttribute("normal",new Se(d,3)),m.setIndex(new xu(f,1)),m}static paint(t,e){t.traverse(n=>{const i=n,r=i.userData;if(!i.isMesh||r?.emissive)return;const a=i.material;a?.color&&a.color.set(e)})}static build(t,e){const n=t.kind==="building"?ef(t.floors??ad,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?nf():t.kind==="crop"?rf():t.kind==="mound"?af():t.kind==="streetlight"?of(e):t.kind==="vehicle"?cf(e,t.windows,t.witnessSide):t.kind==="aircraft"?pf():t.kind==="entity"?df():jh();t.color&&this.paint(n,t.color);const i=this.scaleFor(t),r=new en;return n.name=hn.BODY_NAME,n.scale.copy(i),r.add(n),t.headingDeg!==void 0&&(r.rotation.y=-t.headingDeg*pl),this.addLights(r,t.lights),t.kind==="aircraft"&&this.exemptFromFog(r),r}static scaleFor(t){const e=t.sizeM;if(!e)return new P(1,1,1);const n=this.naturalSize(t.kind,t.floors);return new P(e.widthM===void 0?1:vl(e.widthM,n.widthM),e.heightM===void 0?1:vl(e.heightM,n.heightM),e.lengthM===void 0?1:vl(e.lengthM,n.lengthM))}static naturalSize(t,e){const n=t==="building"?Math.max(1,(e??ad)+1):0,i=`${t}:${n}`,r=lf.get(i);if(r)return r;const a=t==="building"?ef(n-1,void 0,void 0,void 0):t==="tree"?nf():t==="crop"?rf():t==="mound"?af():t==="streetlight"?of(!1):t==="vehicle"?cf(!1,void 0,void 0):t==="aircraft"?pf():t==="entity"?df():jh(),o=new xi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),lf.set(i,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&Qf(t.kind))}static applyModel(t,e,n,i={}){const r=this.bodyOf(t),a=new en;a.name=hn.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*pl,n.updateMatrixWorld(!0);const o=new xi().setFromObject(n),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=hf(e.sizeM,c)??hf(i.depictedSizeM,c)??1;n.scale.multiplyScalar(l);const h=o.getCenter(new P).multiplyScalar(l);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,n.traverse(u=>{u instanceof $t&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(n),r.parent?(r.parent.add(a),r.removeFromParent()):t.add(a),this.dispose(r)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static exemptFromFog(t){t.traverse(e=>{if(!(e instanceof $t))return;const n=e.material;n.fog=!1,n.needsUpdate=!0})}static addLights(t,e){for(const n of e??[]){const i=ZS(n.color),r=Le(t,new pn(j0,8,6),i,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:i},r.visible=!1}}static setLights(t,e,n,i,r=0){if(!e||e.length===0)return;const a=new Map(e.map(c=>[c.id,c])),o=Math.max(1,i*KS/j0);for(const c of t.children){if(!(c instanceof $t))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?jf(h,n,n+r):bg(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const g=r>0?u*$S*(h.intensity??1):u;d.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}c.scale.setScalar(o)}}static setLit(t,e,n){const i=e==="streetlight"?n?gm:mm:n?xm:vm;t.traverse(r=>{const a=r.userData;!(r instanceof $t)||!a.emissive||a.lightId||r.material.color.setRGB(...i)})}static dispose(t){t.traverse(e=>{if(!(e instanceof $t))return;e.geometry.dispose();const n=e.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const _l="https://ufoathome.org/models/index.json";class lb{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??hb()}async entries(t){const e=await this.load();return t?e.filter(n=>n.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const n=await e.json();return Array.isArray(n?.models)?n.models.map(({file:i,...r})=>({...r,url:new URL(i,t).href})):void 0}catch{return}}}function hb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==_l?[s,_l]:[_l]}const ub=[{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 lb}];async function db(s){const{GLTFLoader:t}=await Ul(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:n}},[],import.meta.url),e=new t;return new Promise((n,i)=>{e.load(s,r=>n(r.scene),void 0,r=>i(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const wm=2,fb=5,pb=2048;class Xn{constructor(t){this.scene=t}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new P;up=new P;lookAt=new Xt;vertex=new P;centre=new P;right=new P;above=new P;set(t,e){this.placed=t,this.frame=e;const n=new Set(t.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of t){let r=this.meshes.get(i.sourceId);r||(r=new $t(new Hi(1,1,Xn.SEGMENTS,Xn.SEGMENTS),new Oi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),r.frustumCulled=!1,r.layers.set(wm),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=fb+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,e)}}place(t,e,n){const i=this.frame;if(i)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=n(Xn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<Xn.FURTHEST_NDC&&Math.abs(d.ndcY)<Xn.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,t,e,i,o,l,h,r.distanceM):this.flat(a,t,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(t,e,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=t.geometry.attributes.position,d=Xn.SEGMENTS;let f=0;for(let g=0;g<=d;g++){const v=h+g/d*r.height;for(let p=0;p<=d;p++){const m=l+p/d*r.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(me.sizeMAt(c,i.projection.pxToDeg(r.width)),me.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(t,e,n,i,r){const a=t.geometry.attributes.position,o=Xn.SEGMENTS,c=me.sizeMAt(r,n.projection.pxToDeg(i.width)),l=me.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,r),this.lookAt.lookAt(e.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const g=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,g*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const n=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,n){const{shape:i}=e,r=Ol.paintExtent(i);this.extents.set(e.sourceId,r);const a=Xn.signatureOf(i,n);if(this.signatures.get(e.sourceId)===a&&t.material.map)return;this.signatures.set(e.sourceId,a);const o=Math.min(n.scale,pb/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=t.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const g=new Ol(f);if(g.setStarPoints(n.starPoints),g.setRoll(n.rollRad),g.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new _i(u);v.colorSpace=Rn,v.minFilter=ye,v.generateMipmaps=!1,t.material.map=v,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:n}=t;return JSON.stringify([t.kind,Math.round(n.width*10),Math.round(n.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function mb(s,t){return s.cloudCover===t.cloudCover&&s.cloudDarkness===t.cloudDarkness&&s.cloudBaseM===t.cloudBaseM&&s.highCloudCover===t.highCloudCover&&s.iceCrystalAlignment===t.iceCrystalAlignment&&s.lowerCloudCover===t.lowerCloudCover&&s.precipitationType===t.precipitationType&&s.precipitationIntensity===t.precipitationIntensity&&s.windDirectionDeg===t.windDirectionDeg&&s.windSpeed===t.windSpeed&&s.storm===t.storm}const bo=900,Ml=1,mf=.5,sa=900,gb=6371e3,vb=3e4;function gf(s){const t=Math.sqrt(2*gb*Math.max(s,0));return Math.max(sa,Math.min(t,vb))}const yl=.5,vf=850,xb=.03,Eo=850,Sl=4,xf=1.5,_f=-1,_b=6,tu=-4,Mf=.2,wo=2600,Mb=.97,yb=.38,yf=tu,Sb=3,bb=.15,Eb=.6,wb=40,Ab=30,Tb=[0,45,90,135,180,225,270,315],Rb={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Db=["en","fr"],Cb=880,bl=40,Pb=60,Ib=10,Lb=1,Nb=150,Ob=55,Ub=.5,Fb=2.05,Sf=.265,bf=[[0,0],...Array.from({length:8},(s,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Sf,Math.sin(e)*Sf]})],Ef=700,zb=250/Kf,Bb=12,wf=5,El=6,xs=[.92,.92,.95],wl=[.15,.15,.19],Af={snow:{fallSpeedMPerS:2,size:.3,color:new vt(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new vt(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},lr=0,Al=0,kb=150,Tf=3e3,Jr=20,Hb=15,Rf=lr,Gb=40,Df=1,Vb=9;function Cf(s){return Df+(Vb-Df)*s}const Wb=new vt(.75,.82,.92),Xb=10,qb=.5;function Yb(s){return ac(s/Xb,qb,1)}const or=200,Pf=.18,If=.32,Kb=.35,$b=new vt(.85,.9,.98),Lf=5,Nf=.85,Of=.01;function Tl(s,t){return Math.round(s*(Of+(1-Of)*t))}const Uf=230,Ff=.7,zf=.05,Zb=.6,Jb=.7,Qb=.15,Bf=.35,jb=3,tE=1/12,eE=.5,kf=8,Hf=25,Gf=.12,nE={Venus:new vt(1,.96,.85),Mars:new vt(1,.55,.4),Jupiter:new vt(.95,.87,.72),Saturn:new vt(.92,.86,.68)};class ai{renderer;scene=new uc;phenomena=new Xn(this.scene);camera;celestialGroup=new en;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=ub[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new H2(16777215,0);celestialLightTarget=new _e;skyLight=new U2(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new tl;weather=$f;observerElevationM=0;groundRadius=sa;terrainRadius=sa;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new P;rainLastVerticalFacing=-1;rainViewportSize=new Pt;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new P;sunVisible=!1;lensFlareScratch=new P;sunOcclusionRaycaster=new tl;sunOcclusionDirectionScratch=new P;sunOcclusionRightScratch=new P;sunOcclusionUpScratch=new P;ufoOcclusionRaycaster=new tl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(t,e=Og(),n){this.renderer=new Ky({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ra,this.camera=new yn(60,t.width/Math.max(t.height,1),.1,bo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*vn,n=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*vn;if(t.headingDeg!==void 0?this.camera.rotation.set(n,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*vn,e,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(gf(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/sa),this.camera.far=Math.max(bo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const i=un(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=un(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<Nb*(i/sa))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:t,lng:e},this.terrainRadius=i;const o=++this.terrainBuildToken;DS(t,e,this.terrainProviders,i).then(({mesh:c,attribution:l})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,u=r?un(t,e,r.lat,r.lng):void 0;h&&u&&Math.hypot(u.x,u.z)<=a&&(c.position.y=h.position.y+this.groundYOfPatch(h,u.x,u.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Lb,this.terrainMesh=c,this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.render(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=Ob*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=v3(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=gs(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=Fb**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;for(const e of this.compassSprites)e.visible=t;this.render()}setWeather(t){mb(this.weather,t)||(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=eE,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),hn.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=hn.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(t,e){const n=t.model;if(!(!n||!hn.usesModel(t)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await db(r);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;hn.applyModel(c,t,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${t.id}":`,i)}}updateDecorAnchoring(t,e,n=0){const i=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?un(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Qf(l.kind));r||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(r){const l=hn.occupantView(r),h=-(r.headingDeg??0)*vn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+i.x,g=-r.northM+i.z;a.x=-(f+u),a.z=-(g+d),this.camera.position.y=this.groundYUnder(f,g)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*vn,-(l.headingDeg+this.indoorLookYawDeg)*vn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=nu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.z+a.z;h.position.set(d,this.groundUnderFootprint(l,d,f,u.headingDeg)+u.altitudeM,f),l.kind==="crop"&&(h.visible=Math.hypot(d,f)<=kb),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*vn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(bo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,t-n.position.x,e-n.position.z):Al}groundYOfPatch(t,e,n){const i=t.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return Al;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=ac((e-a)/(o-a)*(r-1),0,r-1),u=ac((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Al;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),g=h-d,v=u-f,p=(E,M)=>i.getY(E*r+M),m=p(f,d)*(1-g)+p(f,d+1)*g,b=p(f+1,d)*(1-g)+p(f+1,d+1)*g;return m*(1-v)+b*v}groundUnderFootprint(t,e,n,i){const r=hn.sizeOf(t),a=(i??0)*vn,o=Math.sin(a)*(r.lengthM/2),c=-Math.cos(a)*(r.lengthM/2),l=Math.cos(a)*(r.widthM/2),h=Math.sin(a)*(r.widthM/2);let u=this.groundYUnder(e,n);for(const[d,f]of[[1,1],[1,-1],[-1,1],[-1,-1]])u=Math.max(u,this.groundYUnder(e+d*o+f*l,n+d*c+f*h));return u}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t,e=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&hn.setLights(i,n.lights,t,i.position.distanceTo(this.camera.position),e),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=Sg(n,t);hn.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(t,e){const n=hn.bodyOf(e),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new B2(16764006,wb,Ab);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,e.add(r),this.streetlightLights.set(t,r)}setAstronomy(t){const e=Ph(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n);const i=Wp(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,i),this.setBodyMesh("sun",t.sun,Sl,new vt(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,i),this.buildPlanets(t.planets,i),this.buildComet(t.comet,i),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.buildSkyGlow(t,e.zenith),this.scene.fog=new vu(new vt(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=Eb;const i=t.sun.altitudeDeg>=yf,r=!i&&t.moon.altitudeDeg>=yf;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?t.sun:t.moon,{x:o,y:c,z:l}=cn(a.altitudeDeg,a.azimuthDeg,Eo);this.celestialLight.position.set(o,c,l);const h=gs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*vn));this.celestialLight.intensity=(i?Sb:bb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new qe,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=ze.starPointsOf(t),n=ze.flareArtifactsOf(t);e===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(t){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(t,e){const n=e?Math.max(1,Math.round(t)):1;if(n===this.exposureInstants&&(n===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=n,this.exposureInstantAt=e,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){const e=this.usableEquidistantPass();this.phenomena.place(this.camera,(r,a,o)=>this.directionAtScreenPoint(r,a,o),r=>this.screenPointOf(r));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(t===void 0&&!r),t&&this.renderer.setRenderTarget(t),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i);return}e.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(!1),t&&this.renderer.setRenderTarget(t),e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const t=this.renderer.autoClear,e=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&ai.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(Ml),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(wm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=e}decorDepthMaterial=new Oi({colorWrite:!1});static markDecorDepth(t,e){t.traverse(n=>{if(!(n instanceof $t))return;const i=Array.isArray(n.material)?n.material[0]:n.material;e&&i.depthWrite!==!1&&i.blending!==Zn?n.layers.enable(Ml):n.layers.disable(Ml)})}startExposure(){this.cancelExposure();const t=this.renderer.getDrawingBufferSize(new Pt),e=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new $y(e,n)),this.exposureAccumulation.resize(e,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const n=1/this.exposureInstants,i=performance.now()+ai.EXPOSURE_BUDGET_MS;do this.restateAt(t,this.exposureInstantsDone),this.renderOnce(e.instantTarget),e.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i);this.restateAt(t,0),e.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new Pt),n=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new la(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Pt);if(ca.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new ca(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){t.setFromCamera(new Pt(e,n),this.camera);return}const r=i.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}directionAtScreenPoint(t,e,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(e.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return ca.ndcFor(e,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*vn);return{ndcX:e.x/-e.z/(i*r),ndcY:e.y/-e.z/r}}screenPointScratch=new P;screenPointQuaternion=new hs;screenPointSize=new Pt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(i,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let t=0;for(const e of bf)this.isSunOccluded(e[0],e[1])||t++;return t/bf.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const n=this.decorGroups.get(e.id);n&&t.push(n)}return t}isSunOccluded(t=0,e=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.raycastableDecor())n.push(o);if(n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}get lowerCloudUp(){return this.cloudMesh!==void 0&&this.lowerCloudCover()>0}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=mf;let i,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(t,e))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const n=this.raycaster.ray.direction,i=Math.cos(xb*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(t,e)?void 0:r}groundHides(t,e){const n=[this.terrainMesh,this.groundMesh].filter(i=>i!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=mf,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())hn.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;let t;const e=n=>{const i=t===void 0?0:Math.min((n-t)/1e3,tE);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,i),this.updateRain(i),this.updateLightning(n/1e3,i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(t){t!==this.animationsRunning&&(this.animationsRunning=t,t?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),t||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){this.disposeMesh(this.skyMesh);const e=new pn(bo,32,16),n=e.attributes.position,i=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=Qy(n.getX(a),n.getY(a),n.getZ(a)),l=a3(o,c,t.azimuthDeg,t.altitudeDeg);i.push(l[0],l[1],l[2])}e.setAttribute("color",new Se(i,3));const r=new Oi({vertexColors:!0,side:Be,fog:!1,depthWrite:!1});this.skyMesh=new $t(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=gf(this.observerElevationM);const t=new Mu(this.groundRadius,48),e=new ba({color:new vt(yl,yl,yl),fog:!0});this.groundMesh=new $t(t,e),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t){const e=cn(t.altitudeDeg,t.azimuthDeg,1);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ue.alphaAt(e,Math.abs(this.cloudLayerOffset()),i)*Mb);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ue.alphaAt(e,wo,r)*yb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,i,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<tu){this.bodyMeshes.delete(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=cn(e.altitudeDeg,e.azimuthDeg,Eo),l=gs(e.altitudeDeg),h=this.cloudTransmission(e),u=new vt(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h),d=new pn(n,16,16),f=new Oi({color:u,fog:!1}),g=new $t(d,f);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(t,g),this.setHitArea(t,a,o,c,n);const v=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,v,u),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=YS(),this.lensFlare.uniforms.uOpacity.value=Ub,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),t.magnitude>e||t.altitudeDeg<tu){this.bodyMeshes.delete(n);return}const{x:i,y:r,z:a}=cn(t.altitudeDeg,t.azimuthDeg,Eo),o=gs(t.altitudeDeg),c=new vt(o[0],o[1],o[2]),l=new ta({map:dE(t.phase),color:c,fog:!1}),h=new qa(l);h.position.set(i,r,a);const u=Sl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,i,r,a,Sl),this.setGlare(n,i,r,a,t.magnitude,c)}setHitArea(t,e,n,i,r){const a=new ta({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new qa(a);o.position.set(e,n,i);const c=r*_b;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(t,o)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,i,r,a){const o=l3(r);if(o<=0){this.disposeGlare(t);return}const c=d3(o),l=this.glareSprites.get(t),h=l??new qa(new ta({map:uE(),transparent:!0,blending:Zn,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=m3(o),h.position.set(e,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=cl(t.magnitude,e),r=ll(i);this.cometKey=n,this.setBodyMesh(n,t.position,xf*(.5+.5*i),new vt(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new An(Eo),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,i)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new ri,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:wo},0);return}const i=this.weather.lowerCloudCover??this.weather.cloudCover,r=te.deckLitUntilDeg(te.DECK_HEIGHT_M),a=t.altitudeDeg>-r?t:e,o=te.strength(n,i,a.altitudeDeg,r)*(a===t?1:Mf),{x:c,y:l,z:h}=cn(a.altitudeDeg,a.azimuthDeg,1),u=gs(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:wo},this.weather.iceCrystalAlignment??$m)}buildRainbow(t,e){this.rainbow||(this.rainbow=new ha,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=t.altitudeDeg>0,r=i?t:e,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=Mf*Mn.moonlightShare(e.magnitude),c=Mn.strength(n,a,r.altitudeDeg)*(i?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=cn(r.altitudeDeg,r.azimuthDeg,1),d=gs(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Vn,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=t.frame,r=Wn.galactic(n,i),a=ai.directionOf(r.centre),o=ai.directionOf(r.rotation),c=ai.directionOf(r.pole),l=new Bt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=ai.directionOf(Wn.eclipticPole(n,i)),u=ai.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:ai.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Kt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new P(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:n,z:i}=cn(t.altitudeDeg,t.azimuthDeg,1);return new P(e,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of t){if(i.magnitude>e)continue;n.add(i.body);const r=cl(i.magnitude,e),a=ll(r),o=nE[i.body]??new vt(1,1,1),c=new vt(o.r*a,o.g*a,o.b*a),l=xf*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(t,e){if(this.disposeStarTiers(),this.namedStars=[],!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=t,a=Rl(1337),o=[];for(let c=0;c<n.count;c++){const l=n.mag[c];if(l>e)break;const{altitudeDeg:h,azimuthDeg:u}=Rr(n.ra[c],n.dec[c],i,r);if(h<_f)continue;const{x:d,y:f,z:g}=cn(h,u,vf);o.push({x:d,y:f,z:g,brightness:cl(l,e),phase:a()*Math.PI*2,speedFactor:.7+a()*.6})}for(const c of bS){if(c.mag>e)continue;const{altitudeDeg:l,azimuthDeg:h}=Rr(c.raHours,c.decDeg,i,r);if(l<_f)continue;const{x:u,y:d,z:f}=cn(l,h,vf);this.namedStars.push({star:c,direction:new P(u,d,f).normalize(),altitudeDeg:l})}this.starTiers=qp.map((c,l)=>{const h=o.filter(E=>_3(E.brightness)===l),u=new Float32Array(h.length*3),d=new Float32Array(h.length),f=new Float32Array(h.length),g=new Float32Array(h.length);h.forEach((E,M)=>{u[M*3]=E.x,u[M*3+1]=E.y,u[M*3+2]=E.z,d[M]=E.brightness,f[M]=E.phase,g[M]=E.speedFactor});const v=new be;v.setAttribute("position",new de(u,3));const p=new de(new Float32Array(h.length*3),3);v.setAttribute("color",p);const m=new Rp({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Es.apply(m);const b=new Fo(v,m);return this.celestialGroup.add(b),{points:b,colorAttribute:p,brightness:d,phase:f,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let i=0;i<e.brightness.length;i++){const r=S3(e.brightness[i],{phase:e.phase[i],speedFactor:e.speedFactor[i]},t),a=ll(e.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const t=this.lowerCloudCover();if(t<=0)return;const e=this.weather.cloudDarkness,n=new vt(xs[0]+(wl[0]-xs[0])*e,xs[1]+(wl[1]-xs[1])*e,xs[2]+(wl[2]-xs[2])*e),{material:i,uniforms:r}=J0(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=Q0(Ef);this.cloudMesh=new $t(a,i),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=wf,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const t=this.weather.highCloudCover??0;if(t<=0)return;const{material:e,uniforms:n}=J0(new vt(...xs),t,wo,1);this.cirrusMaterial=e,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new $t(Q0(Ef*1.04),e),this.cirrusMesh.renderOrder=wf-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&(this.cloudMesh.scale.y=t<0?-1:1)}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Kf)-this.observerElevationM)*zb;return Math.sign(e||1)*Math.max(Math.abs(e),Bb)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:i,y:r,z:a}=cn(t.altitudeDeg,t.azimuthDeg,1),o=gs(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*vn));for(const l of n)l.sunDir.value.set(i,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.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=Af[t],n=e.poolSize,i=Rl(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),g=new Float32Array(n);for(let E=0;E<n;E++){const M=i()*Math.PI*2,S=i()*e.radiusM;r[E*3]=Math.cos(M)*S,r[E*3+1]=lr+i()*(e.topYM-lr),r[E*3+2]=Math.sin(M)*S,a[E]=i()*Math.PI*2,o[E]=.7+i()*.6,c[E]=.6+i()*.8,l[E]=.4+i()*1.2}const v=new be;v.setAttribute("position",new de(r,3)),v.setDrawRange(0,Tl(n,this.weather.precipitationIntensity));const p={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new vt(...this.baseFogColor)},uTexture:{value:iE(t)},uNearFocusDistance:{value:Lf},uHazeDistance:{value:e.radiusM*Nf}},m=new De({uniforms:p,vertexShader:lE,fragmentShader:hE,transparent:!0,depthWrite:!1});this.precipitationUniforms=p;const b=new Fo(v,m);b.renderOrder=El,this.scene.add(b),this.precipitationPoints=b,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=g}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=Af[n],r=this.weather.windDirectionDeg*vn,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,v=this.precipitationBounceDuration,p=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,b=n==="snow"&&u&&d,E=n==="hail"&&f&&g&&v&&p&&m;for(let M=0,S=0;M<c.length;M+=3,S++){if(E&&f[S]>0){if(f[S]-=e,f[S]<=0){const _=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[M]=Math.cos(_)*A,c[M+1]=i.topYM,c[M+2]=Math.sin(_)*A,f[S]=0}else{const _=1-f[S]/v[S];c[M+1]=lr+Math.sin(Math.PI*_)*g[S],c[M]=To(c[M]+(a+p[S])*e,i.radiusM),c[M+2]=To(c[M+2]+(o+m[S])*e,i.radiusM)}continue}let w=0,R=0;if(b){const _=Zb*u[S],A=Jb*d[S];w=Math.sin(t*_*Math.PI*2+l[S])*A,R=Math.sin(t*_*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=i.fallSpeedMPerS*h[S]*e,c[M+2]+=(o+R)*e,c[M]=To(c[M],i.radiusM),c[M+2]=To(c[M+2],i.radiusM),c[M+1]<lr){if(E){g[S]=Bf*(.2+Math.random()*1.6),v[S]=Qb*(.5+Math.random()),f[S]=v[S];const C=Math.random()*Math.PI*2,D=jb*(g[S]/Bf);p[S]=Math.cos(C)*D,m[S]=Math.sin(C)*D,c[M+1]=lr;continue}const _=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[M]=Math.cos(_)*A,c[M+1]=i.topYM,c[M+2]=Math.sin(_)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=Cf(this.weather.precipitationIntensity);this.rainSystem=BS({count:Tf,radiusM:Jr,heightM:Hb,bottomYM:Rf,overallSpeed:Gb,color:Wb,opacity:.85,visibleCount:Tl(Tf,this.weather.precipitationIntensity),speedStreak:Yb(t),pixelSize:Uf,seed:9001,nearFocusDistanceM:Lf,hazeDistanceM:Jr*Nf,hazeColor:new vt(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=El,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=Rl(4242),e=new Float32Array(or*3),n=new Float32Array(or),i=new Float32Array(or),r=new Float32Array(or);for(let h=0;h<or;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*Jr;e[h*3]=Math.cos(u)*d,e[h*3+1]=Rf,e[h*3+2]=Math.sin(u)*d,i[h]=Ao(Pf,If),n[h]=t()*i[h],r[h]=n[h]/i[h]}const a=new be;a.setAttribute("position",new de(e,3));const o=new de(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Tl(or,this.weather.precipitationIntensity));const c=new De({uniforms:{uMaxSize:{value:Kb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:$b},uTexture:{value:aE()}},vertexShader:oE,fragmentShader:cE,transparent:!0,depthWrite:!1}),l=new Fo(a,c);l.renderOrder=El,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*vn;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-Cf(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*vn,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=Jr,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+i*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Ff+(1-Ff)*(1-c),h=zf+(1-zf)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=Uf*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=t,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Jr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Ao(Pf,If),i[l]=0}o[l]=i[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/Gf;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+Ao(kf,Hf);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Gf,this.nextLightningAtS=t+Ao(kf,Hf),this.onLightningFlash?.())}}buildCompassLabels(){const t=eu(navigator.languages,Db),e=Rb[t];this.compassSprites=Tb.map((n,i)=>{const r=e[i],a=new ta({map:fE(r),depthTest:!1,fog:!1}),o=new qa(a),{x:c,y:l,z:h}=cn(0,n,Cb);return o.position.set(c,l,h),o.scale.set(bl,bl,1),o.renderOrder=Ib,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Pb*Math.PI/360,n=bl*Math.tan(t)/Math.tan(e);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const i=n.map;i&&i.dispose(),n.dispose()}}}const vn=Math.PI/180;function ac(s,t,e){return Math.max(t,Math.min(e,s))}function Ao(s,t){return s+Math.random()*(t-s)}function To(s,t){return(s%(t*2)+t*3)%(t*2)-t}let Ro,Do;function iE(s){switch(s){case"snow":return sE();case"hail":return rE()}}function sE(){if(Ro)return Ro;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Ro=new _i(t),Ro}function rE(){if(Do)return Do;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Do=new _i(t),Do}let Co;function aE(){if(Co)return Co;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Co=new _i(t),Co}const oE=`
|
|
5726
|
+
`,transparent:!0,blending:Zn,depthWrite:!1,side:Be,fog:!1}),this.object=new $t(new pn(ha.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,i){const r=this.material.uniforms;if(e<=0){r.uStrength.value=0,this.object.visible=!1;return}this.computed||this.publish(),r.uSource.value.set(t.x,t.y,t.z).normalize(),r.uStrength.value=e,r.uTint.value.set(n[0],n[1],n[2]),r.uSaturation.value=i?1:ha.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,i=0;i<e.length;n+=4,i+=3)this.texels[n]=as.toHalfFloat(e[i]),this.texels[n+1]=as.toHalfFloat(e[i+1]),this.texels[n+2]=as.toHalfFloat(e[i+2]),this.texels[n+3]=1;this.texture.needsUpdate=!0,this.computed=!0}dispose(){this.texture.dispose(),this.object.geometry.dispose(),this.material.dispose()}}class gm{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 Rs{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:i,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new gm(r),c=Math.floor(a),l=c+(o.next()<a-c?1:0),h=[];for(let u=0;u<l;u++){const d=Math.min(1,Math.max(0,(i-20)/52)),f=Rs.MAX_DURATION_MS-d*(Rs.MAX_DURATION_MS-Rs.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:f*o.between(.7,1.3),fromRadiantDeg:g,bearingDeg:o.between(0,360),lengthDeg:Math.sin(g*Math.PI/180)*o.between(8,40)*(.6+d),brightness:o.next()**3}),h.sort((v,p)=>v.t-p.t)}return h}static aliveAt(t,e){return t.filter(n=>e>=n.t&&e<=n.t+n.durationMs).map(n=>({meteor:n,progress:(e-n.t)/n.durationMs}))}}class qe{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=qe.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(qe.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=qe.MAX_CONCURRENT*qe.SEGMENTS*qe.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new be;e.setAttribute("position",new de(this.positions,3)),e.setAttribute("color",new de(this.colors,3)),e.setDrawRange(0,0),this.object=new $t(e,new Oi({vertexColors:!0,transparent:!0,blending:Zn,depthWrite:!1,fog:!1,side:qn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(t,e,n){this.meteors=t,this.radiantAltitudeDeg=e,this.radiantAzimuthDeg=n}update(t){const e=this.object.geometry;if(this.meteors.length===0){e.setDrawRange(0,0);return}const n=Rs.aliveAt(this.meteors,t).slice(0,qe.MAX_CONCURRENT);let i=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=cn(o.altitudeDeg,o.azimuthDeg,1),[l,h]=this.basisAround(c),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),f=Math.min(1,(1-a)*2.5),g=this.turn(l,h,r.bearingDeg),v=(.15+.85*r.brightness)*f,p=E=>v*E**1.6,m=E=>this.onSphere(c,g,d+(u-d)*E),b=E=>qe.RADIUS*((qe.MIN_HALF_WIDTH_DEG+qe.BRIGHT_HALF_WIDTH_DEG*r.brightness*E)*Math.PI/180);for(let E=1;E<qe.POINTS;E++){const M=(E-1)/qe.SEGMENTS,S=E/qe.SEGMENTS;i=this.pushRibbon(i,m(M),m(S),b(M),b(S),p(M),p(S))}}e.setDrawRange(0,i),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=cn(e.altitudeDeg,e.azimuthDeg,1),[i,r]=this.basisAround(n),a=this.turn(i,r,t.bearingDeg),o=this.onSphere(n,a,t.fromRadiantDeg+t.lengthDeg/2),c=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/c)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(t){return t.radiant?t.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(t,e,n,i,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<qe.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,i,h),f=this.across(n,c,r,h),g=this.across(e,c,i,u),v=this.across(n,c,r,u),p=(m,b)=>m===0?b:0;t=this.push(t,d,p(h,a)),t=this.push(t,f,p(h,o)),t=this.push(t,g,p(u,a)),t=this.push(t,f,p(h,o)),t=this.push(t,v,p(u,o)),t=this.push(t,g,p(u,a))}return t}across(t,e,n,i){return{x:t.x+e.x*n*i,y:t.y+e.y*n*i,z:t.z+e.z*n*i}}push(t,e,n){const i=t*3;this.positions[i]=e.x,this.positions[i+1]=e.y,this.positions[i+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[i]=r*.9,this.colors[i+1]=r*.95,this.colors[i+2]=r,t+1}turn(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:t.x*r+e.x*a,y:t.y*r+e.y*a,z:t.z*r+e.z*a}}onSphere(t,e,n){const i=n*Math.PI/180,r=Math.cos(i),a=Math.sin(i);return{x:(t.x*r+e.x*a)*qe.RADIUS,y:(t.y*r+e.y*a)*qe.RADIUS,z:(t.z*r+e.z*a)*qe.RADIUS}}basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(t,e));return[n,this.normalise(this.cross(t,n))]}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const pl=Math.PI/180;function Ne(s,t,e,n,i=!1){const r=i?new Oi({color:new vt(...e)}):new ba({color:new vt(...e)}),a=new $t(t,r);return a.position.y=n,a.userData={emissive:i},a.castShadow=!i,a.receiveShadow=!i,s.add(a),a}const j0=.25,QS=.002,jS=20;function tb(s){const t=/^#([0-9a-f]{6})$/i.exec(s);if(!t)return[1,1,1];const e=parseInt(t[1],16);return[(e>>16&255)/255,(e>>8&255)/255,(e&255)/255]}const vm=[.32,.32,.3],xm=[1,.85,.5],_m=[.25,.25,.25],Mm=[1,.97,.85],eb=[.55,.68,.72],li=.03,hi=.05,ym={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 ln(s,t){return s?.[t]}function ui(s,t,e,n,i,r,a,o){if(o===void 0)return;const c=new ba({color:new vt(...eb),transparent:!0,opacity:o/100}),l=new $t(new Bn(t,e,n),c);l.position.set(i,r,a),s.add(l)}const Nn=.05,ml=[.6,.58,.53],tf=[.5,.5,.48];function dr(s,t,e,n,i,r,a,o){const c=new ba({color:new vt(...o),side:Be}),l=new $t(new Bn(t,e,n),c);l.position.set(i,r,a),s.add(l)}function nb(s,t,e,n,i,r,a,o,c){const l=(n-r)/2,h=(g,v,p,m)=>{g<=0||(t?dr(s,g,v,Nn,p,o+m,a,c):dr(s,Nn,v,g,a,o+m,p,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...i].sort((g,v)=>g.center-v.center);let d=-e/2;for(const g of u){const p=g.center-g.main/2-d;h(p,r,d+p/2,0),d=g.center+g.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function Sm(s,t,e,n,i,r,a,o,c,l){const h=(n+i)/2,u=i-n,d=(f,g,v,p)=>{f.length===0?g?dr(s,v,u,Nn,0,h,p,ml):dr(s,Nn,u,v,p,h,0,ml):nb(s,g,v,u,f,r,p,h,ml)};d(a,!0,t*2,-e+Nn),d(o,!0,t*2,e-Nn),d(c,!1,e*2,-t+Nn),d(l,!1,e*2,t-Nn),dr(s,t*2,Nn,e*2,0,n+Nn,0,tf),dr(s,t*2,Nn,e*2,0,i-Nn,0,tf)}function Zh(s,t,e,n){switch(s){case"front":return{x:0,z:-(e-n)};case"behind":return{x:0,z:e-n};case"left":return{x:-(t-n),z:0};case"right":return{x:t-n,z:0};case"front-left":return{x:-(t-n),z:-di};case"front-right":return{x:t-n,z:-di};case"behind-left":return{x:-(t-n),z:di};case"behind-right":return{x:t-n,z:di}}}function bm(s,t,e,n,i,r,a){const o=jh();o.scale.setScalar(n),o.rotation.y=ym[t];const{x:c,z:l}=Zh(t,i,r,a);o.position.set(c,e,l),s.add(o)}const Jh=6,Qh=6,es=3,$r=1.4,Zr=es*.5,Em=1.2,wm=.35,ib=.75,sb=1.6;function ef(s,t,e,n){const i=new en,r=Math.max(1,s+1),a=r*es;Ne(i,new Bn(Jh,a,Qh),[.55,.54,.5],a/2);const o=Jh/2,c=Qh/2;for(let l=0;l<r;l++){const h=l*es+es/2;ui(i,$r,Zr,hi,0,h,-c-li,ln(t,"front")),ui(i,$r,Zr,hi,0,h,c+li,ln(t,"behind")),ui(i,hi,Zr,$r,-o-li,h,0,ln(t,"left")),ui(i,hi,Zr,$r,o+li,h,0,ln(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);bm(i,e,l*es,.72,o,c,Em);const h=u=>ln(t,u)!==void 0?[{main:$r,center:0}]:[];Sm(i,o,c,l*es,(l+1)*es,Zr,h("front"),h("behind"),h("left"),h("right"))}return i}function nf(){const s=new en;return Ne(s,new ki(.15,.22,2,8),[.32,.22,.14],1),Ne(s,new Sa(1.4,3,8),[.16,.32,.14],3.5),s}const sf=.275,rb=.35,ab=.9,ob=34,cb=8,lb=1.4;function rf(){const s=new en,t=new pn(sf,7,3,0,Math.PI*2,0,Math.PI/2);t.scale(1,rb/sf,1);const e=hn.repeatOnGrid(t,ob,ab,cb,lb),n=Ne(s,e,[.26,.28,.22],0);return n.castShadow=!1,t.dispose(),s}function af(){const s=new en,t=new pn(1,7,3,0,Math.PI*2,0,Math.PI/2);return Ne(s,t,[.38,.36,.32],0),s}function of(s){const t=new en;return Ne(t,new ki(.05,.08,5,8),[.28,.28,.3],2.5),Ne(t,new pn(.25,12,8),s?xm:vm,5.1,!0),t}const hb=[.08,.08,.08],ts=.8,cr=1,si=1.7,gl=.6,vs=.4,So=1.2,ar=.7,di=.5,ub=si;function cf(s,t,e){const n=new en;Ne(n,new Bn(1.8,1.4,4.2),[.45,.14,.14],.7),Ne(n,new Bn(ts*2,gl,cr*2),[.4,.12,.12],si);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ne(n,new ki(.4,.4,.3,12),hb,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const i=s?Mm:_m;for(const r of[-.7,.7])Ne(n,new pn(.15,8,6),i,.7,!0).position.set(r,.7,-2.1);if(ui(n,So,vs,hi,0,si,-cr-li,ln(t,"front")),ui(n,So,vs,hi,0,si,cr+li,ln(t,"behind")),ui(n,hi,vs,ar,-ts-li,si,-di,ln(t,"front-left")),ui(n,hi,vs,ar,-ts-li,si,di,ln(t,"behind-left")),ui(n,hi,vs,ar,ts+li,si,-di,ln(t,"front-right")),ui(n,hi,vs,ar,ts+li,si,di,ln(t,"behind-right")),e){bm(n,e,ib,.5,ts,cr,wm);const r=(c,l)=>{const h=[];return ln(t,c)!==void 0&&h.push({main:ar,center:-di}),ln(t,l)!==void 0&&h.push({main:ar,center:di}),h},a=ln(t,"front")!==void 0?[{main:So,center:0}]:[],o=ln(t,"behind")!==void 0?[{main:So,center:0}]:[];Sm(n,ts,cr,si-gl/2,si+gl/2,vs,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const lf=new Map;function hf(s,t){if(!s)return;const e=[[s.lengthM,t.lengthM],[s.heightM,t.heightM],[s.widthM,t.widthM]];for(const[n,i]of e)if(n!==void 0&&i>1e-6)return n/i}function vl(s,t){return t>1e-6?s/t:1}const Am=[.95,.9,.82],uf=[.72,.74,.78];function df(){const s=new en;Ne(s,new ki(.25,.3,1.5,10),uf,.75),Ne(s,new pn(.26,10,8),uf,1.74);const t=Ne(s,new Sa(.07,.16,8),Am,1.74);return t.rotation.x=-Math.PI/2,t.position.z=-.22,s}function jh(){const s=new en;Ne(s,new ki(.25,.3,1.5,10),[.3,.3,.35],.75),Ne(s,new pn(.22,10,8),[.62,.52,.46],1.72);const t=Ne(s,new Sa(.07,.16,8),Am,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,s}const db=17,ff=18.5,xl=[.16,.16,.18];function pf(){const s=new en,t=Ne(s,new ki(1.8,1.8,ff*2,10),xl,0);t.rotation.x=Math.PI/2,Ne(s,new Bn(db*2,.5,4.5),xl,0);const e=Ne(s,new Bn(.4,5.5,4),xl,3);return e.position.z=-ff+2,s}class hn{static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:i}=t.kind==="vehicle"?Zh(e,ts,cr,wm):Zh(e,Jh/2,Qh/2,Em),r=t.kind==="vehicle"?ub:(t.occupiedFloor??0)*es+sb,a=(t.headingDeg??0)-ym[e]/pl,o=this.scaleFor(t);return{x:n*o.x,z:i*o.z,eyeY:r*o.y,headingDeg:a}}static BODY_NAME="decor-body";static bodyOf(t){return t.getObjectByName(hn.BODY_NAME)??t}static repeatOnGrid(t,e,n,i,r){const a=t.getAttribute("position"),o=t.getAttribute("normal"),c=t.getIndex();if(!c)throw new Error("repeatOnGrid needs an indexed geometry");const l=a.count,h=e*i,u=new Float32Array(l*h*3),d=new Float32Array(l*h*3),f=new Uint32Array(c.count*h),g=-((e-1)*n)/2,v=-((i-1)*r)/2;let p=0;for(let b=0;b<i;b++)for(let E=0;E<e;E++,p++){const M=v+b*r,S=g+E*n;for(let w=0;w<l;w++){const R=(p*l+w)*3;u[R]=a.getX(w)+M,u[R+1]=a.getY(w),u[R+2]=a.getZ(w)+S,d[R]=o.getX(w),d[R+1]=o.getY(w),d[R+2]=o.getZ(w)}for(let w=0;w<c.count;w++)f[p*c.count+w]=c.getX(w)+p*l}const m=new be;return m.setAttribute("position",new Se(u,3)),m.setAttribute("normal",new Se(d,3)),m.setIndex(new xu(f,1)),m}static paint(t,e){t.traverse(n=>{const i=n,r=i.userData;if(!i.isMesh||r?.emissive)return;const a=i.material;a?.color&&a.color.set(e)})}static build(t,e){const n=t.kind==="building"?ef(t.floors??ad,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?nf():t.kind==="crop"?rf():t.kind==="mound"?af():t.kind==="streetlight"?of(e):t.kind==="vehicle"?cf(e,t.windows,t.witnessSide):t.kind==="aircraft"?pf():t.kind==="entity"?df():jh();t.color&&this.paint(n,t.color);const i=this.scaleFor(t),r=new en;return n.name=hn.BODY_NAME,n.scale.copy(i),r.add(n),t.headingDeg!==void 0&&(r.rotation.y=-t.headingDeg*pl),this.addLights(r,t.lights),t.kind==="aircraft"&&this.exemptFromFog(r),r}static scaleFor(t){const e=t.sizeM;if(!e)return new P(1,1,1);const n=this.naturalSize(t.kind,t.floors);return new P(e.widthM===void 0?1:vl(e.widthM,n.widthM),e.heightM===void 0?1:vl(e.heightM,n.heightM),e.lengthM===void 0?1:vl(e.lengthM,n.lengthM))}static naturalSize(t,e){const n=t==="building"?Math.max(1,(e??ad)+1):0,i=`${t}:${n}`,r=lf.get(i);if(r)return r;const a=t==="building"?ef(n-1,void 0,void 0,void 0):t==="tree"?nf():t==="crop"?rf():t==="mound"?af():t==="streetlight"?of(!1):t==="vehicle"?cf(!1,void 0,void 0):t==="aircraft"?pf():t==="entity"?df():jh(),o=new xi().setFromObject(a),c={widthM:o.max.x-o.min.x,heightM:o.max.y-o.min.y,lengthM:o.max.z-o.min.z};return this.dispose(a),lf.set(i,c),c}static usesModel(t){return t.model!==void 0&&!(t.witnessSide!==void 0&&Qf(t.kind))}static applyModel(t,e,n,i={}){const r=this.bodyOf(t),a=new en;a.name=hn.BODY_NAME,n.rotation.y=-(i.headingOffsetDeg??0)*pl,n.updateMatrixWorld(!0);const o=new xi().setFromObject(n),c={lengthM:o.max.z-o.min.z,heightM:o.max.y-o.min.y,widthM:o.max.x-o.min.x},l=hf(e.sizeM,c)??hf(i.depictedSizeM,c)??1;n.scale.multiplyScalar(l);const h=o.getCenter(new P).multiplyScalar(l);n.position.x-=h.x,n.position.z-=h.z,n.position.y-=e.kind==="aircraft"?h.y:o.min.y*l,n.traverse(u=>{u instanceof $t&&(u.castShadow=!0,u.receiveShadow=!0)}),a.add(n),r.parent?(r.parent.add(a),r.removeFromParent()):t.add(a),this.dispose(r)}static sizeOf(t){const e=this.naturalSize(t.kind,t.floors);return{widthM:t.sizeM?.widthM??e.widthM,lengthM:t.sizeM?.lengthM??e.lengthM,heightM:t.sizeM?.heightM??e.heightM}}static exemptFromFog(t){t.traverse(e=>{if(!(e instanceof $t))return;const n=e.material;n.fog=!1,n.needsUpdate=!0})}static addLights(t,e){for(const n of e??[]){const i=tb(n.color),r=Ne(t,new pn(j0,8,6),i,n.offsetM.y,!0);r.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),r.userData={emissive:!0,lightId:n.id,lightColor:i},r.visible=!1}}static setLights(t,e,n,i,r=0){if(!e||e.length===0)return;const a=new Map(e.map(c=>[c.id,c])),o=Math.max(1,i*QS/j0);for(const c of t.children){if(!(c instanceof $t))continue;const l=c.userData.lightId;if(!l)continue;const h=a.get(l);if(!h)continue;const u=r>0?jf(h,n,n+r):wg(h,n)?1:0;c.visible=u>0;const d=c.material,f=c.userData.lightColor;if(f){const g=r>0?u*jS*(h.intensity??1):u;d.color.setRGB(f[0]*g,f[1]*g,f[2]*g)}c.scale.setScalar(o)}}static setLit(t,e,n){const i=e==="streetlight"?n?xm:vm:n?Mm:_m;t.traverse(r=>{const a=r.userData;!(r instanceof $t)||!a.emissive||a.lightId||r.material.color.setRGB(...i)})}static dispose(t){t.traverse(e=>{if(!(e instanceof $t))return;e.geometry.dispose();const n=e.material;for(const i of Array.isArray(n)?n:[n])i.dispose()})}}const _l="https://ufoathome.org/models/index.json";class fb{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??pb()}async entries(t){const e=await this.load();return t?e.filter(n=>n.kind===t):e}async entry(t){return(await this.load()).find(e=>e.id===t)}load(){return this.loading??=this.fetchFirstAvailable(),this.loading}async fetchFirstAvailable(){for(const t of this.indexUrls){const e=await this.fetchIndex(t);if(e)return e}return[]}async fetchIndex(t){try{const e=await this.fetchImpl(t);if(!e.ok)return;const n=await e.json();return Array.isArray(n?.models)?n.models.map(({file:i,...r})=>({...r,url:new URL(i,t).href})):void 0}catch{return}}}function pb(){const s=typeof location>"u"?void 0:new URL("/models/index.json",location.href).href;return s&&s!==_l?[s,_l]:[_l]}const mb=[{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 fb}];async function gb(s){const{GLTFLoader:t}=await Ul(async()=>{const{GLTFLoader:n}=await import("./GLTFLoader-BumifFuq.js");return{GLTFLoader:n}},[],import.meta.url),e=new t;return new Promise((n,i)=>{e.load(s,r=>n(r.scene),void 0,r=>i(new Error(`Could not load 3D model ${s}: ${r instanceof Error?r.message:String(r)}`)))})}const Tm=2,vb=5,xb=2048;class Xn{constructor(t){this.scene=t}meshes=new Map;signatures=new Map;extents=new Map;placed=[];frame;direction=new P;up=new P;lookAt=new Xt;vertex=new P;centre=new P;right=new P;above=new P;set(t,e){this.placed=t,this.frame=e;const n=new Set(t.map(i=>i.sourceId));for(const[i,r]of this.meshes)n.has(i)||(this.dispose(r),this.meshes.delete(i),this.signatures.delete(i),this.extents.delete(i));for(const i of t){let r=this.meshes.get(i.sourceId);r||(r=new $t(new Hi(1,1,Xn.SEGMENTS,Xn.SEGMENTS),new Oi({transparent:!0,depthWrite:!1,depthTest:!0,fog:!1,toneMapped:!1})),r.frustumCulled=!1,r.layers.set(Tm),this.scene.add(r),this.meshes.set(i.sourceId,r)),r.renderOrder=vb+i.renderOrder,r.visible=!i.hidden&&i.shape.transparency<1,r.visible&&this.paint(r,i,e)}}place(t,e,n){const i=this.frame;if(i)for(const r of this.placed){const a=this.meshes.get(r.sourceId);if(!a||!a.visible)continue;const o=this.extents.get(r.sourceId);if(!o)continue;const{bounds:c}=r.shape;let l=c.x+c.width/2,h=c.y+c.height/2,u=!0;if(r.aim){const d=n(Xn.directionOf(r.aim,this.direction));d&&Math.abs(d.ndcX)<Xn.FURTHEST_NDC&&Math.abs(d.ndcY)<Xn.FURTHEST_NDC?(l=(d.ndcX+1)/2*i.canvasWidthPx,h=(1-d.ndcY)/2*i.canvasHeightPx):u=!1}u?this.curve(a,t,e,i,o,l,h,r.distanceM):this.flat(a,t,i,o,r.distanceM)}}static FURTHEST_NDC=4;curve(t,e,n,i,r,a,o,c){const l=a-r.width/2,h=o-r.height/2,u=t.geometry.attributes.position,d=Xn.SEGMENTS;let f=0;for(let g=0;g<=d;g++){const v=h+g/d*r.height;for(let p=0;p<=d;p++){const m=l+p/d*r.width;n(m/i.canvasWidthPx*2-1,-(v/i.canvasHeightPx*2-1),this.direction),this.vertex.copy(e.position).addScaledVector(this.direction,c),u.setXYZ(f++,this.vertex.x,this.vertex.y,this.vertex.z)}}u.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(me.sizeMAt(c,i.projection.pxToDeg(r.width)),me.sizeMAt(c,i.projection.pxToDeg(r.height)),1)}flat(t,e,n,i,r){const a=t.geometry.attributes.position,o=Xn.SEGMENTS,c=me.sizeMAt(r,n.projection.pxToDeg(i.width)),l=me.sizeMAt(r,n.projection.pxToDeg(i.height));this.up.set(0,1,0).applyQuaternion(e.quaternion),this.centre.copy(e.position).addScaledVector(this.direction,r),this.lookAt.lookAt(e.position,this.centre,this.up),this.right.setFromMatrixColumn(this.lookAt,0),this.above.setFromMatrixColumn(this.lookAt,1);let h=0;for(let u=0;u<=o;u++){const d=.5-u/o;for(let f=0;f<=o;f++){const g=f/o-.5;this.vertex.copy(this.centre).addScaledVector(this.right,g*c).addScaledVector(this.above,d*l),a.setXYZ(h++,this.vertex.x,this.vertex.y,this.vertex.z)}}a.needsUpdate=!0,t.matrixAutoUpdate=!1,t.matrix.identity(),t.matrixWorldNeedsUpdate=!0,t.scale.set(c,l,1)}static SEGMENTS=16;static directionOf(t,e){const n=t.azimuthDeg*Math.PI/180,i=t.altitudeDeg*Math.PI/180;return e.set(Math.sin(n)*Math.cos(i),Math.sin(i),-Math.cos(n)*Math.cos(i))}get any(){for(const t of this.meshes.values())if(t.visible)return!0;return!1}get furthestM(){return this.placed.reduce((t,e)=>Math.max(t,e.distanceM),0)}paint(t,e,n){const{shape:i}=e,r=Ol.paintExtent(i);this.extents.set(e.sourceId,r);const a=Xn.signatureOf(i,n);if(this.signatures.get(e.sourceId)===a&&t.material.map)return;this.signatures.set(e.sourceId,a);const o=Math.min(n.scale,xb/Math.max(r.width,r.height,1)),c=Math.max(1,Math.ceil(r.width*o)),l=Math.max(1,Math.ceil(r.height*o)),h=t.material.map,u=h?.image??document.createElement("canvas"),d=u.width!==c||u.height!==l;d&&(u.width=c,u.height=l);const f=u.getContext("2d");if(!f)return;f.clearRect(0,0,c,l);const g=new Ol(f);if(g.setStarPoints(n.starPoints),g.setRoll(n.rollRad),g.paintInto(i,r,o),h&&!d){h.needsUpdate=!0;return}h?.dispose();const v=new _i(u);v.colorSpace=Rn,v.minFilter=ye,v.generateMipmaps=!1,t.material.map=v,t.material.needsUpdate=!0}static signatureOf(t,e){const{bounds:n}=t;return JSON.stringify([t.kind,Math.round(n.width*10),Math.round(n.height*10),t.color,t.angle,t.transparency,t.haloScale,t.blur??0,t.brightness??0,t.kind==="polygon"?t.points:void 0,e.scale,e.starPoints,e.rollRad])}dispose(t){t.removeFromParent(),t.geometry.dispose(),t.material.map?.dispose(),t.material.dispose()}clear(){for(const t of this.meshes.values())this.dispose(t);this.meshes.clear(),this.signatures.clear(),this.extents.clear(),this.placed=[]}}function _b(s,t){return s.cloudCover===t.cloudCover&&s.cloudDarkness===t.cloudDarkness&&s.cloudBaseM===t.cloudBaseM&&s.highCloudCover===t.highCloudCover&&s.iceCrystalAlignment===t.iceCrystalAlignment&&s.lowerCloudCover===t.lowerCloudCover&&s.precipitationType===t.precipitationType&&s.precipitationIntensity===t.precipitationIntensity&&s.windDirectionDeg===t.windDirectionDeg&&s.windSpeed===t.windSpeed&&s.storm===t.storm}const bo=900,Ml=1,mf=.5,sa=900,Mb=6371e3,yb=3e4;function gf(s){const t=Math.sqrt(2*Mb*Math.max(s,0));return Math.max(sa,Math.min(t,yb))}const yl=.5,vf=850,Sb=.03,Eo=850,Sl=4,xf=1.5,_f=-1,bb=6,tu=-4,Mf=.2,wo=2600,Eb=.97,wb=.38,yf=tu,Ab=3,Tb=.15,Rb=.6,Db=40,Cb=30,Pb=[0,45,90,135,180,225,270,315],Ib={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},Lb=["en","fr"],Nb=880,bl=40,Ob=60,Ub=10,Fb=1,zb=150,Bb=55,kb=.5,Hb=2.05,Sf=.265,bf=[[0,0],...Array.from({length:8},(s,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*Sf,Math.sin(e)*Sf]})],Ef=700,Gb=250/Kf,Vb=12,wf=5,El=6,xs=[.92,.92,.95],wl=[.15,.15,.19],Af={snow:{fallSpeedMPerS:2,size:.3,color:new vt(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new vt(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},lr=0,Al=0,Wb=150,Tf=3e3,Jr=20,Xb=15,Rf=lr,qb=40,Df=1,Yb=9;function Cf(s){return Df+(Yb-Df)*s}const Kb=new vt(.75,.82,.92),$b=10,Zb=.5;function Jb(s){return ac(s/$b,Zb,1)}const or=200,Pf=.18,If=.32,Qb=.35,jb=new vt(.85,.9,.98),Lf=5,Nf=.85,Of=.01;function Tl(s,t){return Math.round(s*(Of+(1-Of)*t))}const Uf=230,Ff=.7,zf=.05,tE=.6,eE=.7,nE=.15,Bf=.35,iE=3,sE=1/12,rE=.5,kf=8,Hf=25,Gf=.12,aE={Venus:new vt(1,.96,.85),Mars:new vt(1,.55,.4),Jupiter:new vt(.95,.87,.72),Saturn:new vt(.92,.86,.68)};class ai{renderer;scene=new uc;phenomena=new Xn(this.scene);camera;celestialGroup=new en;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;decorModelProvider=mb[0].create();decorModelToken=0;decorModelCredits=new Map;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new V2(16777215,0);celestialLightTarget=new _e;skyLight=new z2(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new tl;weather=$f;observerElevationM=0;groundRadius=sa;terrainRadius=sa;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new P;rainLastVerticalFacing=-1;rainViewportSize=new Pt;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new P;sunVisible=!1;lensFlareScratch=new P;sunOcclusionRaycaster=new tl;sunOcclusionDirectionScratch=new P;sunOcclusionRightScratch=new P;sunOcclusionUpScratch=new P;ufoOcclusionRaycaster=new tl;projectionKind="rectilinear";starPoints=0;namedStars=[];equidistantPass;depthOfFieldPass;exposureAccumulation;exposureInstants=1;get developingExposure(){return this.exposureInstants>1&&this.exposureInstantAt!==void 0}static EXPOSURE_BUDGET_MS=12;exposureFrameId=null;exposureInstantsDone=0;exposureInstantAt;restatingExposure=!1;lensOptics;instrumentMagnitudeGain=0;meteorSystem;cometTail;iceHalos;rainbow;skyGlow;cometKey;onLightningFlash;constructor(t,e=Fg(),n){this.renderer=new Zy({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ra,this.camera=new yn(60,t.width/Math.max(t.height,1),.1,bo*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=e,this.onLightningFlash=n,this.celestialLight.shadow.mapSize.set(1024,1024),this.celestialLight.shadow.camera.left=-120,this.celestialLight.shadow.camera.right=120,this.celestialLight.shadow.camera.top=120,this.celestialLight.shadow.camera.bottom=-120,this.celestialLight.shadow.camera.near=1,this.celestialLight.shadow.camera.far=1e3,this.celestialLight.shadow.bias=-.0015,this.celestialLight.target=this.celestialLightTarget,this.scene.add(this.celestialLight,this.celestialLightTarget,this.skyLight),this.scene.add(this.celestialGroup)}get currentTerrainAttribution(){return this.terrainAttribution}resize(t,e){this.renderer.setSize(t,e,!1),this.camera.aspect=t/Math.max(e,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(t){const e=((t.rollDeg??0)+this.gaitOffset.rollDeg)*vn,n=(t.pitchDeg+this.lookPitchDeg+this.gaitOffset.pitchDeg)*vn;if(t.headingDeg!==void 0?this.camera.rotation.set(n,-(t.headingDeg+this.lookYawDeg+this.gaitOffset.yawDeg)*vn,e,"YXZ"):this.camera.rotation.set(n,this.camera.rotation.y,e,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(gf(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/sa),this.camera.far=Math.max(bo*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.terrainMesh&&this.terrainOrigin&&t.lat!==void 0&&t.lng!==void 0){const i=un(this.terrainOrigin.lat,this.terrainOrigin.lng,t.lat,t.lng);this.terrainMesh.position.x=i.x,this.terrainMesh.position.z=i.z}this.poseCameraY=this.groundYUnder(0,0)+1.6+t.elevationM,this.camera.position.y=this.poseCameraY,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix(),this.updateCompassScale())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.applyGroundDepthWrite(),this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const i=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-i)<i*.1){const{x:c,z:l}=un(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(c*c+l*l)<zb*(i/sa))return}const r=this.terrainOrigin,a=this.terrainRadius;this.terrainOrigin={lat:t,lng:e},this.terrainRadius=i;const o=++this.terrainBuildToken;PS(t,e,this.terrainProviders,i).then(({mesh:c,attribution:l})=>{if(o!==this.terrainBuildToken)return;const h=this.terrainMesh,u=r?un(t,e,r.lat,r.lng):void 0;h&&u&&Math.hypot(u.x,u.z)<=a&&(c.position.y=h.position.y+this.groundYOfPatch(h,u.x,u.z)),this.disposeMesh(this.terrainMesh),c.renderOrder=Fb,this.terrainMesh=c,this.terrainAttribution=l,this.scene.add(c),this.applyGroundDepthWrite(),this.render(),n?.()}).catch(c=>{console.warn("Terrain build failed, keeping the flat ground fallback:",c),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=Bb*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(e*t[0],e*t[1],e*t[2]),this.applyDazzleStrength()}applyDazzleStrength(){if(!this.lensFlare)return;const t=this.lastSunPosition?.altitudeDeg??-90,e=_3(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=gs(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=Hb**2*Math.max(0,e)}setCompassHovered(t){this.compassHovered!==t&&(this.compassHovered=t,this.updateCompassVisibility())}setCompassForced(t){this.compassForced!==t&&(this.compassForced=t,this.updateCompassVisibility())}updateCompassVisibility(){const t=this.compassHovered||this.compassForced;for(const e of this.compassSprites)e.visible=t;this.render()}setWeather(t){_b(this.weather,t)||(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=rE,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t,this.decorModelToken++,this.decorModelCredits.clear();for(const e of this.decorGroups.values())e.removeFromParent(),hn.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=hn.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n),this.loadDecorModel(e,this.decorModelToken)}this.celestialLight.castShadow=this.decorGroups.size>0}}setDecorModelProvider(t){this.decorModelProvider=t;const e=this.decorObjects;this.decorObjects=[],this.setDecor(e)}get currentDecorModelCredits(){return[...this.decorModelCredits.values()]}async loadDecorModel(t,e){const n=t.model;if(!(!n||!hn.usesModel(t)))try{const i=n.url?void 0:n.id?await this.decorModelProvider.entry(n.id):void 0,r=n.url??i?.url,a=n.credit??i?.credit;if(!r||!a)return;const o=await gb(r);if(e!==this.decorModelToken)return;const c=this.decorGroups.get(t.id);if(!c)return;hn.applyModel(c,t,o,{headingOffsetDeg:n.headingOffsetDeg??i?.headingOffsetDeg,depictedSizeM:i?.sizeM}),this.decorModelCredits.set(t.id,a),this.render()}catch(i){console.warn(`Keeping the built-in shape for decor "${t.id}":`,i)}}updateDecorAnchoring(t,e,n=0){const i=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?un(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&Qf(l.kind));r||(i.x-=this.gaitOffset.eastM,i.z+=this.gaitOffset.northM,this.camera.position.y=this.poseCameraY+this.gaitOffset.upM,this.celestialGroup.position.y=this.camera.position.y);const a={x:0,z:0};let o=0;if(r){const l=hn.occupantView(r),h=-(r.headingDeg??0)*vn,u=l.x*Math.cos(h)+l.z*Math.sin(h),d=-l.x*Math.sin(h)+l.z*Math.cos(h),f=r.eastM+i.x,g=-r.northM+i.z;a.x=-(f+u),a.z=-(g+d),this.camera.position.y=this.groundYUnder(f,g)+l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*vn,-(l.headingDeg+this.indoorLookYawDeg)*vn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=nu(l,n),d=u.eastM+i.x+a.x,f=-u.northM+i.z+a.z;h.position.set(d,this.groundUnderFootprint(l,d,f,u.headingDeg)+u.altitudeM,f),l.kind==="crop"&&(h.visible=Math.hypot(d,f)<=Wb),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*vn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(bo*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}groundYUnder(t,e){const n=this.terrainMesh;return n?n.position.y+this.groundYOfPatch(n,t-n.position.x,e-n.position.z):Al}groundYOfPatch(t,e,n){const i=t.geometry.getAttribute("position"),r=Math.round(Math.sqrt(i.count));if(r<2||r*r!==i.count)return Al;const a=i.getX(0),o=i.getX(r-1),c=i.getZ(0),l=i.getZ((r-1)*r),h=ac((e-a)/(o-a)*(r-1),0,r-1),u=ac((n-c)/(l-c)*(r-1),0,r-1);if(!Number.isFinite(h)||!Number.isFinite(u))return Al;const d=Math.min(Math.floor(h),r-2),f=Math.min(Math.floor(u),r-2),g=h-d,v=u-f,p=(E,M)=>i.getY(E*r+M),m=p(f,d)*(1-g)+p(f,d+1)*g,b=p(f+1,d)*(1-g)+p(f+1,d+1)*g;return m*(1-v)+b*v}groundUnderFootprint(t,e,n,i){const r=hn.sizeOf(t),a=(i??0)*vn,o=Math.sin(a)*(r.lengthM/2),c=-Math.cos(a)*(r.lengthM/2),l=Math.cos(a)*(r.widthM/2),h=Math.sin(a)*(r.widthM/2);let u=this.groundYUnder(e,n);for(const[d,f]of[[1,1],[1,-1],[-1,1],[-1,-1]])u=Math.max(u,this.groundYUnder(e+d*o+f*l,n+d*c+f*h));return u}lookYawDeg=0;lookPitchDeg=0;poseCameraY=1.6;setGait(t){this.gaitOffset=t}gaitOffset={eastM:0,northM:0,upM:0,rollDeg:0,pitchDeg:0,yawDeg:0};setLookOffset(t,e){this.lookYawDeg=t,this.lookPitchDeg=e}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t,e=0){for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);if(i&&n.lights?.length&&hn.setLights(i,n.lights,t,i.position.distanceTo(this.camera.position),e),n.kind!=="streetlight"&&n.kind!=="vehicle")continue;const r=this.decorGroups.get(n.id);if(!r)continue;const a=Eg(n,t);hn.setLit(r,n.kind,a);const o=this.streetlightLights.get(n.id);o&&(o.visible=a)}}addStreetlightLight(t,e){const n=hn.bodyOf(e),i=n.children.find(a=>a.userData.emissive);if(!i)return;const r=new H2(16764006,Db,Cb);r.position.copy(i.position).multiply(n.scale),r.castShadow=!0,r.shadow.mapSize.set(512,512),r.shadow.bias=-.002,e.add(r),this.streetlightLights.set(t,r)}setAstronomy(t){const e=Ph(t.sun.altitudeDeg),n=e.horizon;this.baseFogColor=n,this.lastSunPosition=t.sun,this.buildSky(t.sun),this.buildGround(),this.updateCloudLighting(t.sun,n),this.updateCelestialLight(t,e.zenith,n);const i=Wp(t.sun.altitudeDeg,this.instrumentMagnitudeGain);this.buildStars(t.stars,i),this.setBodyMesh("sun",t.sun,Sl,new vt(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,i),this.buildPlanets(t.planets,i),this.buildComet(t.comet,i),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.buildSkyGlow(t,e.zenith),this.scene.fog=new vu(new vt(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(t,e,n){this.skyLight.color.setRGB(e[0],e[1],e[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=Rb;const i=t.sun.altitudeDeg>=yf,r=!i&&t.moon.altitudeDeg>=yf;if(!i&&!r){this.celestialLight.intensity=0;return}const a=i?t.sun:t.moon,{x:o,y:c,z:l}=cn(a.altitudeDeg,a.azimuthDeg,Eo);this.celestialLight.position.set(o,c,l);const h=gs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*vn));this.celestialLight.intensity=(i?Ab:Tb)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new qe,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(t,e,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(t){return this.meteorSystem?.midpointOf(t)}updateMeteors(t){this.meteorSystem?.update(t)}setInstrument(t){this.projectionKind=t.projection;const e=ze.starPointsOf(t),n=ze.flareArtifactsOf(t);e===this.starPoints&&n===this.lensFlareArtifactIntensity||(this.starPoints=e,this.lensFlareArtifactIntensity=n,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e,this.lensFlare.uniforms.uFlareIntensity.value=n),this.render())}setInstrumentGain(t){this.instrumentMagnitudeGain=Number.isFinite(t)?t:0}render(){this.restatingExposure||(this.renderOnce(),this.developingExposure&&this.startExposure())}setExposure(t,e){const n=e?Math.max(1,Math.round(t)):1;if(n===this.exposureInstants&&(n===1||e===this.exposureInstantAt)){this.exposureInstantAt=e;return}this.exposureInstants=n,this.exposureInstantAt=e,n===1&&(this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0),this.render()}renderOnce(t){const e=this.usableEquidistantPass();this.phenomena.place(this.camera,(r,a,o)=>this.directionAtScreenPoint(r,a,o),r=>this.screenPointOf(r));const n=this.phenomena.furthestM*1.2;n>this.camera.far&&(this.camera.far=n,this.camera.updateProjectionMatrix());const i=this.renderer.getRenderTarget();if(!e){this.updateLensFlarePosition();const r=this.usableDepthOfFieldPass();r?.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(t===void 0&&!r),t&&this.renderer.setRenderTarget(t),r?r.render(this.renderer,this.scene,this.camera,()=>this.renderPhenomenaPass()):(this.renderer.render(this.scene,this.camera),this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i);return}e.setEncodesOutput(t===void 0),this.skyGlow?.setDestinationEncoded(!1),t&&this.renderer.setRenderTarget(t),e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition(),()=>this.renderPhenomenaPass()),t&&this.renderer.setRenderTarget(i)}renderPhenomenaPass(){if(!this.phenomena.any)return;const t=this.renderer.autoClear,e=this.renderer.shadowMap.autoUpdate;this.renderer.autoClear=!1,this.renderer.shadowMap.autoUpdate=!1,this.renderer.clearDepth();for(const n of this.decorObjects){const i=this.decorGroups.get(n.id);i&&ai.markDecorDepth(i,n.kind!=="crop")}this.camera.layers.set(Ml),this.scene.overrideMaterial=this.decorDepthMaterial,this.renderer.render(this.scene,this.camera),this.scene.overrideMaterial=null,this.camera.layers.set(Tm),this.renderer.render(this.scene,this.camera),this.camera.layers.set(0),this.renderer.autoClear=t,this.renderer.shadowMap.autoUpdate=e}decorDepthMaterial=new Oi({colorWrite:!1});static markDecorDepth(t,e){t.traverse(n=>{if(!(n instanceof $t))return;const i=Array.isArray(n.material)?n.material[0]:n.material;e&&i.depthWrite!==!1&&i.blending!==Zn?n.layers.enable(Ml):n.layers.disable(Ml)})}startExposure(){this.cancelExposure();const t=this.renderer.getDrawingBufferSize(new Pt),e=Math.max(1,Math.round(t.x)),n=Math.max(1,Math.round(t.y));this.exposureAccumulation||(this.exposureAccumulation=new Jy(e,n)),this.exposureAccumulation.resize(e,n),this.exposureAccumulation.open(this.renderer),this.exposureInstantsDone=0,this.exposureFrameId=requestAnimationFrame(()=>this.developExposure())}developExposure(){this.exposureFrameId=null;const t=this.exposureInstantAt,e=this.exposureAccumulation;if(!t||!e)return;const n=1/this.exposureInstants,i=performance.now()+ai.EXPOSURE_BUDGET_MS;do this.restateAt(t,this.exposureInstantsDone),this.renderOnce(e.instantTarget),e.add(this.renderer,n),this.exposureInstantsDone++;while(this.exposureInstantsDone<this.exposureInstants&&performance.now()<i);this.restateAt(t,0),e.develop(this.renderer,this.exposureInstants/this.exposureInstantsDone),this.exposureInstantsDone<this.exposureInstants&&(this.exposureFrameId=requestAnimationFrame(()=>this.developExposure()))}restateAt(t,e){this.restatingExposure=!0;try{t(e)}finally{this.restatingExposure=!1}}cancelExposure(){this.exposureFrameId!==null&&(cancelAnimationFrame(this.exposureFrameId),this.exposureFrameId=null)}setLensOptics(t){const e=this.lensOptics;this.lensOptics=t,(e===void 0!=(t===void 0)||e&&t&&(e.focalLengthMm!==t.focalLengthMm||e.fNumber!==t.fNumber||e.focusDistance!==t.focusDistance||e.frameHeightMm!==t.frameHeightMm))&&(t&&this.depthOfFieldPass&&this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.render())}usableDepthOfFieldPass(){const t=this.lensOptics;if(!t)return;const e=this.renderer.getDrawingBufferSize(new Pt),n=Math.max(1,Math.round(e.x)),i=Math.max(1,Math.round(e.y));return this.depthOfFieldPass||(this.depthOfFieldPass=new la(n,i)),this.depthOfFieldPass.resize(n,i),this.depthOfFieldPass.setLens(t.focalLengthMm,t.fNumber,t.focusDistance,t.frameHeightMm),this.depthOfFieldPass}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Pt);if(ca.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new ca(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const i=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!i){t.setFromCamera(new Pt(e,n),this.camera);return}const r=i.directionFor(e,n,this.camera.fov);this.camera.updateMatrixWorld(),t.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),t.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),t.camera=this.camera}directionAtScreenPoint(t,e,n){return this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),n.copy(this.ufoOcclusionRaycaster.ray.direction)}screenPointOf(t){this.camera.updateMatrixWorld();const e=this.screenPointScratch.copy(t).applyQuaternion(this.screenPointQuaternion.copy(this.camera.quaternion).invert());if(e.z>=0)return;const n=this.renderer.getDrawingBufferSize(this.screenPointSize),i=n.x/Math.max(n.y,1);if(this.projectionKind==="equidistant"&&this.equidistantPass)return ca.ndcFor(e,this.camera.fov,i);const r=Math.tan(this.camera.fov/2*vn);return{ndcX:e.x/-e.z/(i*r),ndcY:e.y/-e.z/r}}screenPointScratch=new P;screenPointQuaternion=new hs;screenPointSize=new Pt;updateLensFlarePosition(){const t=this.lensFlare;if(!t)return;if(!this.sunVisible){t.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){t.mesh.visible=!1;return}const e=this.sunVisibleFraction();if(e<=0){t.mesh.visible=!1;return}t.mesh.visible=!0,this.sunUnhiddenFraction=e,this.applyDazzleStrength();const n=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);t.uniforms.uLensPosition.value.set(n.x,n.y);const i=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(i,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let t=0;for(const e of bf)this.isSunOccluded(e[0],e[1])||t++;return t/bf.length}raycastableDecor(){const t=[];for(const e of this.decorObjects){if(e.kind==="crop")continue;const n=this.decorGroups.get(e.id);n&&t.push(n)}return t}isSunOccluded(t=0,e=0){this.scene.updateMatrixWorld();const n=[];this.groundMesh&&n.push(this.groundMesh),this.terrainMesh&&n.push(this.terrainMesh);for(const o of this.raycastableDecor())n.push(o);if(n.length===0)return!1;const i=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=i.length();if(i.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(i.z,0,-i.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,i).normalize();i.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,i);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}get lowerCloudUp(){return this.cloudMesh!==void 0&&this.lowerCloudCover()>0}setPhenomena(t,e){this.phenomena.set(t,e)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=mf;let i,r;for(const a of this.decorObjects){if(a.kind==="crop")continue;const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?i=i===void 0?c.distance:Math.max(i,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:i,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],i=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(i&&!this.groundHides(t,e))return n.find(([,r])=>r===i.object)?.[0]}pickStarAt(t,e){if(this.namedStars.length===0)return;this.aimAtScreenPoint(this.raycaster,t,e);const n=this.raycaster.ray.direction,i=Math.cos(Sb*this.camera.fov*Math.PI/180);let r,a=i;for(const o of this.namedStars){const c=o.direction.dot(n);c>a&&(a=c,r={star:o.star,altitudeDeg:o.altitudeDeg})}return r&&this.groundHides(t,e)?void 0:r}groundHides(t,e){const n=[this.terrainMesh,this.groundMesh].filter(i=>i!==void 0);return n.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=mf,this.ufoOcclusionRaycaster.intersectObjects(n,!0).length>0)}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],i=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!i)return;let r=i.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),this.phenomena.clear(),this.terrainBuildToken++,this.disposeMesh(this.skyMesh),this.disposeMesh(this.groundMesh),this.disposeMesh(this.terrainMesh),this.disposeCloudSystem(),this.disposeCirrus(),this.disposePrecipitationPoints(),this.disposeRain(),this.disposeStarTiers(),this.meteorSystem?.dispose(),this.meteorSystem=void 0,this.iceHalos?.dispose(),this.iceHalos=void 0,this.rainbow?.dispose(),this.rainbow=void 0,this.skyGlow?.dispose(),this.skyGlow=void 0,this.depthOfFieldPass?.dispose(),this.depthOfFieldPass=void 0,this.cancelExposure(),this.exposureAccumulation?.dispose(),this.exposureAccumulation=void 0,this.cometTail?.dispose(),this.cometTail=void 0;for(const t of this.bodyMeshes.values())this.disposeMesh(t);this.bodyMeshes.clear();for(const t of[...this.hitAreas.keys()])this.disposeHitArea(t);for(const t of[...this.glareSprites.keys()])this.disposeGlare(t);this.disposeCompassLabels();for(const t of this.decorGroups.values())hn.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;let t;const e=n=>{const i=t===void 0?0:Math.min((n-t)/1e3,sE);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,i),this.updateRain(i),this.updateLightning(n/1e3,i),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.developingExposure||this.render(),this.animationFrameId=requestAnimationFrame(e)};this.animationFrameId=requestAnimationFrame(e)}setAnimationsRunning(t){t!==this.animationsRunning&&(this.animationsRunning=t,t?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),t||this.render())}stopTwinkle(){this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}restoreFogColor(){this.scene.fog&&this.scene.fog.color.setRGB(...this.baseFogColor)}needsAnimationLoop(){return this.animationsRunning&&(this.starTiers.length>0||this.precipitationPoints!==void 0||this.rainSystem!==void 0||this.lightningArmed||this.lensFlare!==void 0&&this.sunVisible)}syncAnimationLoop(){this.needsAnimationLoop()?this.startTwinkle():this.stopTwinkle()}buildSky(t){this.disposeMesh(this.skyMesh);const e=new pn(bo,32,16),n=e.attributes.position,i=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=t3(n.getX(a),n.getY(a),n.getZ(a)),l=c3(o,c,t.azimuthDeg,t.altitudeDeg);i.push(l[0],l[1],l[2])}e.setAttribute("color",new Se(i,3));const r=new Oi({vertexColors:!0,side:Be,fog:!1,depthWrite:!1});this.skyMesh=new $t(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=gf(this.observerElevationM);const t=new Mu(this.groundRadius,48),e=new ba({color:new vt(yl,yl,yl),fog:!0});this.groundMesh=new $t(t,e),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh),this.applyGroundDepthWrite()}applyGroundDepthWrite(){const t=this.groundMesh?.material;if(!t)return;const e=this.terrainMesh===void 0;t.depthWrite!==e&&(t.depthWrite=e,t.needsUpdate=!0)}cloudTransmission(t){const e=cn(t.altitudeDeg,t.azimuthDeg,1);let n=1;const i=this.lowerCloudCover();i>0&&(n*=1-Ie.alphaAt(e,Math.abs(this.cloudLayerOffset()),i)*Eb);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ie.alphaAt(e,wo,r)*wb),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,i,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<tu){this.bodyMeshes.delete(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=cn(e.altitudeDeg,e.azimuthDeg,Eo),l=gs(e.altitudeDeg),h=this.cloudTransmission(e),u=new vt(i.r*l[0]*h,i.g*l[1]*h,i.b*l[2]*h),d=new pn(n,16,16),f=new Oi({color:u,fog:!1}),g=new $t(d,f);g.position.set(a,o,c),this.celestialGroup.add(g),this.bodyMeshes.set(t,g),this.setHitArea(t,a,o,c,n);const v=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,v,u),t==="sun"){this.sunVisible=!0;const p=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*p,o*p+this.celestialGroup.position.y,c*p),this.lensFlare||(this.lensFlare=JS(),this.lensFlare.uniforms.uOpacity.value=kb,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.lensFlare.uniforms.uStarPoints.value=this.starPoints,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(l)}}setMoonMesh(t,e){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),t.magnitude>e||t.altitudeDeg<tu){this.bodyMeshes.delete(n);return}const{x:i,y:r,z:a}=cn(t.altitudeDeg,t.azimuthDeg,Eo),o=gs(t.altitudeDeg),c=new vt(o[0],o[1],o[2]),l=new ta({map:gE(t.phase),color:c,fog:!1}),h=new qa(l);h.position.set(i,r,a);const u=Sl*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,i,r,a,Sl),this.setGlare(n,i,r,a,t.magnitude,c)}setHitArea(t,e,n,i,r){const a=new ta({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new qa(a);o.position.set(e,n,i);const c=r*bb;o.scale.set(c,c,1),this.celestialGroup.add(o),this.hitAreas.set(t,o)}disposeHitArea(t){const e=this.hitAreas.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.hitAreas.delete(t))}setGlare(t,e,n,i,r,a){const o=u3(r);if(o<=0){this.disposeGlare(t);return}const c=p3(o),l=this.glareSprites.get(t),h=l??new qa(new ta({map:mE(),transparent:!0,blending:Zn,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=v3(o),h.position.set(e,n,i),h.scale.set(c*2,c*2,1),l||(this.celestialGroup.add(h),this.glareSprites.set(t,h))}disposeGlare(t){const e=this.glareSprites.get(t);e&&(e.removeFromParent(),e.material.dispose(),this.glareSprites.delete(t))}buildComet(t,e){const n=t&&`comet:${t.id}`;if(!t||!n||t.magnitude>e){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const i=cl(t.magnitude,e),r=ll(i);this.cometKey=n,this.setBodyMesh(n,t.position,xf*(.5+.5*i),new vt(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new An(Eo),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,i)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new ri,this.iceHalos.onReady=()=>this.render(),this.celestialGroup.add(this.iceHalos.object));const n=this.weather.highCloudCover;if(n===void 0){this.iceHalos.update({x:0,y:1,z:0},-1,0,[1,1,1],{cover:0,layerHeight:wo},0);return}const i=this.weather.lowerCloudCover??this.weather.cloudCover,r=te.deckLitUntilDeg(te.DECK_HEIGHT_M),a=t.altitudeDeg>-r?t:e,o=te.strength(n,i,a.altitudeDeg,r)*(a===t?1:Mf),{x:c,y:l,z:h}=cn(a.altitudeDeg,a.azimuthDeg,1),u=gs(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:wo},this.weather.iceCrystalAlignment??Jm)}buildRainbow(t,e){this.rainbow||(this.rainbow=new ha,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,i=t.altitudeDeg>0,r=i?t:e,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=Mf*Mn.moonlightShare(e.magnitude),c=Mn.strength(n,a,r.altitudeDeg)*(i?1:o);if(c<=0){this.rainbow.update({x:0,y:1,z:0},0,[1,1,1],!0);return}const{x:l,y:h,z:u}=cn(r.altitudeDeg,r.azimuthDeg,1),d=gs(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],i)}buildSkyGlow(t,e){if(!t.frame){this.skyGlow?.hide();return}this.skyGlow||(this.skyGlow=new Vn,this.skyGlow.onReady=()=>this.render(),this.celestialGroup.add(this.skyGlow.object));const{date:n,observer:i}=t.frame,r=Wn.galactic(n,i),a=ai.directionOf(r.centre),o=ai.directionOf(r.rotation),c=ai.directionOf(r.pole),l=new Bt().set(a.x,a.y,a.z,o.x,o.y,o.z,c.x,c.y,c.z),h=ai.directionOf(Wn.eclipticPole(n,i)),u=ai.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:ai.directionOf(t.moon),altitudeDeg:t.moon.altitudeDeg,phaseAngleDeg:Kt.phaseAngleOf(t.moon.phase.illuminatedFraction)},skyColor:new P(e[0],e[1],e[2])})}static directionOf(t){const{x:e,y:n,z:i}=cn(t.altitudeDeg,t.azimuthDeg,1);return new P(e,n,i).normalize()}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(t,e){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const i of t){if(i.magnitude>e)continue;n.add(i.body);const r=cl(i.magnitude,e),a=ll(r),o=aE[i.body]??new vt(1,1,1),c=new vt(o.r*a,o.g*a,o.b*a),l=xf*(.5+.5*r);this.setBodyMesh(i.body,i.position,l,c,i.magnitude)}for(const i of[...this.bodyMeshes.keys()])n.has(i)||(this.disposeMesh(this.bodyMeshes.get(i)),this.bodyMeshes.delete(i),this.disposeHitArea(i),this.disposeGlare(i))}buildStars(t,e){if(this.disposeStarTiers(),this.namedStars=[],!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:i,observer:r}=t,a=Rl(1337),o=[];for(let c=0;c<n.count;c++){const l=n.mag[c];if(l>e)break;const{altitudeDeg:h,azimuthDeg:u}=Rr(n.ra[c],n.dec[c],i,r);if(h<_f)continue;const{x:d,y:f,z:g}=cn(h,u,vf);o.push({x:d,y:f,z:g,brightness:cl(l,e),phase:a()*Math.PI*2,speedFactor:.7+a()*.6})}for(const c of wS){if(c.mag>e)continue;const{altitudeDeg:l,azimuthDeg:h}=Rr(c.raHours,c.decDeg,i,r);if(l<_f)continue;const{x:u,y:d,z:f}=cn(l,h,vf);this.namedStars.push({star:c,direction:new P(u,d,f).normalize(),altitudeDeg:l})}this.starTiers=qp.map((c,l)=>{const h=o.filter(E=>y3(E.brightness)===l),u=new Float32Array(h.length*3),d=new Float32Array(h.length),f=new Float32Array(h.length),g=new Float32Array(h.length);h.forEach((E,M)=>{u[M*3]=E.x,u[M*3+1]=E.y,u[M*3+2]=E.z,d[M]=E.brightness,f[M]=E.phase,g[M]=E.speedFactor});const v=new be;v.setAttribute("position",new de(u,3));const p=new de(new Float32Array(h.length*3),3);v.setAttribute("color",p);const m=new Rp({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Es.apply(m);const b=new Fo(v,m);return this.celestialGroup.add(b),{points:b,colorAttribute:p,brightness:d,phase:f,speedFactor:g}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let i=0;i<e.brightness.length;i++){const r=E3(e.brightness[i],{phase:e.phase[i],speedFactor:e.speedFactor[i]},t),a=ll(e.brightness[i])*r;n[i*3]=a,n[i*3+1]=a,n[i*3+2]=a}e.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const t=this.lowerCloudCover();if(t<=0)return;const e=this.weather.cloudDarkness,n=new vt(xs[0]+(wl[0]-xs[0])*e,xs[1]+(wl[1]-xs[1])*e,xs[2]+(wl[2]-xs[2])*e),{material:i,uniforms:r}=J0(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=i,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=Q0(Ef);this.cloudMesh=new $t(a,i),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=wf,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const t=this.weather.highCloudCover??0;if(t<=0)return;const{material:e,uniforms:n}=J0(new vt(...xs),t,wo,1);this.cirrusMaterial=e,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new $t(Q0(Ef*1.04),e),this.cirrusMesh.renderOrder=wf-1,this.celestialGroup.add(this.cirrusMesh)}disposeCirrus(){this.cirrusMesh&&(this.cirrusMesh.removeFromParent(),this.cirrusMesh.geometry.dispose()),this.cirrusMaterial?.dispose(),this.cirrusMesh=void 0,this.cirrusMaterial=void 0,this.cirrusUniforms=void 0}syncCloudLayer(){const t=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(t)),this.cloudMesh&&(this.cloudMesh.scale.y=t<0?-1:1)}cloudLayerOffset(){const e=((this.weather.cloudBaseM??Kf)-this.observerElevationM)*Gb;return Math.sign(e||1)*Math.max(Math.abs(e),Vb)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:i,y:r,z:a}=cn(t.altitudeDeg,t.azimuthDeg,1),o=gs(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*vn));for(const l of n)l.sunDir.value.set(i,r,a),l.sunColor.value.setRGB(o[0]*c,.96*o[1]*c,.88*o[2]*c),l.ambientColor.value.setRGB(e[0],e[1],e[2])}disposeCloudSystem(){this.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=Af[t],n=e.poolSize,i=Rl(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),c=new Float32Array(n),l=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),f=new Float32Array(n),g=new Float32Array(n);for(let E=0;E<n;E++){const M=i()*Math.PI*2,S=i()*e.radiusM;r[E*3]=Math.cos(M)*S,r[E*3+1]=lr+i()*(e.topYM-lr),r[E*3+2]=Math.sin(M)*S,a[E]=i()*Math.PI*2,o[E]=.7+i()*.6,c[E]=.6+i()*.8,l[E]=.4+i()*1.2}const v=new be;v.setAttribute("position",new de(r,3)),v.setDrawRange(0,Tl(n,this.weather.precipitationIntensity));const p={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new vt(...this.baseFogColor)},uTexture:{value:oE(t)},uNearFocusDistance:{value:Lf},uHazeDistance:{value:e.radiusM*Nf}},m=new De({uniforms:p,vertexShader:fE,fragmentShader:pE,transparent:!0,depthWrite:!1});this.precipitationUniforms=p;const b=new Fo(v,m);b.renderOrder=El,this.scene.add(b),this.precipitationPoints=b,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=c,this.precipitationWobbleAmpJitter=l,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=f,this.precipitationBounceVelZ=g}updatePrecipitation(t,e){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),e<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const i=Af[n],r=this.weather.windDirectionDeg*vn,a=Math.sin(r)*this.weather.windSpeed*i.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*i.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,v=this.precipitationBounceDuration,p=this.precipitationBounceVelX,m=this.precipitationBounceVelZ,b=n==="snow"&&u&&d,E=n==="hail"&&f&&g&&v&&p&&m;for(let M=0,S=0;M<c.length;M+=3,S++){if(E&&f[S]>0){if(f[S]-=e,f[S]<=0){const _=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[M]=Math.cos(_)*A,c[M+1]=i.topYM,c[M+2]=Math.sin(_)*A,f[S]=0}else{const _=1-f[S]/v[S];c[M+1]=lr+Math.sin(Math.PI*_)*g[S],c[M]=To(c[M]+(a+p[S])*e,i.radiusM),c[M+2]=To(c[M+2]+(o+m[S])*e,i.radiusM)}continue}let w=0,R=0;if(b){const _=tE*u[S],A=eE*d[S];w=Math.sin(t*_*Math.PI*2+l[S])*A,R=Math.sin(t*_*Math.PI*2+l[S]+Math.PI/2)*A}if(c[M]+=(a+w)*e,c[M+1]-=i.fallSpeedMPerS*h[S]*e,c[M+2]+=(o+R)*e,c[M]=To(c[M],i.radiusM),c[M+2]=To(c[M+2],i.radiusM),c[M+1]<lr){if(E){g[S]=Bf*(.2+Math.random()*1.6),v[S]=nE*(.5+Math.random()),f[S]=v[S];const C=Math.random()*Math.PI*2,D=iE*(g[S]/Bf);p[S]=Math.cos(C)*D,m[S]=Math.sin(C)*D,c[M+1]=lr;continue}const _=Math.random()*Math.PI*2,A=Math.sqrt(Math.random())*i.radiusM;c[M]=Math.cos(_)*A,c[M+1]=i.topYM,c[M+2]=Math.sin(_)*A}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=Cf(this.weather.precipitationIntensity);this.rainSystem=HS({count:Tf,radiusM:Jr,heightM:Xb,bottomYM:Rf,overallSpeed:qb,color:Kb,opacity:.85,visibleCount:Tl(Tf,this.weather.precipitationIntensity),speedStreak:Jb(t),pixelSize:Uf,seed:9001,nearFocusDistanceM:Lf,hazeDistanceM:Jr*Nf,hazeColor:new vt(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.syncRainSlant(),this.rainSystem.points.renderOrder=El,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=Rl(4242),e=new Float32Array(or*3),n=new Float32Array(or),i=new Float32Array(or),r=new Float32Array(or);for(let h=0;h<or;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*Jr;e[h*3]=Math.cos(u)*d,e[h*3+1]=Rf,e[h*3+2]=Math.sin(u)*d,i[h]=Ao(Pf,If),n[h]=t()*i[h],r[h]=n[h]/i[h]}const a=new be;a.setAttribute("position",new de(e,3));const o=new de(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Tl(or,this.weather.precipitationIntensity));const c=new De({uniforms:{uMaxSize:{value:Qb},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:jb},uTexture:{value:hE()}},vertexShader:uE,fragmentShader:dE,transparent:!0,depthWrite:!1}),l=new Fo(a,c);l.renderOrder=El,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:i,lifeAttribute:o}}disposeRain(){this.rainSystem&&(this.rainSystem.points.removeFromParent(),this.rainSystem.points.geometry.dispose(),this.rainSystem.points.material.dispose()),this.rainSystem=void 0,this.disposeRainSplashes()}disposeRainSplashes(){this.rainSplashSystem&&(this.rainSplashSystem.points.removeFromParent(),this.rainSplashSystem.points.geometry.dispose(),this.rainSplashSystem.points.material.dispose()),this.rainSplashSystem=void 0}syncRainSlant(){const t=this.rainSystem;if(!t)return;const e=this.weather.windDirectionDeg*vn;t.uniforms.uDropVelocity.value.set(Math.sin(e)*this.weather.windSpeed,-Cf(this.weather.precipitationIntensity),-Math.cos(e)*this.weather.windSpeed);const n=this.renderer.getSize(this.rainViewportSize);t.uniforms.uAspect.value=n.x/Math.max(n.y,1)}updateRain(t){const e=this.rainSystem;if(!e)return;e.uniforms.uTime.value+=t,e.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*vn,i=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=Jr,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+i*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.syncRainSlant(),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Ff+(1-Ff)*(1-c),h=zf+(1-zf)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=Uf*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:i,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(i[l]+=t,i[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Jr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=Ao(Pf,If),i[l]=0}o[l]=i[l]/r[l]}e.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(t,e){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-e);const n=this.lightningFlashRemainingS/Gf;this.scene.fog&&this.scene.fog.color.setRGB(this.baseFogColor[0]+(1-this.baseFogColor[0])*n,this.baseFogColor[1]+(1-this.baseFogColor[1])*n,this.baseFogColor[2]+(1-this.baseFogColor[2])*n);return}if(this.nextLightningAtS===null){this.nextLightningAtS=t+Ao(kf,Hf);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Gf,this.nextLightningAtS=t+Ao(kf,Hf),this.onLightningFlash?.())}}buildCompassLabels(){const t=eu(navigator.languages,Lb),e=Ib[t];this.compassSprites=Pb.map((n,i)=>{const r=e[i],a=new ta({map:vE(r),depthTest:!1,fog:!1}),o=new qa(a),{x:c,y:l,z:h}=cn(0,n,Nb);return o.position.set(c,l,h),o.scale.set(bl,bl,1),o.renderOrder=Ub,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o}),this.updateCompassScale()}updateCompassScale(){const t=this.camera.fov*Math.PI/360,e=Ob*Math.PI/360,n=bl*Math.tan(t)/Math.tan(e);for(const i of this.compassSprites)i.scale.set(n,n,1)}disposeCompassLabels(){for(const t of this.compassSprites)t.removeFromParent(),t.material.map?.dispose(),t.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const t of this.starTiers)this.disposeMesh(t.points);this.starTiers=[]}disposeMesh(t){if(!t)return;t.removeFromParent(),"geometry"in t&&t.geometry.dispose();const e=t.material;for(const n of Array.isArray(e)?e:[e]){const i=n.map;i&&i.dispose(),n.dispose()}}}const vn=Math.PI/180;function ac(s,t,e){return Math.max(t,Math.min(e,s))}function Ao(s,t){return s+Math.random()*(t-s)}function To(s,t){return(s%(t*2)+t*3)%(t*2)-t}let Ro,Do;function oE(s){switch(s){case"snow":return cE();case"hail":return lE()}}function cE(){if(Ro)return Ro;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0.95)"),n.addColorStop(.5,"rgba(255,255,255,0.55)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Ro=new _i(t),Ro}function lE(){if(Do)return Do;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.55,"rgba(255,255,255,0.95)"),n.addColorStop(.8,"rgba(255,255,255,0.4)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Do=new _i(t),Do}let Co;function hE(){if(Co)return Co;const s=64,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.4,"rgba(255,255,255,0)"),n.addColorStop(.6,"rgba(255,255,255,0.9)"),n.addColorStop(.8,"rgba(255,255,255,0.25)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Co=new _i(t),Co}const uE=`
|
|
5714
5727
|
uniform float uMaxSize;
|
|
5715
5728
|
uniform float uScale;
|
|
5716
5729
|
attribute float aLife;
|
|
@@ -5723,7 +5736,7 @@ void main() {
|
|
|
5723
5736
|
vOpacity = 1.0 - aLife;
|
|
5724
5737
|
gl_Position = projectionMatrix * mvPosition;
|
|
5725
5738
|
}
|
|
5726
|
-
`,
|
|
5739
|
+
`,dE=`
|
|
5727
5740
|
uniform vec3 uColor;
|
|
5728
5741
|
uniform sampler2D uTexture;
|
|
5729
5742
|
varying float vOpacity;
|
|
@@ -5734,7 +5747,7 @@ void main() {
|
|
|
5734
5747
|
if (alpha < 0.01) discard;
|
|
5735
5748
|
gl_FragColor = vec4(uColor, alpha);
|
|
5736
5749
|
}
|
|
5737
|
-
`,
|
|
5750
|
+
`,fE=`
|
|
5738
5751
|
uniform float uSize;
|
|
5739
5752
|
uniform float uScale;
|
|
5740
5753
|
uniform float uNearFocusDistance;
|
|
@@ -5760,7 +5773,7 @@ void main() {
|
|
|
5760
5773
|
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
5761
5774
|
gl_Position = projectionMatrix * mvPosition;
|
|
5762
5775
|
}
|
|
5763
|
-
`,
|
|
5776
|
+
`,pE=`
|
|
5764
5777
|
precision mediump float;
|
|
5765
5778
|
uniform sampler2D uTexture;
|
|
5766
5779
|
uniform vec3 uColor;
|
|
@@ -5775,5 +5788,5 @@ void main() {
|
|
|
5775
5788
|
float blur = max(vNearBlur, vHaze);
|
|
5776
5789
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
5777
5790
|
}
|
|
5778
|
-
`;let Po;function
|
|
5779
|
-
`);let r=oi.cache.get(i);return r||(r=Promise.all(n.map(a=>oi.load(a.url))).then(a=>a.reduce((o,c)=>oi.concat(o,c))),oi.cache.set(i,r)),r}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*n,e),dec:new Float32Array(t,1*n,e),mag:new Float32Array(t,2*n,e),ci:new Float32Array(t,3*n,e)}}static concat(t,e){const n=(i,r)=>{const a=new Float32Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),a};return{count:t.count+e.count,ra:n(t.ra,e.ra),dec:n(t.dec,e.dec),mag:n(t.mag,e.mag),ci:n(t.ci,e.ci)}}}const pE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,mE=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,gE=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,vE=20,xE=1;class _E{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const i=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=i==="hail"?Math.min(1,e*1.3+.2):i==="rain"?e:0,i!==this.ambientKey){this.ambientKey=i;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(pE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/vE,1);const r=n>xE;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(mE,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:i}=this.requested;this.setAmbient(e,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(gE,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,i){if(e!==n()){t?.source.stop();return}i(t)}async startLoop(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ri{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[i,r]=this.perifocalAxes(),a=Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),i=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Ri.stumpffC(i),o=e-n*n*n/Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2)*Ri.stumpffS(i);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2)*Math.abs(t),i=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ri.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;i(r)<n;)r*=2;let a=0;for(let o=0;o<Ri.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;i(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:i*a-r*o*c,y:r*a+i*o*c,z:o*l},{x:-i*o-r*a*c,y:-r*o+i*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const Am=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class ME{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return Am.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(t,e,n){const i=Ve(e),r=this.earthPositionAt(i),a=this.apparentPositionOf(t,2451545+i.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,i,e,n),u=this.horizontalOf(o,i,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const i=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(i,t.peakMagnitude)}static tailEndAt(t,e,n,i,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/i,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const i=this.orbitOf(t);let r=i.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=i.positionAt(e-o)}return r}static horizontalOf(t,e,n,i){const r=ko(mS(),new ge(t.x,t.y,t.z,e)),a=ko(gS(e),r),o=q3(e,new Lu(i.lat,i.lng,i.elevationM)),c=new ge(a.x-o.x,a.y-o.y,a.z-o.z,e),l=um(c);return Rr(l.ra,l.dec,n,i)}static earthPositionAt(t){return ko(pS(),os(St.Earth,t))}static julianDayOf(t){return 2451545+Ve(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new Ri(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const yE=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],oc=6.5;class Pl{static activeAt(t){return yE.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),i=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,i),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,i=oc){if(e<=0)return 0;const r=oc-i;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return Rr(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class Re{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=Ve(t),i=new Pu(0,W3(t).elon-90,1),r=ko(vS(n),hm(i,n)),a=um(r);return Rr(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=oc){const n=Re.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),i=oc-e;return(Re.QUIET_RATE_PER_HOUR+n)/Math.pow(Re.POPULATION_INDEX,i)}static schedule(t){const e=new pm(t.seed^1542469173);return Rs.schedule(t).map(n=>{const i=Re.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=Re.turnAround(i,e.between(0,360)),o={x:i.x*Math.cos(r)+a.x*Math.sin(r),y:i.y*Math.cos(r)+a.y*Math.sin(r),z:i.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:Re.toHorizontal(o),bearingDeg:Re.bearingFrom(o,i)}})}static turnAround(t,e){const[n,i]=Re.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+i.x*Math.sin(r),y:n.y*Math.cos(r)+i.y*Math.sin(r),z:n.z*Math.cos(r)+i.z*Math.sin(r)}}static bearingFrom(t,e){const[n,i]=Re.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=Re.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*i.x+a.y*i.y+a.z*i.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Re.normalise(Re.cross(t,e));return[n,Re.normalise(Re.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=Re.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Re.turnAround(e,t.bearingDeg),i=t.fromRadiantDeg*Math.PI/180;return Re.toHorizontal({x:e.x*Math.cos(i)+n.x*Math.sin(i),y:e.y*Math.cos(i)+n.y*Math.sin(i),z:e.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,i=Math.cos(e);return{x:i*Math.sin(n),y:Math.sin(e),z:-i*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class SE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=me.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=me.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:me.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:me.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Sr{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Sr.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const n=Sr.degOver(t)/e;return n<1?1:Math.min(Sr.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class on{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return Sr.DEG_PER_SECOND*3600}static graspOf(t,e={}){const n=e.exposureSeconds??t.exposureSeconds,i=e.fNumber??t.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return on.EYE;const r=e.focalLengthMm??t.frame?.focalLengthMm??on.UNKNOWN_CAMERA_FOCAL_MM,a=r/i,o=on.resolutionArcsec(t,r,a);return{apertureMm:a,exposureSeconds:Math.min(n,on.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,n){const r=(t.detailUm??on.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*on.ARCSEC_PER_RADIAN,a=1.22*on.WAVELENGTH_M/(n/1e3)*on.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(t){return t/on.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const n=on.graspOf(t,e),i=on.EYE,r=(n.apertureMm/i.apertureMm)**2,a=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(t,e){const n=e.fieldOfViewDeg===void 0?void 0:ze.focalLengthMmFor(t,e.fieldOfViewDeg);return on.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:n,exposureSeconds:e.exposureSeconds})}}class Di{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(t,e,n,i,r){if(!(i>0))return 1;const a=r>0?Di.travelDegOver(t,e,n,n+i*1e3)/r/Di.PIXELS_PER_INSTANT:0,o=Di.flashesOver(t,i)*Di.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Di.MAX_INSTANTS,c)}static travelDegOver(t,e,n,i){let r=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Di.directionAt(a,e,n),c=Di.directionAt(a,e,i),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(t,e){let n=0;for(const i of t)for(const r of i.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*e}static directionAt(t,e,n){const i=nu(t,n),r=i.eastM,a=i.altitudeM-e,o=i.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}const Vf=111320,Qr=Math.PI/180,bE=1.02,EE=1;class ua{static of(t,e){const n=ua.sightings(t,e);if(n.length<2)return;const i=ua.baseline(n);if(!i)return;const{near:r,far:a,closedM:o}=i,c=Math.tan(a.widthDeg/2*Qr)===0?0:Math.tan(r.widthDeg/2*Qr)/Math.tan(a.widthDeg/2*Qr);if(c<bE)return;const l=o/(c-1),h=me.sizeMAt(l,r.widthDeg),u=n.map(d=>({t:d.t,m:me.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:r.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===e)?.shape,r=i?.angular?.widthDeg,a=tn(t,n.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:n.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??a.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(t){let e;for(const n of t)for(const i of t){if(n.t>=i.t)continue;const r=ua.closedAlongSight(n,i),[a,o,c]=r>=0?[i,n,r]:[n,i,-r];c<EE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const n=(e.lat-t.lat)*Vf,i=(e.lng-t.lng)*Vf*Math.cos(t.lat*Qr),r=(t.sightAzimuthDeg??0)*Qr;return n*Math.cos(r)+i*Math.sin(r)}}class an{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:an.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:an.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:an.atLeastNearest(t.derivedM),basis:"derived"};const e=an.largest(t.range?.minM,t.crossing?.behindM),n=an.smallest(t.range?.maxM,t.crossing?.inFrontM),i=e===void 0?void 0:e*an.MARGIN,r=n===void 0?void 0:n/an.MARGIN;return i!==void 0&&r!==void 0?{distanceM:an.atLeastNearest(i<=r?Math.sqrt(i*r):i),basis:"bounded"}:i!==void 0?{distanceM:an.atLeastNearest(i),basis:"bounded"}:r!==void 0&&r<an.CONVENTIONAL_M?{distanceM:an.atLeastNearest(r),basis:"bounded"}:{distanceM:an.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(an.NEAREST_M,t)}static largest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.min(...e)}}ap();const wE={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},AE=["en","fr"],TE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},RE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Wf="comet:",DE={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},CE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,PE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,IE=-18,LE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Il={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class NE extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass",fr,pr]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new P;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new _E;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(i,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=eu(Vo.preferencesFor(this),AE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(t,this.said.read(u.title)||DE[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,g=d.altitudeDeg,v=(g<0?RE:TE)[c];this.showHoverTooltip(t,v.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(Wf)?t.slice(Wf.length):void 0;return(n?Am.find(r=>r.id===n):void 0)?.name[e]??wE[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(qu(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs)};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Om}</style>${Nm}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ai(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Fl),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",e=>this.lookToward(e.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new ns(Vo.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),(t===fr||t===pr)&&n!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[fr,pr])this.ufoElement.toggleAttribute(t,this.hasAttribute(t))}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=tn(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="witness"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=un(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const r=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((r-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){this.sightingData=await qf.json(t)}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=me.CANVAS_HEIGHT_PX,n=ze.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=[{magnitudeLimit:Dl,url:this.getAttribute("star-catalog-src")??CE},{magnitudeLimit:Cl,url:this.getAttribute("deep-star-catalog-src")??PE}],e=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=e>Dl?Cl:Dl;const i=await oi.upTo(t,e);n===this.starCatalogRequest&&(this.starCatalog=i,this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Cl||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=on.gainFor(t.instrument,{fNumber:tn(t,0)?.fNumber,fieldOfViewDeg:Un.fovOf(t,0),exposureSeconds:t.exposure});return Wp(IE,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=this.exposureSeconds(),n=this.degreesPerPixelAt(t),i=Sr.instants(e,n),r=Math.max(i,this.ufoElement.exposureTimes(t).length,Di.instants(this.ufoElement.sighting.decor,tn(this.ufoElement.sighting,t)?.elevationM??0,t,e,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=e*1e3;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t+a*o/r,{sky:Math.floor(o*i/r)!==Math.floor((o-1)*i/r),stepMs:a/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Un.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const n=this.ufoElement.sighting;this.setWeather(qu(n,t)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,t),this.sceneRenderer.setDecor(n.decor);const i=tn(n,t);if(this.sceneRenderer.setObserverPose(i??Il),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(on.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:Un.fovOf(n,t),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Fe.of(n)?.offsetAt(t)??Fe.STILL),this.sceneRenderer.updateDecorAnchoring(tn(n,0),i,t),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(t),e&&!e.sky)return;const r=i?.lat??Il.lat,a=i?.lng??Il.lng,o=K0(n.event.time??{},a,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(LE);return}const c=new Date(o.getTime()+t),l={lat:r,lng:a,elevationM:i?.elevationM??0},h=`${c.getTime()}|${r}|${a}|${l.elevationM}|${this.starCatalog?this.starCatalogDepth:0}`;if(h===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=h;const u={...dl("Sun",c,l),magnitude:fl("Sun",c)},d={...dl("Moon",c,l),phase:_S(c),magnitude:fl("Moon",c)},f=xS.map(g=>({body:g,position:dl(g,c,l),magnitude:fl(g,c)}));this.sceneRenderer.setAstronomy({sun:u,moon:d,planets:f,comet:this.cometAt(c,l),stars:this.starCatalog?{catalog:this.starCatalog,date:c,observer:l}:void 0,frame:{date:c,observer:l}}),this.ufoElement.setSunAltitude(u.altitudeDeg)}cometAt(t,e){const n=ME.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const n=e.timeline,i=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const v of n.sourceIds){const p=n.getInterpolatedShapeAt(t,v);if(!p)continue;const m={...p,bounds:{...p.bounds,x:p.bounds.x+r.x,y:p.bounds.y+r.y}};o.set(v,m);const b=p.aim?this.sceneRenderer.screenPointOf(Xn.directionOf(p.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/i.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/i.height*2-1)},E=b!==void 0&&Math.abs(b.ndcX)<=1&&Math.abs(b.ndcY)<=1,M=E?this.sceneRenderer.decorDistancesAt(b.ndcX,b.ndcY,v):{};l.add(v),(E||p.aim)&&l.delete(v);const S=p.angular?.widthDeg??a.pxToDeg(p.bounds.width),w=this.sizeEstimateOf(v);w.add(S,M);const R=ua.of(e,v);c.set(v,an.resolve({hypothesisM:this.distanceHypotheses.get(v),derivedM:R&&S>0?me.distanceMAt(R.widthM,S):void 0,range:w.distanceRangeAt(S),crossing:M}))}for(const[v,p]of o)for(const[m,b]of o){if(m===v||b.transparency>=1||b.bounds.width*b.bounds.height<=p.bounds.width*p.bounds.height||!(p.bounds.x>=b.bounds.x&&p.bounds.y>=b.bounds.y&&p.bounds.x+p.bounds.width<=b.bounds.x+b.bounds.width&&p.bounds.y+p.bounds.height<=b.bounds.y+b.bounds.height))continue;const M=c.get(m);M&&c.set(v,{distanceM:M.distanceM*.999,basis:M.basis});break}this.depths=c;const h=n.sourceIds,u=this.sceneRenderer.lowerCloudUp,d=[];for(const[v,p]of o)d.push({sourceId:v,shape:p,distanceM:c.get(v).distanceM,renderOrder:h.indexOf(v),aim:p.aim,hidden:p.behindCloud===!0&&u||l.has(v)});const g=(tn(e,t)?.rollDeg??0)+(Fe.of(e)?.offsetAt(t)??Fe.STILL).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:ze.starPointsOf(e.instrument),rollRad:g*Math.PI/180})}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(i)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,i=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?K0(n,e.lng,t.event.utcOffsetHours):void 0;if(!i||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(e.lat*1e3),c=Re.schedule({ratePerHour:Re.observedRatePerHour(Re.apexPosition(i,r).altitudeDeg),durationMs:a,velocityKmS:Re.TYPICAL_VELOCITY_KM_S,seed:o}),l=Pl.activeAt(i).map(u=>{const d=Pl.radiantPosition(u.shower,i,r);return{entry:u,position:d,rate:Pl.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Rs.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(t){const e=this.ufoElement.sighting,n=e.instrument,i=n.frame,r=tn(e,t),a=r?.fNumber??n.fNumber;if(!i||a===void 0)return;const o=ze.focalLengthMmFor(n,Un.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ii.of(e.instrument,me.CANVAS_HEIGHT_PX,Un.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new SE,this.sizeEstimates.set(t,e)),e}}const Xf="rr0-scene";function OE(){ap(),customElements.get(Xf)||customElements.define(Xf,NE)}OE();export{o2 as $,kE as A,de as B,vt as C,H2 as D,$t as E,qE as F,GE as G,Tp as H,HE as I,VE as J,Fo as K,wa as L,WE as M,Ua as N,_e as O,B2 as P,hs as Q,Wo as R,Rn as S,UE as T,en as U,Pt as V,yn as W,BE as X,Ir as Y,Ap as Z,XE as _,zE as a,Yo as a0,Eh as a1,Qo as a2,$e as a3,Lp as a4,yu as a5,Su as a6,Qt as a7,cs as a8,Ea as a9,xi as aa,zi as ab,FE as b,$E as c,$o as d,KE as e,Xt as f,P as g,qd as h,YE as i,ZE as j,i2 as k,ws as l,Ec as m,o1 as n,ye as o,ke as p,Yl as q,dn as r,Rp as s,Bi as t,f2 as u,M2 as v,qn as w,Oi as x,ce as y,be as z};
|
|
5791
|
+
`;let Po;function mE(){if(Po)return Po;const s=128,t=document.createElement("canvas");t.width=s,t.height=s;const e=t.getContext("2d"),n=e.createRadialGradient(s/2,s/2,0,s/2,s/2,s/2);return n.addColorStop(0,"rgba(255,255,255,1)"),n.addColorStop(.4,"rgba(255,255,255,0.35)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,s,s),Po=new _i(t),Po}function gE(s){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),i=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.fill();const l=ac(s.illuminatedFraction,0,1),h=s.phaseFraction<.5,u=i*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,i,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,i,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,i,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,i,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,i,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new _i(e)}function vE(s){const t=document.createElement("canvas");t.width=128,t.height=128;const e=t.getContext("2d");return e.fillStyle="rgba(0, 0, 0, 0.55)",e.beginPath(),e.arc(64,64,60,0,Math.PI*2),e.fill(),e.fillStyle="#ffffff",e.font="bold 52px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(s,64,68),new _i(t)}function Rl(s){let t=s;return function(){t|=0,t=t+1831565813|0;let n=Math.imul(t^t>>>15,1|t);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const Dl=7.5,Cl=9;class oi{static cache=new Map;static load(t){let e=oi.cache.get(t);return e||(e=fetch(t).then(n=>n.arrayBuffer()).then(n=>oi.parse(n)),oi.cache.set(t,e)),e}static upTo(t,e){const n=t.filter((a,o)=>o===0||t[o-1].magnitudeLimit<e);if(n.length<=1)return oi.load(t[0].url);const i=n.map(a=>a.url).join(`
|
|
5792
|
+
`);let r=oi.cache.get(i);return r||(r=Promise.all(n.map(a=>oi.load(a.url))).then(a=>a.reduce((o,c)=>oi.concat(o,c))),oi.cache.set(i,r)),r}static parse(t){const e=t.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),n=e*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(t,0*n,e),dec:new Float32Array(t,1*n,e),mag:new Float32Array(t,2*n,e),ci:new Float32Array(t,3*n,e)}}static concat(t,e){const n=(i,r)=>{const a=new Float32Array(i.length+r.length);return a.set(i,0),a.set(r,i.length),a};return{count:t.count+e.count,ra:n(t.ra,e.ra),dec:n(t.dec,e.dec),mag:n(t.mag,e.mag),ci:n(t.ci,e.ci)}}}const xE=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,_E=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,ME=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,yE=20,SE=1;class bE{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(t){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",t);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(t,e,n){if(this.requested={type:t,intensity:e,windSpeed:n},!this.context)return;this.paused&&(t="none",e=0,n=0);const i=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=i==="hail"?Math.min(1,e*1.3+.2):i==="rain"?e:0,i!==this.ambientKey){this.ambientKey=i;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,i!=="none"&&this.startLoop(xE,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,c=>{this.ambientSource=c?.source,this.ambientGain=c?.gain,c&&(c.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/yE,1);const r=n>SE;if(r!==this.windActive){this.windActive=r;const a=++this.windToken;this.stopSource(this.windSource,this.windGain),this.windSource=void 0,this.windGain=void 0,r&&this.startLoop(_E,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,c=>{this.windSource=c?.source,this.windGain=c?.gain,c&&(c.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(t){if(t===this.paused)return;this.paused=t;const{type:e,intensity:n,windSpeed:i}=this.requested;this.setAmbient(e,n,i)}playThunder(){!this.context||this.paused||this.playOneShot(ME,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(t,e,n,i){if(e!==n()){t?.source.stop();return}i(t)}async startLoop(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i,r.loop=!0;const a=n.createGain();return a.gain.value=e,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(i){console.warn("Weather ambient sound failed to load, staying silent:",i);return}}async playOneShot(t,e){const n=this.context;if(n)try{const i=await this.getBuffer(t),r=n.createBufferSource();r.buffer=i;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(i){console.warn("Thunder sound failed to load:",i)}}async getBuffer(t){const e=this.context;if(!e)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(t);return n||(n=fetch(t).then(i=>{if(!i.ok)throw new Error(`Audio fetch failed (${i.status}): ${t}`);return i.arrayBuffer()}).then(i=>e.decodeAudioData(i)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class Ri{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[i,r]=this.perifocalAxes(),a=Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(i,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-e)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(t){const e=t-this.elements.perihelionJd,n=this.universalAnomaly(e),i=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Ri.stumpffC(i),o=e-n*n*n/Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2)*Ri.stumpffS(i);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(t){const e=this.positionAt(t);return Math.hypot(e.x,e.y,e.z)}universalAnomaly(t){if(t===0)return 0;const e=Math.sign(t),n=Math.sqrt(Ri.SUN_GM_AU3_PER_DAY2)*Math.abs(t),i=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*Ri.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;i(r)<n;)r*=2;let a=0;for(let o=0;o<Ri.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;i(c)<n?a=c:r=c}return e*(a+r)/2}perifocalAxes(){const t=this.elements.ascendingNodeDeg*Math.PI/180,e=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,i=Math.cos(t),r=Math.sin(t),a=Math.cos(e),o=Math.sin(e),c=Math.cos(n),l=Math.sin(n);return[{x:i*a-r*o*c,y:r*a+i*o*c,z:o*l},{x:-i*o-r*a*c,y:-r*o+i*a*c,z:a*l}]}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}static stumpffC(t){if(Math.abs(t)<1e-6)return 1/2-t/24+t*t/720;if(t>0)return(1-Math.cos(Math.sqrt(t)))/t;const e=Math.sqrt(-t);return(Math.cosh(e)-1)/-t}static stumpffS(t){if(Math.abs(t)<1e-6)return 1/6-t/120+t*t/5040;if(t>0){const n=Math.sqrt(t);return(n-Math.sin(n))/(n*n*n)}const e=Math.sqrt(-t);return(Math.sinh(e)-e)/(e*e*e)}}const Rm=[{id:"halley-1910",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672960498922706,perihelionAu:.5872100477652511,inclinationDeg:162.218798367122,ascendingNodeDeg:58.56208298700436,argumentOfPerihelionDeg:111.7366940639061,perihelionJd:2.4187816784171113e6},peakMagnitude:0,peakOn:"1910-05-20",absoluteMagnitude:4.72,activityExponent:4,tailLengthDeg:100,tailLengthAu:.1638,note:"Passed 0.15 au from Earth on 20 May 1910, and the Earth crossed the outer tail the day before — the apparition that produced a genuine public panic."},{id:"brooks-1911",designation:"C/1911 O1",name:{en:"Comet Brooks",fr:"comète Brooks"},orbit:{eccentricity:.9876404970138669,perihelionAu:.4898172916113738,inclinationDeg:33.34043866978714,ascendingNodeDeg:293.7022074981857,argumentOfPerihelionDeg:153.5578007321686,perihelionJd:2.4193378856140426e6},peakMagnitude:2,peakOn:"1911-10-25",absoluteMagnitude:5.59,activityExponent:4},{id:"skjellerup-maristany-1927",designation:"C/1927 X1",name:{en:"Comet Skjellerup-Maristany",fr:"comète Skjellerup-Maristany"},orbit:{eccentricity:.999839726885059,perihelionAu:.1761569619628186,inclinationDeg:85.1125991950808,ascendingNodeDeg:78.24360172472711,argumentOfPerihelionDeg:47.15877857390136,perihelionJd:2.4252326808989984e6},peakMagnitude:-6,peakOn:"1927-12-15",absoluteMagnitude:1.19,activityExponent:4,note:"One of the few comets of the century seen in full daylight."},{id:"de-kock-paraskevopoulos-1941",designation:"C/1941 B2",name:{en:"Comet de Kock-Paraskevopoulos",fr:"comète de Kock-Paraskevopoulos"},orbit:{eccentricity:.9991026715181549,perihelionAu:.7900329662827822,inclinationDeg:168.2039226531089,ascendingNodeDeg:43.10609347214336,argumentOfPerihelionDeg:268.6990344196369,perihelionJd:2430022157765061e-9},peakMagnitude:2,peakOn:"1941-02-05",absoluteMagnitude:5.01,activityExponent:4},{id:"southern-1947",designation:"C/1947 X1",name:{en:"the Southern Comet",fr:"comète australe"},orbit:{eccentricity:.9998424430916737,perihelionAu:.1100045955093761,inclinationDeg:138.5113919632757,ascendingNodeDeg:337.3114969669252,argumentOfPerihelionDeg:196.1820121395961,perihelionJd:2.4325220864727003e6},peakMagnitude:-3,peakOn:"1947-12-08",absoluteMagnitude:3.01,activityExponent:4,note:"A bright southern-hemisphere comet of December 1947, the month the American sighting wave of that year was still being argued over."},{id:"eclipse-1948",designation:"C/1948 V1",name:{en:"the Eclipse Comet",fr:"comète de l'éclipse"},orbit:{eccentricity:.9999130678247334,perihelionAu:.1354437057263306,inclinationDeg:23.11668597152911,ascendingNodeDeg:211.0454985994762,argumentOfPerihelionDeg:107.2474157073104,perihelionJd:2.4328519265329437e6},peakMagnitude:-2,peakOn:"1948-11-01",absoluteMagnitude:4.79,activityExponent:4,note:"Found during the total solar eclipse of 1 November 1948, which is how a comet that bright had gone unnoticed: it had been hidden in the Sun's glare."},{id:"arend-roland-1957",designation:"C/1956 R1",name:{en:"Comet Arend-Roland",fr:"comète Arend-Roland"},orbit:{eccentricity:1.0002570255357,perihelionAu:.3160532361485914,inclinationDeg:119.9440863251822,ascendingNodeDeg:215.8548157717755,argumentOfPerihelionDeg:308.775920364167,perihelionJd:2.4359365327396123e6},peakMagnitude:.5,peakOn:"1957-04-25",absoluteMagnitude:3.96,activityExponent:4,note:"Showed a spike pointing back TOWARD the Sun in late April 1957 — a real anti-tail, and much reported at the time."},{id:"mrkos-1957",designation:"C/1957 P1",name:{en:"Comet Mrkos",fr:"comète Mrkos"},orbit:{eccentricity:.9993521583504134,perihelionAu:.3549238508212375,inclinationDeg:93.9433042053929,ascendingNodeDeg:68.32441518619923,argumentOfPerihelionDeg:40.31823675802871,perihelionJd:243605193752228e-8},peakMagnitude:1,peakOn:"1957-08-05",absoluteMagnitude:5.07,activityExponent:4,note:"The second bright naked-eye comet of 1957, four months after Arend-Roland."},{id:"seki-lines-1962",designation:"C/1962 C1",name:{en:"Comet Seki-Lines",fr:"comète Seki-Lines"},orbit:{eccentricity:1.000003791331562,perihelionAu:.03139689112215131,inclinationDeg:65.01487186102287,ascendingNodeDeg:304.6776602796538,argumentOfPerihelionDeg:11.47295326312573,perihelionJd:2437756163010178e-9},peakMagnitude:-2.5,peakOn:"1962-04-01",absoluteMagnitude:9.3,activityExponent:4},{id:"ikeya-seki-1965",designation:"C/1965 S1",name:{en:"Comet Ikeya-Seki",fr:"comète Ikeya-Seki"},orbit:{eccentricity:.9999141178248997,perihelionAu:.007785966366889336,inclinationDeg:141.8642315267051,ascendingNodeDeg:346.9951764632611,argumentOfPerihelionDeg:69.04909813996062,perihelionJd:2.4390546837018197e6},peakMagnitude:-10,peakOn:"1965-10-21",alsoRecordedMagnitude:2,alsoRecordedOn:"1965-10-30",absoluteMagnitude:5.26,activityExponent:4.002,tailLengthDeg:25,tailLengthAu:.5048,note:"A sungrazer that passed 450 000 km above the Sun's surface and was seen beside it in broad daylight — the brightest comet of the twentieth century. It then stood in the dawn sky for a fortnight with a tail some 25 degrees long, which is the second magnitude recorded here."},{id:"bennett-1970",designation:"C/1969 Y1",name:{en:"Comet Bennett",fr:"comète Bennett"},orbit:{eccentricity:.9962979048768408,perihelionAu:.5376209981502136,inclinationDeg:90.03975717147327,ascendingNodeDeg:224.6576652531314,argumentOfPerihelionDeg:354.1494209173161,perihelionJd:2.4406655455270996e6},peakMagnitude:0,peakOn:"1970-03-26",absoluteMagnitude:3.36,activityExponent:4},{id:"white-ortiz-bolelli-1970",designation:"C/1970 K1",name:{en:"Comet White-Ortiz-Bolelli",fr:"comète White-Ortiz-Bolelli"},orbit:{eccentricity:.9999488875801225,perihelionAu:.00884411465256722,inclinationDeg:138.9520738221631,ascendingNodeDeg:336.8194095816687,argumentOfPerihelionDeg:61.10224765396615,perihelionJd:2.4407209807728203e6},peakMagnitude:1,peakOn:"1970-05-22",absoluteMagnitude:4.35,activityExponent:4},{id:"kohoutek-1973",designation:"C/1973 E1",name:{en:"Comet Kohoutek",fr:"comète Kohoutek"},orbit:{eccentricity:1.000007152175185,perihelionAu:.1424250377812859,inclinationDeg:14.30414984159355,ascendingNodeDeg:258.4893339663974,argumentOfPerihelionDeg:37.79772760699667,perihelionJd:2442044930687027e-9},peakMagnitude:0,peakOn:"1974-01-05",absoluteMagnitude:4.89,activityExponent:4,note:"Announced in advance as the comet of the century and remembered for disappointing: it was an ordinary naked-eye object, not the spectacle the press had promised."},{id:"west-1976",designation:"C/1975 V1",name:{en:"Comet West",fr:"comète West"},orbit:{eccentricity:1.000017859625611,perihelionAu:.1966006188461085,inclinationDeg:43.07319920579427,ascendingNodeDeg:118.9189245655447,argumentOfPerihelionDeg:358.4315101259072,perihelionJd:2442833721841768e-9},peakMagnitude:-3,peakOn:"1976-02-25",absoluteMagnitude:4.41,activityExponent:4,tailLengthDeg:30,tailLengthAu:.4325,note:"Broke into four pieces at perihelion. Barely reported at the time — the press had been burned by Kohoutek two years earlier."},{id:"iras-araki-alcock-1983",designation:"C/1983 H1",name:{en:"Comet IRAS-Araki-Alcock",fr:"comète IRAS-Araki-Alcock"},orbit:{eccentricity:.9898409731606003,perihelionAu:.9913412593828502,inclinationDeg:73.25000846947029,ascendingNodeDeg:49.10235754476374,argumentOfPerihelionDeg:192.8506176754439,perihelionJd:2.4454757545235856e6},peakMagnitude:1.7,peakOn:"1983-05-11",absoluteMagnitude:9.04,activityExponent:4,note:"Passed 0.031 au from Earth on 11 May 1983, one of the closest cometary approaches on record: it crossed a quarter of the sky in a night, which no other comet in this list did."},{id:"halley-1986",designation:"1P/Halley",name:{en:"Halley's Comet",fr:"comète de Halley"},orbit:{eccentricity:.9672792271749998,perihelionAu:.5871034488173393,inclinationDeg:162.2422242700916,ascendingNodeDeg:58.85993640671803,argumentOfPerihelionDeg:111.8655480539208,perihelionJd:2.4464709589610207e6},peakMagnitude:2.1,peakOn:"1986-03-10",absoluteMagnitude:2.71,activityExponent:4,note:"The worst-placed return in two thousand years — famous, expected, and for most observers a faint smudge."},{id:"hyakutake-1996",designation:"C/1996 B2",name:{en:"Comet Hyakutake",fr:"comète Hyakutake"},orbit:{eccentricity:.9997295133739305,perihelionAu:.2302272039470452,inclinationDeg:124.923592343765,ascendingNodeDeg:188.0454295899424,argumentOfPerihelionDeg:130.1724036582639,perihelionJd:2.4502048946148166e6},peakMagnitude:0,peakOn:"1996-03-25",absoluteMagnitude:4.75,activityExponent:4,tailLengthDeg:80,tailLengthAu:1,note:"Passed 0.10 au from Earth in March 1996, five weeks BEFORE perihelion, with a tail measured at some 80 degrees — the longest of the modern era."},{id:"hale-bopp-1997",designation:"C/1995 O1",name:{en:"Comet Hale-Bopp",fr:"comète Hale-Bopp"},orbit:{eccentricity:.9951314746156615,perihelionAu:.9141695067003724,inclinationDeg:89.43017155012492,ascendingNodeDeg:282.470602866853,argumentOfPerihelionDeg:130.5872524854533,perihelionJd:2450539633099368e-9},peakMagnitude:-.8,peakOn:"1997-04-01",absoluteMagnitude:-1.06,activityExponent:4,tailLengthDeg:20,tailLengthAu:.9938,note:"Visible to the naked eye for about eighteen months, longer than any comet on record."},{id:"mcnaught-2007",designation:"C/2006 P1",name:{en:"Comet McNaught",fr:"comète McNaught"},orbit:{eccentricity:1.00001811603225,perihelionAu:.1707325614080681,inclinationDeg:77.83726446452654,ascendingNodeDeg:267.4149080498975,argumentOfPerihelionDeg:155.9756130642756,perihelionJd:2454113298753579e-9},peakMagnitude:-5.5,peakOn:"2007-01-13",absoluteMagnitude:2.53,activityExponent:4,tailLengthDeg:35,tailLengthAu:.5009,note:"The brightest comet since Ikeya-Seki, seen in daylight beside the Sun in January 2007."},{id:"lovejoy-2011",designation:"C/2011 W3",name:{en:"Comet Lovejoy",fr:"comète Lovejoy"},orbit:{eccentricity:.999915056276912,perihelionAu:.005553783989325053,inclinationDeg:134.3558712062691,ascendingNodeDeg:326.3693517957772,argumentOfPerihelionDeg:53.50991655176601,perihelionJd:2455911511809431e-9},peakMagnitude:-3,peakOn:"2011-12-16",alsoRecordedMagnitude:1.5,alsoRecordedOn:"2011-12-22",absoluteMagnitude:3.51,activityExponent:1.194,note:"A sungrazer that was expected to be destroyed at perihelion and came out the other side, to stand in the southern dawn sky for the rest of December — which is the second magnitude recorded here."},{id:"panstarrs-2013",designation:"C/2011 L4",name:{en:"Comet PANSTARRS",fr:"comète PANSTARRS"},orbit:{eccentricity:1.000032542889696,perihelionAu:.301544229714915,inclinationDeg:84.2081978367921,ascendingNodeDeg:65.66588626213694,argumentOfPerihelionDeg:333.6516444379993,perihelionJd:2456361669960698e-9},peakMagnitude:1,peakOn:"2013-03-10",absoluteMagnitude:5.98,activityExponent:4},{id:"neowise-2020",designation:"C/2020 F3",name:{en:"Comet NEOWISE",fr:"comète NEOWISE"},orbit:{eccentricity:.9991782081129224,perihelionAu:.2946512466331692,inclinationDeg:128.9375043020912,ascendingNodeDeg:61.01042991771634,argumentOfPerihelionDeg:37.2786526292898,perihelionJd:2.4590341788972816e6},peakMagnitude:.9,peakOn:"2020-07-08",absoluteMagnitude:5.79,activityExponent:4,tailLengthDeg:10,tailLengthAu:.1808,note:"The first comet since Hale-Bopp that ordinary observers in the northern hemisphere saw without being told where to look."},{id:"tsuchinshan-atlas-2024",designation:"C/2023 A3",name:{en:"Comet Tsuchinshan-ATLAS",fr:"comète Tsuchinshan-ATLAS"},orbit:{eccentricity:1.000020192843226,perihelionAu:.3914228969475176,inclinationDeg:139.1105462619479,ascendingNodeDeg:21.55945689078845,argumentOfPerihelionDeg:308.4913086299446,perihelionJd:2460581242087108e-9},peakMagnitude:0,peakOn:"2024-10-14",absoluteMagnitude:3.97,activityExponent:4,tailLengthDeg:20,tailLengthAu:.1902,note:"Briefly reported far brighter around 9 October 2024, when it stood almost between the observer and the Sun and forward-scattered the light through its own dust — a geometry this catalog's brightness model does not attempt, so what is stored is the ordinary evening-sky peak a few days later."}];class EE{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(t){const e=this.julianDayOf(t);return Rm.filter(n=>Math.abs(e-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(t,e){return this.aroundDate(t).map(n=>this.appearanceOf(n,t,e)).sort((n,i)=>n.magnitude-i.magnitude)[0]}static appearanceOf(t,e,n){const i=Ve(e),r=this.earthPositionAt(i),a=this.apparentPositionOf(t,2451545+i.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,i,e,n),u=this.horizontalOf(o,i,e,n);return{apparition:t,position:u,...h,heliocentricDistanceAu:c,earthDistanceAu:l,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(t,c,l)}}static magnitudeAt(t,e,n){const i=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(i,t.peakMagnitude)}static tailEndAt(t,e,n,i,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/i,l=this.subtract({x:e.x*c,y:e.y*c,z:e.z*c},n),h=this.subtract(e,n);return{tailEnd:this.horizontalOf(l,r,a,o),tailLengthDeg:this.angleBetween(h,l)}}static apparentPositionOf(t,e,n){const i=this.orbitOf(t);let r=i.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=i.positionAt(e-o)}return r}static horizontalOf(t,e,n,i){const r=ko(vS(),new ge(t.x,t.y,t.z,e)),a=ko(xS(e),r),o=K3(e,new Lu(i.lat,i.lng,i.elevationM)),c=new ge(a.x-o.x,a.y-o.y,a.z-o.z,e),l=um(c);return Rr(l.ra,l.dec,n,i)}static earthPositionAt(t){return ko(gS(),os(St.Earth,t))}static julianDayOf(t){return 2451545+Ve(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new Ri(t.orbit);return this.orbits.set(t.id,n),n}static subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}static length(t){return Math.hypot(t.x,t.y,t.z)}static angleBetween(t,e){const n=(t.x*e.x+t.y*e.y+t.z*e.z)/(this.length(t)*this.length(e)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const wE=[{id:"quadrantids",code:"QUA",name:{en:"Quadrantids",fr:"Quadrantides"},radiantRaHours:15.33,radiantDecDeg:49.7,start:{month:12,day:28},peak:{month:1,day:3},end:{month:1,day:12},peakZhr:110,velocityKmS:41,populationIndex:2.1},{id:"lyrids",code:"LYR",name:{en:"April Lyrids",fr:"Lyrides d'avril"},radiantRaHours:18.13,radiantDecDeg:33.3,start:{month:4,day:16},peak:{month:4,day:22},end:{month:4,day:25},peakZhr:18,velocityKmS:49,populationIndex:2.1},{id:"eta-aquariids",code:"ETA",name:{en:"eta Aquariids",fr:"Êta Aquarides"},radiantRaHours:22.53,radiantDecDeg:-1,start:{month:4,day:19},peak:{month:5,day:6},end:{month:5,day:28},peakZhr:50,velocityKmS:66,populationIndex:2.4},{id:"alpha-capricornids",code:"CAP",name:{en:"alpha Capricornids",fr:"Alpha Capricornides"},radiantRaHours:20.47,radiantDecDeg:-9.2,start:{month:7,day:3},peak:{month:7,day:30},end:{month:8,day:15},peakZhr:5,velocityKmS:23,populationIndex:2.5},{id:"southern-delta-aquariids",code:"SDA",name:{en:"Southern delta Aquariids",fr:"Delta Aquarides du Sud"},radiantRaHours:22.67,radiantDecDeg:-16.4,start:{month:7,day:12},peak:{month:7,day:30},end:{month:8,day:23},peakZhr:25,velocityKmS:41,populationIndex:3.2},{id:"perseids",code:"PER",name:{en:"Perseids",fr:"Perséides"},radiantRaHours:3.22,radiantDecDeg:58,start:{month:7,day:17},peak:{month:8,day:12},end:{month:8,day:24},peakZhr:100,velocityKmS:59,populationIndex:2.2},{id:"southern-taurids",code:"STA",name:{en:"Southern Taurids",fr:"Taurides du Sud"},radiantRaHours:3.47,radiantDecDeg:13,start:{month:9,day:10},peak:{month:10,day:10},end:{month:11,day:20},peakZhr:5,velocityKmS:27,populationIndex:2.3},{id:"draconids",code:"DRA",name:{en:"October Draconids",fr:"Draconides d'octobre"},radiantRaHours:17.47,radiantDecDeg:54,start:{month:10,day:6},peak:{month:10,day:8},end:{month:10,day:10},peakZhr:10,velocityKmS:20,populationIndex:2.6},{id:"orionids",code:"ORI",name:{en:"Orionids",fr:"Orionides"},radiantRaHours:6.35,radiantDecDeg:15.6,start:{month:10,day:2},peak:{month:10,day:21},end:{month:11,day:7},peakZhr:20,velocityKmS:66,populationIndex:2.5},{id:"northern-taurids",code:"NTA",name:{en:"Northern Taurids",fr:"Taurides du Nord"},radiantRaHours:3.87,radiantDecDeg:22,start:{month:10,day:20},peak:{month:11,day:12},end:{month:12,day:10},peakZhr:5,velocityKmS:29,populationIndex:2.3},{id:"leonids",code:"LEO",name:{en:"Leonids",fr:"Léonides"},radiantRaHours:10.13,radiantDecDeg:21.6,start:{month:11,day:6},peak:{month:11,day:17},end:{month:11,day:30},peakZhr:15,velocityKmS:71,populationIndex:2.5},{id:"geminids",code:"GEM",name:{en:"Geminids",fr:"Géminides"},radiantRaHours:7.47,radiantDecDeg:32.3,start:{month:12,day:4},peak:{month:12,day:14},end:{month:12,day:17},peakZhr:150,velocityKmS:35,populationIndex:2.6},{id:"ursids",code:"URS",name:{en:"Ursids",fr:"Ursides"},radiantRaHours:14.47,radiantDecDeg:75.3,start:{month:12,day:17},peak:{month:12,day:22},end:{month:12,day:26},peakZhr:10,velocityKmS:33,populationIndex:3}],oc=6.5;class Pl{static activeAt(t){return wE.flatMap(e=>{const n=this.nearness(e,t);return n<=0?[]:[{shower:e,zhr:e.peakZhr*n,nearness:n}]})}static nearness(t,e){const n=this.dayOfYear(e),i=this.dayOfYear(this.asDate(t.start)),r=this.dayOfYear(this.asDate(t.peak)),a=this.dayOfYear(this.asDate(t.end)),o=this.wrappedDelta(n,r),c=this.wrappedDelta(r,i),l=this.wrappedDelta(a,r);return o<0?o<-c?0:1+o/c:o>0?o>l?0:1-o/l:1}static observedRatePerHour(t,e,n,i=oc){if(e<=0)return 0;const r=oc-i;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return Rr(t.radiantRaHours,t.radiantDecDeg,e,n)}static dayOfYear(t){const e=Date.UTC(t.getUTCFullYear(),0,1);return Math.floor((Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())-e)/864e5)+1}static asDate(t){return new Date(Date.UTC(2001,t.month-1,t.day))}static wrappedDelta(t,e){const n=t-e;return n>182?n-365:n<-182?n+365:n}}class Re{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=Ve(t),i=new Pu(0,q3(t).elon-90,1),r=ko(_S(n),hm(i,n)),a=um(r);return Rr(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=oc){const n=Re.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),i=oc-e;return(Re.QUIET_RATE_PER_HOUR+n)/Math.pow(Re.POPULATION_INDEX,i)}static schedule(t){const e=new gm(t.seed^1542469173);return Rs.schedule(t).map(n=>{const i=Re.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=Re.turnAround(i,e.between(0,360)),o={x:i.x*Math.cos(r)+a.x*Math.sin(r),y:i.y*Math.cos(r)+a.y*Math.sin(r),z:i.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:Re.toHorizontal(o),bearingDeg:Re.bearingFrom(o,i)}})}static turnAround(t,e){const[n,i]=Re.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+i.x*Math.sin(r),y:n.y*Math.cos(r)+i.y*Math.sin(r),z:n.z*Math.cos(r)+i.z*Math.sin(r)}}static bearingFrom(t,e){const[n,i]=Re.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=Re.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*i.x+a.y*i.y+a.z*i.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(t){const e=Math.abs(t.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=Re.normalise(Re.cross(t,e));return[n,Re.normalise(Re.cross(t,n))]}static toHorizontal(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,t.y/e)))*180/Math.PI,azimuthDeg:(Math.atan2(t.x,-t.z)*180/Math.PI%360+360)%360}}static appearanceOf(t){const e=Re.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=Re.turnAround(e,t.bearingDeg),i=t.fromRadiantDeg*Math.PI/180;return Re.toHorizontal({x:e.x*Math.cos(i)+n.x*Math.sin(i),y:e.y*Math.cos(i)+n.y*Math.sin(i),z:e.z*Math.cos(i)+n.z*Math.sin(i)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,i=Math.cos(e);return{x:i*Math.sin(n),y:Math.sin(e),z:-i*Math.cos(n)}}static cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}static normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}static TYPICAL_VELOCITY_KM_S=40}class AE{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=me.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=me.sizeMAt(e.inFrontM,t);this.upperM=this.upperM===void 0?n:Math.min(this.upperM,n)}}}get sizeRange(){return{minM:this.lowerM,maxM:this.upperM}}get empty(){return this.lowerM===void 0&&this.upperM===void 0}get contradictory(){return this.lowerM!==void 0&&this.upperM!==void 0&&this.lowerM>this.upperM}distanceRangeAt(t){return t<=0?{}:{minM:this.lowerM===void 0?void 0:me.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:me.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}class Sr{static DEG_PER_SECOND=360/86164.0905;static degOver(t){return Math.max(0,t)*Sr.DEG_PER_SECOND}static instants(t,e){if(!(e>0))return 1;const n=Sr.degOver(t)/e;return n<1?1:Math.min(Sr.MAX_INSTANTS,Math.max(2,Math.ceil(n)))}static MAX_INSTANTS=64}class on{static EYE={apertureMm:7,exposureSeconds:.1,resolutionArcsec:60};static WAVELENGTH_M=55e-8;static ARCSEC_PER_RADIAN=180*3600/Math.PI;static UNKNOWN_CAMERA_FOCAL_MM=50;static UNKNOWN_CAMERA_DETAIL_UM=20;static get skyDriftArcsecPerSecond(){return Sr.DEG_PER_SECOND*3600}static graspOf(t,e={}){const n=e.exposureSeconds??t.exposureSeconds,i=e.fNumber??t.fNumber;if(n===void 0||i===void 0||!(n>0)||!(i>0))return on.EYE;const r=e.focalLengthMm??t.frame?.focalLengthMm??on.UNKNOWN_CAMERA_FOCAL_MM,a=r/i,o=on.resolutionArcsec(t,r,a);return{apertureMm:a,exposureSeconds:Math.min(n,on.trailLimitedSeconds(o)),resolutionArcsec:o}}static resolutionArcsec(t,e,n){const r=(t.detailUm??on.UNKNOWN_CAMERA_DETAIL_UM)/1e3/e*on.ARCSEC_PER_RADIAN,a=1.22*on.WAVELENGTH_M/(n/1e3)*on.ARCSEC_PER_RADIAN;return Math.max(r,a)}static trailLimitedSeconds(t){return t/on.skyDriftArcsecPerSecond}static gainOverEye(t,e={}){const n=on.graspOf(t,e),i=on.EYE,r=(n.apertureMm/i.apertureMm)**2,a=n.exposureSeconds/i.exposureSeconds,o=(i.resolutionArcsec/n.resolutionArcsec)**2;return 1.25*Math.log10(r*a*o)}static gainFor(t,e){const n=e.fieldOfViewDeg===void 0?void 0:ze.focalLengthMmFor(t,e.fieldOfViewDeg);return on.gainOverEye(t,{fNumber:e.fNumber,focalLengthMm:n,exposureSeconds:e.exposureSeconds})}}class Di{static PIXELS_PER_INSTANT=2;static INSTANTS_PER_FLASH=2;static MAX_INSTANTS=512;static instants(t,e,n,i,r){if(!(i>0))return 1;const a=r>0?Di.travelDegOver(t,e,n,n+i*1e3)/r/Di.PIXELS_PER_INSTANT:0,o=Di.flashesOver(t,i)*Di.INSTANTS_PER_FLASH,c=Math.ceil(Math.max(a,o));return c<2?1:Math.min(Di.MAX_INSTANTS,c)}static travelDegOver(t,e,n,i){let r=0;for(const a of t){if(!a.track||a.track.length<2)continue;const o=Di.directionAt(a,e,n),c=Di.directionAt(a,e,i),l=Math.min(1,Math.max(-1,o.x*c.x+o.y*c.y+o.z*c.z));r=Math.max(r,Math.acos(l)*180/Math.PI)}return r}static flashesOver(t,e){let n=0;for(const i of t)for(const r of i.lights??[])r.pattern.kind==="flash"&&(n=Math.max(n,r.pattern.perMinute));return n/60*e}static directionAt(t,e,n){const i=nu(t,n),r=i.eastM,a=i.altitudeM-e,o=i.northM,c=Math.hypot(r,a,o);return c===0?{x:0,y:1,z:0}:{x:r/c,y:a/c,z:o/c}}}const Vf=111320,Qr=Math.PI/180,TE=1.02,RE=1;class ua{static of(t,e){const n=ua.sightings(t,e);if(n.length<2)return;const i=ua.baseline(n);if(!i)return;const{near:r,far:a,closedM:o}=i,c=Math.tan(a.widthDeg/2*Qr)===0?0:Math.tan(r.widthDeg/2*Qr)/Math.tan(a.widthDeg/2*Qr);if(c<TE)return;const l=o/(c-1),h=me.sizeMAt(l,r.widthDeg),u=n.map(d=>({t:d.t,m:me.distanceMAt(h,d.widthDeg)}));return{widthM:h,distanceM:u,nearestM:Math.min(...u.map(d=>d.m)),fromT:a.t,toT:r.t,closedM:o}}static sightings(t,e){return t.timeline.allKeyframes.flatMap(n=>{const i=n.shapes.find(o=>o.sourceId===e)?.shape,r=i?.angular?.widthDeg,a=tn(t,n.t);return r===void 0||r<=0||a?.lat===void 0||a.lng===void 0?[]:[{t:n.t,widthDeg:r,lat:a.lat,lng:a.lng,sightAzimuthDeg:i?.aim?.azimuthDeg??a.headingDeg}]}).sort((n,i)=>n.t-i.t)}static baseline(t){let e;for(const n of t)for(const i of t){if(n.t>=i.t)continue;const r=ua.closedAlongSight(n,i),[a,o,c]=r>=0?[i,n,r]:[n,i,-r];c<RE||a.widthDeg<=o.widthDeg||(!e||c>e.closedM)&&(e={near:a,far:o,closedM:c})}return e}static closedAlongSight(t,e){const n=(e.lat-t.lat)*Vf,i=(e.lng-t.lng)*Vf*Math.cos(t.lat*Qr),r=(t.sightAzimuthDeg??0)*Qr;return n*Math.cos(r)+i*Math.sin(r)}}class an{static CONVENTIONAL_M=5;static NEAREST_M=.2;static MARGIN=1.1;static resolve(t){if(t.statedM!==void 0&&t.statedM>0)return{distanceM:an.atLeastNearest(t.statedM),basis:"stated"};if(t.hypothesisM!==void 0&&t.hypothesisM>0)return{distanceM:an.atLeastNearest(t.hypothesisM),basis:"hypothesis"};if(t.derivedM!==void 0&&t.derivedM>0)return{distanceM:an.atLeastNearest(t.derivedM),basis:"derived"};const e=an.largest(t.range?.minM,t.crossing?.behindM),n=an.smallest(t.range?.maxM,t.crossing?.inFrontM),i=e===void 0?void 0:e*an.MARGIN,r=n===void 0?void 0:n/an.MARGIN;return i!==void 0&&r!==void 0?{distanceM:an.atLeastNearest(i<=r?Math.sqrt(i*r):i),basis:"bounded"}:i!==void 0?{distanceM:an.atLeastNearest(i),basis:"bounded"}:r!==void 0&&r<an.CONVENTIONAL_M?{distanceM:an.atLeastNearest(r),basis:"bounded"}:{distanceM:an.CONVENTIONAL_M,basis:"conventional"}}static atLeastNearest(t){return Math.max(an.NEAREST_M,t)}static largest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.max(...e)}static smallest(...t){const e=t.filter(n=>n!==void 0&&n>0);return e.length===0?void 0:Math.min(...e)}}ap();const DE={sun:{en:"Sun",fr:"Soleil"},moon:{en:"Moon",fr:"Lune"},Venus:{en:"Venus",fr:"Vénus"},Mars:{en:"Mars",fr:"Mars"},Jupiter:{en:"Jupiter",fr:"Jupiter"},Saturn:{en:"Saturn",fr:"Saturne"}},CE=["en","fr"],PE={en:"{name} — mag {mag}, {alt}° above the horizon",fr:"{name} — mag {mag}, {alt}° au-dessus de l'horizon"},IE={en:"{name} — mag {mag}, {alt}° below the horizontal",fr:"{name} — mag {mag}, {alt}° sous l'horizontale"},Wf="comet:",LE={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},crop:{en:"Crop row",fr:"Rang de culture"},mound:{en:"Stone heap",fr:"Tas de pierres"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"},entity:{en:"Being",fr:"Être"}},NE=new URL(""+new URL("stars-mag7.5-B43R6Wvg.bin",import.meta.url).href,import.meta.url).href,OE=new URL(""+new URL("stars-mag7.5-9-BLV2tFmZ.bin",import.meta.url).href,import.meta.url).href,UE=-18,FE={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},Il={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class zE extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","deep-star-catalog-src","show-compass",fr,pr]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;distanceHypotheses=new Map;depths=new Map;directionScratch=new P;meteorScheduleFor;lastTimeMs=0;lastSkyKey;starCatalog;starCatalogRequest=0;starCatalogDepth=0;weatherAudio=new bE;animateWhilePausedValue=!1;set animateWhilePaused(t){t!==this.animateWhilePausedValue&&(this.animateWhilePausedValue=t,this.syncAnimationsToPlayback())}get animateWhilePaused(){return this.animateWhilePausedValue}thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=t=>{this.sceneRenderer.setCompassHovered(!0);const e=this.ufoElement.canvasElement,n=e.getBoundingClientRect();if(n.width===0||n.height===0)return;const i=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(i,r)){this.hoverTooltip.hidden=!0;return}const a=(t.clientX-n.left)/n.width*2-1,o=-((t.clientY-n.top)/n.height*2-1),c=eu(Vo.preferencesFor(this),CE),l=this.sceneRenderer.pickBodyAt(a,o);if(l){this.showHoverTooltip(t,this.bodyName(l,c));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(f=>f.id===h):void 0;if(u){this.showHoverTooltip(t,this.said.read(u.title)||LE[u.kind][c]);return}const d=this.sceneRenderer.pickStarAt(a,o);if(d){const f=d.star.mag,g=d.altitudeDeg,v=(g<0?IE:PE)[c];this.showHoverTooltip(t,v.replace("{name}",d.star.name[c]).replace("{mag}",f.toLocaleString(void 0,{maximumFractionDigits:Math.abs(f)<1?2:1})).replace("{alt}",String(Math.round(Math.abs(g)))));return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(Wf)?t.slice(Wf.length):void 0;return(n?Rm.find(r=>r.id===n):void 0)?.name[e]??DE[t]?.[e]??t}showHoverTooltip(t,e){this.hoverTooltip.textContent=e,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${t.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${t.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const t=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),t)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(qu(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs)};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing"||this.animateWhilePaused;this.sceneRenderer.setAnimationsRunning(t),this.weatherAudio.setPaused(!t),t||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Fm}</style>${Um}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new ai(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(Fl),this.ufoElement.classList.add("ufo-overlay"),this.ufoElement.paintsShapes=!1,this.forwardPlayerAttributes(),this.ufoElement.addEventListener("lookat",e=>this.lookToward(e.detail)),this.ufoElement.style.setProperty("--ufo-canvas-background","transparent"),this.ufoElement.style.setProperty("--ufo-canvas-border","none"),this.ufoElement.fullscreenTarget=this.stageElement,this.shadow.getElementById("ufo-slot").replaceWith(this.ufoElement),this.ufoElement.addEventListener("timeupdate",this.handleTimeUpdate),this.ufoElement.canvasElement.addEventListener("pointermove",this.handlePointerMove),this.ufoElement.canvasElement.addEventListener("pointerleave",this.handlePointerLeave),this.ufoElement.canvasElement.addEventListener("pointerdown",this.handleFirstInteraction,{once:!0})}get said(){return this.saidTexts??=new ns(Vo.preferencesFor(this))}saidTexts;connectedCallback(){this.saidTexts=void 0,this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),(t==="star-catalog-src"||t==="deep-star-catalog-src")&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),(t===fr||t===pr)&&n!==e&&this.forwardPlayerAttributes()}forwardPlayerAttributes(){for(const t of[fr,pr])this.ufoElement.toggleAttribute(t,this.hasAttribute(t))}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}lookToward(t){const e=tn(this.ufoElement.sighting,this.lastTimeMs);if(t.kind==="witness"||e?.lat===void 0||e.lng===void 0||e.headingDeg===void 0){this.setLookOffset(0,0);return}const{x:n,z:i}=un(t.lat,t.lng,e.lat,e.lng);if(Math.hypot(n,i)<1)return this.setLookOffset(0,0);const r=(Math.atan2(n,-i)*180/Math.PI+360)%360;this.setLookOffset(((r-e.headingDeg)%360+540)%360-180,-e.pitchDeg)}setLookOffset(t,e){this.sceneRenderer.setLookOffset(t,e),this.ufoElement.setLookOffset(t,e),this.updateAstronomy(this.lastTimeMs)}setIndoorLook(t,e){this.sceneRenderer.setIndoorLook(t,e)}setWeather(t){this.sceneRenderer.setWeather(t),this.weatherAudio.setAmbient(t.precipitationType,t.precipitationIntensity,t.windSpeed)}pickDecorAt(t,e){return this.sceneRenderer.pickDecorAt(t,e)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(t){this.sightingData=await qf.json(t)}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.applyFrameFormat(),this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}setDecorModelProvider(t){this.sceneRenderer.setDecorModelProvider(t)}get decorModelCredits(){return this.sceneRenderer.currentDecorModelCredits}applyFrameFormat(){const t=this.ufoElement.sighting.instrument,e=me.CANVAS_HEIGHT_PX,n=ze.frameWidthPx(t,e);this.frameElement.style.setProperty("--frame-aspect",`${n} / ${e}`)}resizeToStage(){const t=this.frameElement.getBoundingClientRect(),e=Math.max(1,Math.round(t.width)),n=Math.max(1,Math.round(t.height));this.sceneCanvas.width=e,this.sceneCanvas.height=n,this.sceneRenderer.resize(e,n)}async loadStars(){const t=[{magnitudeLimit:Dl,url:this.getAttribute("star-catalog-src")??NE},{magnitudeLimit:Cl,url:this.getAttribute("deep-star-catalog-src")??OE}],e=this.instrumentReach(),n=++this.starCatalogRequest;this.starCatalogDepth=e>Dl?Cl:Dl;const i=await oi.upTo(t,e);n===this.starCatalogRequest&&(this.starCatalog=i,this.updateAstronomy(this.lastTimeMs))}ensureStarsDeepEnough(){!this.starCatalog||this.starCatalogDepth>=Cl||this.instrumentReach()<=this.starCatalogDepth||this.loadStars()}instrumentReach(){const t=this.ufoElement.sighting,e=on.gainFor(t.instrument,{fNumber:tn(t,0)?.fNumber,fieldOfViewDeg:Un.fovOf(t,0),exposureSeconds:t.exposure});return Wp(UE,e)}updateAstronomy(t){this.ensureStarsDeepEnough(),this.applySceneAt(t);const e=this.exposureSeconds(),n=this.degreesPerPixelAt(t),i=Sr.instants(e,n),r=Math.max(i,this.ufoElement.exposureTimes(t).length,Di.instants(this.ufoElement.sighting.decor,tn(this.ufoElement.sighting,t)?.elevationM??0,t,e,n));if(r<=1){this.sceneRenderer.setExposure(1);return}const a=e*1e3;this.sceneRenderer.setExposure(r,o=>this.applySceneAt(t+a*o/r,{sky:Math.floor(o*i/r)!==Math.floor((o-1)*i/r),stepMs:a/r}))}exposureSeconds(){return this.ufoElement.sighting.exposure??0}degreesPerPixelAt(t){const e=this.sceneCanvas.height;return e<=0?0:Un.fovOf(this.ufoElement.sighting,t)/e}applySceneAt(t,e){const n=this.ufoElement.sighting;this.setWeather(qu(n,t)),this.sceneRenderer.setInstrument(n.instrument),this.updateMeteorShower(n,t),this.sceneRenderer.setDecor(n.decor);const i=tn(n,t);if(this.sceneRenderer.setObserverPose(i??Il),this.sceneRenderer.setLensOptics(this.lensOpticsAt(t)),this.sceneRenderer.setInstrumentGain(on.gainFor(n.instrument,{fNumber:i?.fNumber,fieldOfViewDeg:Un.fovOf(n,t),exposureSeconds:n.exposure})),this.sceneRenderer.setGait(Fe.of(n)?.offsetAt(t)??Fe.STILL),this.sceneRenderer.updateDecorAnchoring(tn(n,0),i,t),this.sceneRenderer.updateDecorLitState(t,e?.stepMs??0),this.sceneRenderer.setTerrainOrigin(i?.lat,i?.lng),this.pushPhenomenaAt(t),e&&!e.sky)return;const r=i?.lat??Il.lat,a=i?.lng??Il.lng,o=K0(n.event.time??{},a,n.event.utcOffsetHours);if(!o){this.sceneRenderer.setAstronomy(FE);return}const c=new Date(o.getTime()+t),l={lat:r,lng:a,elevationM:i?.elevationM??0},h=`${c.getTime()}|${r}|${a}|${l.elevationM}|${this.starCatalog?this.starCatalogDepth:0}`;if(h===this.lastSkyKey){this.sceneRenderer.render();return}this.lastSkyKey=h;const u={...dl("Sun",c,l),magnitude:fl("Sun",c)},d={...dl("Moon",c,l),phase:yS(c),magnitude:fl("Moon",c)},f=MS.map(g=>({body:g,position:dl(g,c,l),magnitude:fl(g,c)}));this.sceneRenderer.setAstronomy({sun:u,moon:d,planets:f,comet:this.cometAt(c,l),stars:this.starCatalog?{catalog:this.starCatalog,date:c,observer:l}:void 0,frame:{date:c,observer:l}}),this.ufoElement.setSunAltitude(u.altitudeDeg)}cometAt(t,e){const n=EE.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}pushPhenomenaAt(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.distanceHypotheses.clear(),this.sizeEstimatesFor=e);const n=e.timeline,i=this.ufoElement.canvasElement,r=this.ufoElement.frameShiftPx,a=this.projectionAt(t),o=new Map,c=new Map,l=new Set;for(const v of n.sourceIds){const p=n.getInterpolatedShapeAt(t,v);if(!p)continue;const m={...p,bounds:{...p.bounds,x:p.bounds.x+r.x,y:p.bounds.y+r.y}};o.set(v,m);const b=p.aim?this.sceneRenderer.screenPointOf(Xn.directionOf(p.aim,this.directionScratch)):{ndcX:(m.bounds.x+m.bounds.width/2)/i.width*2-1,ndcY:-((m.bounds.y+m.bounds.height/2)/i.height*2-1)},E=b!==void 0&&Math.abs(b.ndcX)<=1&&Math.abs(b.ndcY)<=1,M=E?this.sceneRenderer.decorDistancesAt(b.ndcX,b.ndcY,v):{};l.add(v),(E||p.aim)&&l.delete(v);const S=p.angular?.widthDeg??a.pxToDeg(p.bounds.width),w=this.sizeEstimateOf(v);w.add(S,M);const R=ua.of(e,v);c.set(v,an.resolve({hypothesisM:this.distanceHypotheses.get(v),derivedM:R&&S>0?me.distanceMAt(R.widthM,S):void 0,range:w.distanceRangeAt(S),crossing:M}))}for(const[v,p]of o)for(const[m,b]of o){if(m===v||b.transparency>=1||b.bounds.width*b.bounds.height<=p.bounds.width*p.bounds.height||!(p.bounds.x>=b.bounds.x&&p.bounds.y>=b.bounds.y&&p.bounds.x+p.bounds.width<=b.bounds.x+b.bounds.width&&p.bounds.y+p.bounds.height<=b.bounds.y+b.bounds.height))continue;const M=c.get(m);M&&c.set(v,{distanceM:M.distanceM*.999,basis:M.basis});break}this.depths=c;const h=n.sourceIds,u=this.sceneRenderer.lowerCloudUp,d=[];for(const[v,p]of o)d.push({sourceId:v,shape:p,distanceM:c.get(v).distanceM,renderOrder:h.indexOf(v),aim:p.aim,hidden:p.behindCloud===!0&&u||l.has(v)});const g=(tn(e,t)?.rollDeg??0)+(Fe.of(e)?.offsetAt(t)??Fe.STILL).rollDeg;this.sceneRenderer.setPhenomena(d,{projection:a,canvasWidthPx:i.width,canvasHeightPx:i.height,scale:Math.max(1,this.sceneCanvas.height/Math.max(1,i.height)),starPoints:ze.starPointsOf(e.instrument),rollRad:g*Math.PI/180})}setDistanceHypothesis(t,e){e===void 0||!(e>0)?this.distanceHypotheses.delete(t):this.distanceHypotheses.set(t,e),this.updateAstronomy(this.lastTimeMs)}depthOf(t){return this.depths.get(t)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const i=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(i)}sizeContradictory(t){return this.sizeEstimateOf(t).contradictory}updateMeteorShower(t,e){this.ensureMeteorSchedule(t),this.sceneRenderer.updateMeteors(e)}ensureMeteorSchedule(t){const e=this.meteorInputsOf(t);e!==this.meteorScheduleFor&&(this.meteorScheduleFor=e,this.scheduleMeteors(t))}meteorInputsOf(t){const e=t.event.place?.[0],n=t.event.time;return JSON.stringify([e?.lat,e?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,t.event.utcOffsetHours,t.event.durationSeconds,t.timeline.duration])}scheduleMeteors(t){const e=t.event.place?.[0],n=t.event.time,i=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?K0(n,e.lng,t.event.utcOffsetHours):void 0;if(!i||e?.lat===void 0||e.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:e.lat,lng:e.lng,elevationM:0},a=(t.event.durationSeconds??0)*1e3||t.timeline.duration||2e4,o=Math.round(i.getTime()/1e3)+Math.round(e.lat*1e3),c=Re.schedule({ratePerHour:Re.observedRatePerHour(Re.apexPosition(i,r).altitudeDeg),durationMs:a,velocityKmS:Re.TYPICAL_VELOCITY_KM_S,seed:o}),l=Pl.activeAt(i).map(u=>{const d=Pl.radiantPosition(u.shower,i,r);return{entry:u,position:d,rate:Pl.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!l||l.rate<=0){this.sceneRenderer.setMeteorShower(c,0,0);return}const h=Rs.schedule({ratePerHour:l.rate,durationMs:a,velocityKmS:l.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...c],l.position.altitudeDeg,l.position.azimuthDeg)}meteorByRank(t){this.ensureMeteorSchedule(this.ufoElement.sighting);const e=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(e.length===0)return;const n=e[t%e.length],i=this.sceneRenderer.meteorMidpoint(n);if(i)return{t:Math.round(n.t+n.durationMs*.45),...i}}lensOpticsAt(t){const e=this.ufoElement.sighting,n=e.instrument,i=n.frame,r=tn(e,t),a=r?.fNumber??n.fNumber;if(!i||a===void 0)return;const o=ze.focalLengthMmFor(n,Un.fovOf(e,t));if(o!==void 0)return{focalLengthMm:o,fNumber:a,focusDistance:r?.focusDistanceM??0,frameHeightMm:i.heightMm}}projectionAt(t){const e=this.ufoElement.sighting;return Ii.of(e.instrument,me.CANVAS_HEIGHT_PX,Un.fovOf(e,t))}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new AE,this.sizeEstimates.set(t,e)),e}}const Xf="rr0-scene";function BE(){ap(),customElements.get(Xf)||customElements.define(Xf,zE)}BE();export{l2 as $,WE as A,de as B,vt as C,V2 as D,$t as E,ZE as F,qE as G,Tp as H,XE as I,YE as J,Fo as K,wa as L,KE as M,Ua as N,_e as O,H2 as P,hs as Q,Wo as R,Rn as S,kE as T,en as U,Pt as V,yn as W,VE as X,Ir as Y,Ap as Z,$E as _,GE as a,Yo as a0,Eh as a1,Qo as a2,$e as a3,Lp as a4,yu as a5,Su as a6,Qt as a7,cs as a8,Ea as a9,xi as aa,zi as ab,HE as b,jE as c,$o as d,QE as e,Xt as f,P as g,qd as h,JE as i,tw as j,r2 as k,ws as l,Ec as m,l1 as n,ye as o,ke as p,Yl as q,dn as r,Rp as s,Bi as t,m2 as u,S2 as v,qn as w,Oi as x,ce as y,be as z};
|