@rr0/ufoathome 0.30.0 → 0.32.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.
- package/README.md +27 -9
- package/dist-embed/UfoRecorderMessages_fr-B6c8dtZH.js +1 -0
- package/dist-embed/rr0-ufo-recorder.mjs +347 -320
- package/dist-embed-eyewitness/rr0-eyewitness.mjs +326 -305
- package/dist-embed-scene/rr0-scene.mjs +323 -302
- package/dist-embed-ufo/rr0-ufo.mjs +1 -1
- package/package.json +3 -3
- package/dist-embed/UfoRecorderMessages_fr-AN3bk1Bx.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ef=`
|
|
2
2
|
<div class="toolbar" id="toolbar" hidden>
|
|
3
3
|
<span id="testimony" class="testimony">
|
|
4
4
|
<span id="testimony-prefix">Testimony by</span>
|
|
@@ -33,7 +33,7 @@ const af=`
|
|
|
33
33
|
</div>
|
|
34
34
|
</div>
|
|
35
35
|
<div id="ufo-slot"></div>
|
|
36
|
-
`,
|
|
36
|
+
`,bf=`
|
|
37
37
|
:host {
|
|
38
38
|
display: block;
|
|
39
39
|
font-family: sans-serif;
|
|
@@ -261,7 +261,7 @@ const af=`
|
|
|
261
261
|
margin: 0.4em 0 0;
|
|
262
262
|
padding-left: 1.2em;
|
|
263
263
|
}
|
|
264
|
-
`,
|
|
264
|
+
`,wf=`
|
|
265
265
|
<div class="stage" id="stage">
|
|
266
266
|
<div class="frame" id="frame">
|
|
267
267
|
<canvas id="scene-canvas"></canvas>
|
|
@@ -269,7 +269,7 @@ const af=`
|
|
|
269
269
|
<div id="ufo-slot"></div>
|
|
270
270
|
<div id="hover-tooltip" class="hover-tooltip" hidden></div>
|
|
271
271
|
</div>
|
|
272
|
-
`,
|
|
272
|
+
`,Af=`
|
|
273
273
|
:host {
|
|
274
274
|
display: block;
|
|
275
275
|
}
|
|
@@ -342,7 +342,7 @@ const af=`
|
|
|
342
342
|
pointer-events: none;
|
|
343
343
|
white-space: nowrap;
|
|
344
344
|
}
|
|
345
|
-
`,
|
|
345
|
+
`,Tf=`
|
|
346
346
|
<div class="stage" id="stage">
|
|
347
347
|
<div class="frame" id="frame">
|
|
348
348
|
<canvas id="canvas" width="640" height="360"></canvas>
|
|
@@ -357,7 +357,7 @@ const af=`
|
|
|
357
357
|
<button id="loop" type="button" title="Auto-replay" aria-label="Auto-replay" aria-pressed="true">↻</button>
|
|
358
358
|
</div>
|
|
359
359
|
</div>
|
|
360
|
-
`,
|
|
360
|
+
`,Rf=`
|
|
361
361
|
:host {
|
|
362
362
|
display: block;
|
|
363
363
|
font-family: sans-serif;
|
|
@@ -560,21 +560,21 @@ input[type=range] {
|
|
|
560
560
|
pointer-events: none;
|
|
561
561
|
white-space: nowrap;
|
|
562
562
|
}
|
|
563
|
-
`;class Zt{static MOON_ANGULAR_WIDTH_DEG=.5237;static CANVAS_WIDTH_PX=640;static CANVAS_HEIGHT_PX=360;static angularWidthDeg(e){return 2*Math.atan(e.sizeM/(2*e.distanceM))*180/Math.PI}static inMoons(e){return e/Zt.MOON_ANGULAR_WIDTH_DEG}static lerpAngular(e,t,n){if(!(!e||!t))return{widthDeg:e.widthDeg+(t.widthDeg-e.widthDeg)*n,heightDeg:e.heightDeg+(t.heightDeg-e.heightDeg)*n}}static sizeMAt(e,t){return 2*e*Math.tan(t*Math.PI/360)}static distanceMAt(e,t){return e/(2*Math.tan(t*Math.PI/360))}}function df(i,e,t){const{bounds:n}=i;return e>=n.x&&e<=n.x+n.width&&t>=n.y&&t<=n.y+n.height}function ln(i,e,t){return i+(e-i)*t}function ah(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return;const t=parseInt(e[1],16);return[t>>16&255,t>>8&255,t&255]}function ff(i){return`#${i.map(e=>Math.round(e).toString(16).padStart(2,"0")).join("")}`}function pf(i,e,t){const n=ah(i),s=ah(e);return!n||!s?t<1?i:e:ff([ln(n[0],s[0],t),ln(n[1],s[1],t),ln(n[2],s[2],t)])}function mf(i,e,t){const n={x:ln(i.bounds.x,e.bounds.x,t),y:ln(i.bounds.y,e.bounds.y,t),width:ln(i.bounds.width,e.bounds.width,t),height:ln(i.bounds.height,e.bounds.height,t)},s=ln(i.angle,e.angle,t),r=ln(i.transparency,e.transparency,t),a=ln(i.haloScale,e.haloScale,t),o=pf(i.color,e.color,t),l=Zt.lerpAngular(i.angular,e.angular,t);return i.kind==="polygon"&&e.kind==="polygon"&&i.points.length===e.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:l,behindCloud:t<1?i.behindCloud:e.behindCloud,points:i.points.map((c,h)=>({x:ln(c.x,e.points[h].x,t),y:ln(c.y,e.points[h].y,t)}))}:{...t<1?i:e,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:l}}class za{keyframes=[];order=[];groups=[];addKeyframe(e,t){const n=this.findInsertIndex(e);if(this.keyframes[n]?.t===e){const s=new Set(t.map(r=>r.sourceId));this.keyframes[n]={t:e,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...t]}}else this.keyframes.splice(n,0,{t:e,shapes:[...t]});for(const s of t)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getKeyframeAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t];return n?.t===e?n:void 0}getShapeAt(e,t){return this.getKeyframeAt(e)?.shapes.find(n=>n.sourceId===t)?.shape}getLatestShapeAt(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return s.shape}}getInterpolatedShapeAt(e,t){const n=this.findShapeAtOrBefore(e,t);if(n?.t===e)return n.shape;const s=this.findShapeAtOrAfter(e,t);return n?s?mf(n.shape,s.shape,(e-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(e,t){let n=this.findInsertIndex(e);for(this.keyframes[n]?.t!==e&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(e,t){for(let n=this.findInsertIndex(e);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===t);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(e,t,n,s){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(s?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(e,r[a]);if(o&&df(o,t,n))return{sourceId:r[a],shape:o}}}removeSource(e){for(let t=this.keyframes.length-1;t>=0;t--){const n=this.keyframes[t].shapes.filter(s=>s.sourceId!==e);n.length===0?this.keyframes.splice(t,1):n.length!==this.keyframes[t].shapes.length&&(this.keyframes[t]={t:this.keyframes[t].t,shapes:n})}this.order=this.order.filter(t=>t!==e),this.removeFromGroup(e)}group(e){if(!(e.length<2)){for(const t of e)this.removeFromGroup(t);this.groups.push([...e])}}ungroup(e){const t=this.groups.findIndex(n=>n.includes(e));t!==-1&&this.groups.splice(t,1)}groupMembers(e){return this.groups.find(t=>t.includes(e))}removeFromGroup(e){const t=this.groups.findIndex(s=>s.includes(e));if(t===-1)return;const n=this.groups[t].filter(s=>s!==e);n.length<2?this.groups.splice(t,1):this.groups[t]=n}bringToFront(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.push(e))}sendToBack(e){const t=this.order.indexOf(e);t!==-1&&(this.order.splice(t,1),this.order.unshift(e))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get sourceIds(){return[...this.order]}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes,order:this.order,groups:this.groups}}static fromJSON(e){const t=new za;for(const n of e.keyframes)t.addKeyframe(n.t,n.shapes);if(e.order){const n=t.order.filter(s=>!e.order.includes(s));t.order=[...e.order,...n]}return e.groups&&(t.groups=e.groups.map(n=>n.filter(s=>t.order.includes(s))).filter(n=>n.length>=2)),t}}function gf(i,e,t){return Math.max(e,Math.min(t,i))}function vf(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function zs(i,e,t){return i+(e-i)*t}function _f(i,e,t){return{lat:i.lat===void 0||e.lat===void 0?void 0:zs(i.lat,e.lat,t),lng:i.lng===void 0||e.lng===void 0?void 0:zs(i.lng,e.lng,t),elevationM:zs(i.elevationM,e.elevationM,t),headingDeg:i.headingDeg===void 0||e.headingDeg===void 0?void 0:vf(i.headingDeg,e.headingDeg,t),pitchDeg:zs(i.pitchDeg,e.pitchDeg,t),fovDeg:zs(i.fovDeg,e.fovDeg,t)}}class or{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,pose:t}:this.keyframes.splice(n,0,{t:e,pose:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestPoseAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].pose:void 0}getInterpolatedPoseAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.pose;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?_f(n.pose,s.pose,gf((e-n.t)/(s.t-n.t),0,1)):n.pose:s?.pose}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new or;for(const n of e.keyframes)t.addKeyframe(n.t,n.pose);return t}}function Ei(i,e,t){return i+(e-i)*t}function xf(i,e,t){const n=((e-i)%360+540)%360-180;return((i+n*t)%360+360)%360}function Mf(i,e,t){return Math.max(e,Math.min(t,i))}function yf(i,e,t){return{cloudCover:Ei(i.cloudCover,e.cloudCover,t),cloudDarkness:Ei(i.cloudDarkness,e.cloudDarkness,t),highCloudCover:i.highCloudCover===void 0||e.highCloudCover===void 0?void 0:Ei(i.highCloudCover,e.highCloudCover,t),lowerCloudCover:i.lowerCloudCover===void 0||e.lowerCloudCover===void 0?void 0:Ei(i.lowerCloudCover,e.lowerCloudCover,t),cloudBaseM:i.cloudBaseM===void 0||e.cloudBaseM===void 0?void 0:Ei(i.cloudBaseM,e.cloudBaseM,t),precipitationType:t<1?i.precipitationType:e.precipitationType,precipitationIntensity:Ei(i.precipitationIntensity,e.precipitationIntensity,t),windDirectionDeg:xf(i.windDirectionDeg,e.windDirectionDeg,t),windSpeed:Ei(i.windSpeed,e.windSpeed,t),storm:t<1?i.storm:e.storm}}class lr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,weather:t}:this.keyframes.splice(n,0,{t:e,weather:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}getLatestWeatherAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].weather:void 0}getInterpolatedWeatherAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.weather;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];return n?s?yf(n.weather,s.weather,Mf((e-n.t)/(s.t-n.t),0,1)):n.weather:s?.weather}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new lr;for(const n of e.keyframes)t.addKeyframe(n.t,n.weather);return t}}class cr{keyframes=[];addKeyframe(e,t){const n=this.findInsertIndex(e);this.keyframes[n]?.t===e?this.keyframes[n]={t:e,sound:t}:this.keyframes.splice(n,0,{t:e,sound:t})}clear(){this.keyframes.length=0}removeKeyframeAt(e){const t=this.findInsertIndex(e);this.keyframes[t]?.t===e&&this.keyframes.splice(t,1)}getLatestSoundAt(e){let t=this.findInsertIndex(e);return this.keyframes[t]?.t!==e&&(t-=1),t>=0?this.keyframes[t].sound:void 0}getInterpolatedSoundAt(e){const t=this.findInsertIndex(e),n=this.keyframes[t]?.t===e?this.keyframes[t]:this.keyframes[t-1];if(n?.t===e)return n.sound;const s=this.keyframes[t]?.t===e?void 0:this.keyframes[t];if(!n)return s?.sound;if(!s)return n.sound;const r=(e-n.t)/(s.t-n.t);return this.lerp(n.sound,s.sound,Math.max(0,Math.min(1,r)))}get duration(){return this.keyframes.length===0?0:this.keyframes[this.keyframes.length-1].t}get allKeyframes(){return this.keyframes}toJSON(){return{keyframes:this.keyframes}}static fromJSON(e){const t=new cr;for(const n of e.keyframes)t.addKeyframe(n.t,n.sound);return t}lerp(e,t,n){return{kind:n<1?e.kind:t.kind,volume:e.volume+(t.volume-e.volume)*n,pitchHz:e.pitchHz+(t.pitchHz-e.pitchHz)*n,src:n<1?e.src:t.src}}findInsertIndex(e){let t=0,n=this.keyframes.length;for(;t<n;){const s=t+n>>>1;this.keyframes[s].t<e?t=s+1:n=s}return t}}const Md=1e3,yd={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},Sf=100,Ef={kind:"none",volume:0,pitchHz:Sf},oh=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear"}];class bf{static get default(){return oh[0]}static byId(e){return oh.find(t=>t.id===e)??this.default}}function nl(i){if(i.year!==void 0)return Date.UTC(i.year,(i.month??1)-1,i.day??1,i.hour??0,i.minute??0,i.second??0)}function lh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const wf=["year","month","day","hour","minute"],Af=["day","hour","minute"];function ch(i,e){return e.filter(t=>i[t]!==void 0).join(",")}function Tf(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const e=i.time.year!==void 0&&i.endTime.year!==void 0,t=e?wf:Af,n=ch(i.time,t);if(!(n===""||n!==ch(i.endTime,t)))return e?nl(i.endTime)-nl(i.time):lh(i.endTime)-lh(i.time)}class Ba{constructor(e,t,n,s,r,a,o,l,c=[],h,u){this.event=e,this.timeline=t,this.witnessTrack=n,this.weatherTrack=s,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=l,this.decor=c,this.weatherSource=h,this.instrumentId=u}get instrument(){return bf.byId(this.instrumentId)}static create(e,t,n){return new Ba({eventType:"sighting",time:e,place:t},new za,new or,new lr,new cr,n)}}const Rf=0,Cf=0,Df=60;function rr(i,e){const t=i.witnessTrack.getInterpolatedPoseAt(e);if(t)return t;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Rf,headingDeg:void 0,pitchDeg:Cf,fovDeg:Df}}function hh(i,e){return i.weatherTrack.getInterpolatedWeatherAt(e)??i.weather??yd}function Pf(i,e){return i.soundTrack.getInterpolatedSoundAt(e)??Ef}class If{constructor(e,t){this.timeline=e,this.onFrame=t}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;durationOverrideMs=0;get seekableDuration(){return Math.max(this.timeline.duration,this.durationOverrideMs)}play(){if(this.state==="playing")return;this.currentT>=this.seekableDuration&&(this.currentT=0,this.resolveFrame(0)),this.state="playing",this.lastWallTime=performance.now();const e=()=>{if(this.state!=="playing")return;const t=performance.now();if(this.currentT+=(t-this.lastWallTime)*this.playbackRate,this.lastWallTime=t,this.currentT>=this.seekableDuration){if(this.loop&&this.seekableDuration>0){this.currentT%=this.seekableDuration,this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e);return}this.currentT=this.seekableDuration,this.stop(),this.resolveFrame(this.currentT);return}this.resolveFrame(this.currentT),this.rafId=requestAnimationFrame(e)};this.rafId=requestAnimationFrame(e)}pause(){this.state==="playing"&&(this.state="paused",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null))}stop(){this.state="stopped",this.rafId!==null&&(cancelAnimationFrame(this.rafId),this.rafId=null)}seek(e){this.currentT=Math.max(0,Math.min(e,this.seekableDuration)),this.resolveFrame(this.currentT)}get playbackState(){return this.state}get time(){return this.currentT}resolveFrame(e){const t=new Map;for(const n of this.timeline.sourceIds){const s=this.timeline.getInterpolatedShapeAt(e,n);s&&t.set(n,s)}this.onFrame(e,t)}}const Sd=["nw","n","ne","e","se","s","sw","w"],Lf=24,xr=8,Nf=3,Uf=8;function Mr(i,e,t){const n=i.x-e.x,s=i.y-e.y,r=Math.cos(t),a=Math.sin(t);return{x:e.x+n*r-s*a,y:e.y+n*a+s*r}}function Bs(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const Ff={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 en{static handlePointsFor(e){const{x:t,y:n,width:s,height:r}=e.bounds,a={nw:{x:t,y:n},n:{x:t+s/2,y:n},ne:{x:t+s,y:n},e:{x:t+s,y:n+r/2},se:{x:t+s,y:n+r},s:{x:t+s/2,y:n+r},sw:{x:t,y:n+r},w:{x:t,y:n+r/2},rotate:{x:t+s/2,y:n-Lf}},o=Bs(e.bounds),l={};for(const c of Object.keys(a))l[c]=Mr(a[c],o,e.angle);return l}static hitTestHandle(e,t,n=8,s=[...Sd,"rotate"]){const r=en.handlePointsFor(e);for(const a of s)if(Math.hypot(t.x-r[a].x,t.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(e,t){const s=((en.HANDLE_DIRECTION_DEG[e]+t*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(e,t,n,s){const r=Bs(e),a=Mr(s,r,-t),{x:o,y:l,width:c,height:h}=e,u=Ff[n];let d=o,p=l,g=o+c,x=l+h;return u.left&&(d=Math.min(a.x,g-xr)),u.right&&(g=Math.max(a.x,d+xr)),u.top&&(p=Math.min(a.y,x-xr)),u.bottom&&(x=Math.max(a.y,p+xr)),{x:d,y:p,width:g-d,height:x-p}}static resizeShape(e,t,n){if(t==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=e.bounds,a=en.resizeBounds(e.bounds,e.angle,t,n);if(e.kind==="oval")return{...e,bounds:a};const o=s===0?1:a.width/s,l=r===0?1:a.height/r;return{...e,bounds:a,points:e.points.map(c=>({x:c.x*o,y:c.y*l}))}}static rotateShape(e,t){const n=Bs(e.bounds),s=Math.atan2(t.y-n.y,t.x-n.x)+Math.PI/2;return{...e,angle:s}}static groupBoundsFor(e){const t=Math.min(...e.map(a=>a.x)),n=Math.min(...e.map(a=>a.y)),s=Math.max(...e.map(a=>a.x+a.width)),r=Math.max(...e.map(a=>a.y+a.height));return{x:t,y:n,width:s-t,height:r-n}}static vertexPointsFor(e){const t=Bs(e.bounds);return e.points.map(n=>Mr({x:e.bounds.x+n.x,y:e.bounds.y+n.y},t,e.angle))}static hitTestVertex(e,t,n=Uf){const s=en.vertexPointsFor(e);let r,a=n;return s.forEach((o,l)=>{const c=Math.hypot(t.x-o.x,t.y-o.y);c<=a&&(a=c,r=l)}),r}static toLocalPoint(e,t){const n=Bs(e.bounds),s=Mr(t,n,-e.angle);return{x:s.x-e.bounds.x,y:s.y-e.bounds.y}}static moveVertex(e,t,n){const s=e.points.map((u,d)=>d===t?en.toLocalPoint(e,n):u),r=Math.min(...s.map(u=>u.x)),a=Math.min(...s.map(u=>u.y)),o=Math.max(...s.map(u=>u.x)),l=Math.max(...s.map(u=>u.y)),c={x:e.bounds.x+r,y:e.bounds.y+a,width:o-r,height:l-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...e,bounds:c,points:h}}static insertVertexNear(e,t){const n=en.toLocalPoint(e,t),{points:s}=e;let r=s.length-1,a=1/0;for(let l=0;l<s.length;l++){const c=s[l],h=s[(l+1)%s.length],u=en.distanceToSegment(n,c,h);u<a&&(a=u,r=l)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...e,points:o}}static distanceToSegment(e,t,n){const s=n.x-t.x,r=n.y-t.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((e.x-t.x)*s+(e.y-t.y)*r)/a)),l=t.x+o*s,c=t.y+o*r;return Math.hypot(e.x-l,e.y-c)}static deleteVertex(e,t){return e.points.length<=Nf?e:{...e,points:e.points.filter((n,s)=>s!==t)}}}const il=6,yr=il/2,Of=20,uh=4;class zf{constructor(e){this.ctx=e}clear(e,t){this.ctx.clearRect(0,0,e,t)}paintShape(e){this.ctx.save(),this.ctx.globalAlpha=1-e.transparency,e.haloScale>0&&this.paintHalo(e),this.paintBase(e),this.ctx.restore(),e.selected&&this.paintSelectionHandles(e)}paintBase(e){if(this.ctx.fillStyle=e.color,this.ctx.beginPath(),e.kind==="oval"){const{x:t,y:n,width:s,height:r}=e.bounds,a=s/2,o=r/2;this.ctx.ellipse(t+a,n+o,a,o,e.angle,0,2*Math.PI)}else{const{x:t,y:n,width:s,height:r}=e.bounds;this.ctx.save(),this.ctx.translate(t+s/2,n+r/2),this.ctx.rotate(e.angle),this.ctx.translate(-s/2,-r/2),e.points.forEach((a,o)=>{o===0?this.ctx.moveTo(a.x,a.y):this.ctx.lineTo(a.x,a.y)}),this.ctx.closePath(),this.ctx.restore()}this.ctx.fill()}paintHalo(e){this.ctx.save(),this.ctx.shadowColor=e.color,this.ctx.shadowBlur=Of*e.haloScale,this.paintBase(e),this.ctx.restore()}paintSelectionHandles(e){this.paintHandleFrame(en.handlePointsFor(e),{includeRotate:!0}),e.kind==="polygon"&&this.paintVertexHandles(e)}paintVertexHandles(e){this.ctx.fillStyle="#39f";for(const t of en.vertexPointsFor(e))this.ctx.beginPath(),this.ctx.ellipse(t.x,t.y,uh,uh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(e){this.paintOutline(en.handlePointsFor(e))}paintGroupHandles(e){this.paintHandleFrame(en.handlePointsFor({bounds:e,angle:0}),{includeRotate:!0})}paintOutline(e){this.ctx.strokeStyle="lightgray",this.ctx.beginPath(),this.ctx.moveTo(e.nw.x,e.nw.y),this.ctx.lineTo(e.ne.x,e.ne.y),this.ctx.lineTo(e.se.x,e.se.y),this.ctx.lineTo(e.sw.x,e.sw.y),this.ctx.closePath(),this.ctx.stroke()}paintHandleFrame(e,{includeRotate:t}){this.paintOutline(e),this.ctx.fillStyle="lightgray";for(const n of Sd){const s=e[n];this.ctx.fillRect(s.x-yr,s.y-yr,il,il)}t&&(this.ctx.beginPath(),this.ctx.moveTo(e.n.x,e.n.y),this.ctx.lineTo(e.rotate.x,e.rotate.y),this.ctx.stroke(),this.ctx.beginPath(),this.ctx.ellipse(e.rotate.x,e.rotate.y,yr+1,yr+1,0,0,2*Math.PI),this.ctx.fill())}}const dh=.05,fh=.08,ph=2,mh=3,Bf=14,kf=.02;class Gf{context;voice;voiceToken=0;buffers=new Map;noiseBuffer;crackleBuffer;requested;resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("SightingAudio: Web Audio unavailable, the sighting stays silent:",e);return}}this.context.state==="suspended"&&this.context.resume()}setSound(e){if(this.requested=e,!this.context)return;const t=this.keyFor(e);if(!t){this.silence();return}if(this.voice?.key!==t){this.stopVoice();const n=++this.voiceToken;t.startsWith("src:")?this.buildRecordedVoice(e.src,t,n):this.voice=this.buildSynthesizedVoice(e,t)}this.applyTo(this.voice,e)}silence(){this.voiceToken++,this.stopVoice()}dispose(){this.silence(),this.context?.close(),this.context=void 0,this.buffers.clear(),this.noiseBuffer=void 0,this.crackleBuffer=void 0}keyFor(e){if(!(e.volume<=0))return e.src?`src:${e.src}`:e.kind==="none"?void 0:e.kind}applyTo(e,t){const n=this.context;if(!e||!n)return;const s=n.currentTime;e.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,t.volume))*e.gainScale,s,dh);for(const{param:r,ratio:a}of e.pitch)r.setTargetAtTime(Math.min(t.pitchHz*a,n.sampleRate/2-1),s,dh)}buildSynthesizedVoice(e,t){const n=this.context;if(n)switch(e.kind){case"hum":return this.buildHum(n,t);case"whistle":return this.buildWhistle(n,t);case"rumble":return this.buildRumble(n,t);case"crackle":return this.buildCrackle(n,t);default:return}}buildHum(e,t){const n=e.createOscillator();n.type="sawtooth";const s=e.createOscillator();s.type="sawtooth";const r=e.createBiquadFilter();r.type="lowpass",r.Q.value=1;const a=e.createGain();return a.gain.value=0,n.connect(r),s.connect(r),r.connect(a).connect(e.destination),n.start(),s.start(),{key:t,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:s.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(e,t){const n=e.createOscillator();n.type="sine";const s=e.createOscillator();s.type="sine",s.frequency.value=5;const r=e.createGain(),a=e.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(e.destination),n.start(),s.start(),{key:t,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.22,pitch:[{param:n.frequency,ratio:1},{param:r.gain,ratio:.012}]}}buildRumble(e,t){const n=e.createBufferSource();n.buffer=this.brownNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=e.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(e.destination),n.start(),{key:t,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(e,t){const n=e.createBufferSource();n.buffer=this.whiteNoise(e),n.loop=!0;const s=e.createBiquadFilter();s.type="bandpass",s.Q.value=1.2;const r=e.createGain();r.gain.value=0;const a=e.createBufferSource();a.buffer=this.crackleEnvelope(e),a.loop=!0;const o=e.createGain();return o.gain.value=0,a.connect(o).connect(r.gain),n.connect(s).connect(r).connect(e.destination),n.start(),a.start(),{key:t,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(e,t,n){const s=this.context;if(!s)return;let r;try{r=await this.getBuffer(e)}catch(l){console.warn("SightingAudio: the recorded sound failed to load, staying silent:",l);return}if(n!==this.voiceToken||!this.context)return;const a=s.createBufferSource();a.buffer=r,a.loop=!0;const o=s.createGain();o.gain.value=0,a.connect(o).connect(s.destination),a.start(),this.voice={key:t,nodes:[o],sources:[a],volumeParam:o.gain,gainScale:1,pitch:[]},this.requested&&this.applyTo(this.voice,this.requested)}async getBuffer(e){const t=this.context;if(!t)throw new Error("SightingAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}whiteNoise(e){if(!this.noiseBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*ph),e.sampleRate),n=t.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=t}return this.noiseBuffer}brownNoise(e){const t=e.createBuffer(1,Math.floor(e.sampleRate*ph),e.sampleRate),n=t.getChannelData(0);let s=0,r=0;for(let a=0;a<n.length;a++)s=(s+.02*(Math.random()*2-1))/1.02,n[a]=s,r=Math.max(r,Math.abs(s));if(r>0)for(let a=0;a<n.length;a++)n[a]/=r;return t}crackleEnvelope(e){if(!this.crackleBuffer){const t=e.createBuffer(1,Math.floor(e.sampleRate*mh),e.sampleRate),n=t.getChannelData(0),s=Math.max(1,Math.floor(kf*e.sampleRate)),r=Math.round(mh*Bf);for(let a=0;a<r;a++){const o=Math.floor(Math.random()*n.length),l=.4+Math.random()*.6;for(let c=0;c<s&&o+c<n.length;c++)n[o+c]=Math.max(n[o+c],l*(1-c/s))}this.crackleBuffer=t}return this.crackleBuffer}stopVoice(){const e=this.voice,t=this.context;if(this.voice=void 0,!e||!t)return;const n=t.currentTime;e.volumeParam.cancelScheduledValues(n),e.volumeParam.setTargetAtTime(0,n,fh/3);const s=n+fh;for(const r of e.sources){r.onended=()=>{r.disconnect();for(const a of e.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of e.nodes)a.disconnect()}}}}const Qa=Math.PI/180,Sr=180/Math.PI;class Es{constructor(e,t,n){this.kind=e,this.canvasHeightPx=t,this.fovDeg=n;const s=n*Qa/2;this.focalPx=e==="equidistant"?t/2/s:t/2/Math.tan(s)}focalPx;static of(e,t,n){return new Es(e.projection,t,n)}degToPx(e){const t=e*Qa;return this.kind==="equidistant"?this.focalPx*t:2*this.focalPx*Math.tan(t/2)}pxToDeg(e){return this.kind==="equidistant"?e/this.focalPx*Sr:2*Math.atan(e/(2*this.focalPx))*Sr}angleDegToRadiusPx(e){const t=e*Qa;return this.kind==="equidistant"?this.focalPx*t:this.focalPx*Math.tan(t)}radiusPxToAngleDeg(e){return this.kind==="equidistant"?e/this.focalPx*Sr:Math.atan(e/this.focalPx)*Sr}ofBounds(e){return{widthDeg:this.pxToDeg(e.width),heightDeg:this.pxToDeg(e.height)}}toBoundsSize(e){return{width:this.degToPx(e.widthDeg),height:this.degToPx(e.heightDeg)}}widthPx(e){return this.degToPx(Zt.angularWidthDeg(e))}}class bc{static DEFAULT_FOV_DEG=60;static toAngular(e){this.eachKeyframe(e,(t,n)=>({...t,angular:n.ofBounds(t.bounds)}))}static toBounds(e){this.eachKeyframe(e,(t,n)=>{if(!t.angular)return t;const{width:s,height:r}=n.toBoundsSize(t.angular),a={x:t.bounds.x+(t.bounds.width-s)/2,y:t.bounds.y+(t.bounds.height-r)/2,width:s,height:r};if(t.kind!=="polygon")return{...t,bounds:a};const o=t.bounds.width===0?1:s/t.bounds.width,l=t.bounds.height===0?1:r/t.bounds.height;return{...t,bounds:a,points:t.points.map(c=>({x:c.x*o,y:c.y*l}))}})}static reproject(e,t){const n=Zt.CANVAS_WIDTH_PX/2,s=Zt.CANVAS_HEIGHT_PX/2;for(const r of[...e.timeline.allKeyframes]){const a=rr(e,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=Es.of(t,Zt.CANVAS_HEIGHT_PX,a),l=Es.of(e.instrument,Zt.CANVAS_HEIGHT_PX,a);e.timeline.addKeyframe(r.t,r.shapes.map(c=>{const{bounds:h}=c.shape,u=h.x+h.width/2-n,d=h.y+h.height/2-s,p=Math.hypot(u,d);if(p===0)return c;const g=l.angleDegToRadiusPx(o.radiusPxToAngleDeg(p))/p,x={...h,x:n+u*g-h.width/2,y:s+d*g-h.height/2};return{...c,shape:{...c.shape,bounds:x}}}))}this.toBounds(e)}static eachKeyframe(e,t){const{timeline:n}=e;for(const s of[...n.allKeyframes]){const r=rr(e,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=Es.of(e.instrument,Zt.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:t(o.shape,a)})))}}}function Hf(i){return bc.toAngular(i),{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,utcOffsetHours:i.event.utcOffsetHours,timeZone:i.event.timeZone,place:i.event.place,witness:i.witness,caseId:i.caseId,description:i.event.description,tags:i.event.tags,timeline:i.timeline.toJSON(),witnessTrack:i.witnessTrack.toJSON(),weatherTrack:i.weatherTrack.toJSON(),soundTrack:i.soundTrack.toJSON(),weather:i.weather,decor:i.decor,weatherSource:i.weatherSource,instrument:i.instrumentId}}function Vf(i){const e=new Ba({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,utcOffsetHours:i.utcOffsetHours,timeZone:i.timeZone,place:i.place,description:i.description,tags:i.tags},za.fromJSON(i.timeline),i.witnessTrack?or.fromJSON(i.witnessTrack):new or,i.weatherTrack?lr.fromJSON(i.weatherTrack):new lr,i.soundTrack?cr.fromJSON(i.soundTrack):new cr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return bc.toBounds(e),e}function ka(i,e){for(const t of i){const n=t.toLowerCase().split("-")[0];if(e.includes(n))return n}return"en"}const Wf="modulepreload",Xf=function(i,e){return new URL(i,e).href},gh={},Ea=function(e,t,n){let s=Promise.resolve();if(t&&t.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"),l=document.querySelector("meta[property=csp-nonce]"),c=l?.nonce||l?.getAttribute("nonce");s=a(t.map(h=>{if(h=Xf(h,n),h in gh)return;gh[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let x=o.length-1;x>=0;x--){const m=o[x];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":Wf,u||(g.as="script"),g.crossOrigin="",g.href=h,c&&g.setAttribute("nonce",c),document.head.appendChild(g),u)return new Promise((x,m)=>{g.addEventListener("load",x),g.addEventListener("error",()=>m(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 s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Ed=["en","fr"],qf={en:()=>Ea(()=>Promise.resolve().then(()=>$f),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Ea(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function Yf(i){return qf[i]()}const Kf={en:()=>Ea(()=>Promise.resolve().then(()=>ey),void 0,import.meta.url).then(i=>i.eyewitnessMessages_en),fr:()=>Ea(()=>import("./EyewitnessMessages_fr-CzOAdmOE.js"),[],import.meta.url).then(i=>i.eyewitnessMessages_fr)};function Zf(i){return Kf[i]()}const bd={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"},$f=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:bd},Symbol.toStringTag,{value:"Module"})),vh=new Set;class Jf extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Ba.create();sightingAudio=new Gf;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=vh;enableClickToPlay=!0;fullscreenTarget;messages=bd;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=e=>{const t=this.canvasPointFromEvent(e),n=t&&this.currentSighting.timeline.hitTest(this.currentTime,t.x,t.y,this.occludedSourceIds);if(!n?.shape.title){this.tooltip.hidden=!0;return}this.tooltip.textContent=n.shape.title,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${e.clientX-s.left+12}px`,this.tooltip.style.top=`${e.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${uf}</style>${hf}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new zf(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.seekInput=this.shadow.getElementById("seek"),this.timeStartLabel=this.shadow.getElementById("time-start"),this.timeEndLabel=this.shadow.getElementById("time-end");for(const t of[this.timeStartLabel,this.timeEndLabel])t.addEventListener("click",()=>this.toggleTimeDisplay()),t.addEventListener("keydown",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.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(e){const t=await fetch(e);this.sightingData=await t.json()}get sightingData(){return Hf(this.currentSighting)}set sightingData(e){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=Vf(e),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}get sighting(){return this.currentSighting}previewSound(e){this.soundPreview=e,this.sightingAudio.resume(),this.sightingAudio.setSound(e)}stopSoundPreview(){this.soundPreview=void 0,this.sightingAudio.silence()}get canvasElement(){return this.canvas}get renderer(){return this.canvasRenderer}get currentTime(){return this.player.time}set currentTime(e){this.player.seek(e)}get seekableDuration(){return this.player.seekableDuration}get autoReplayEnabled(){return this.loopEnabled}get positionLabel(){return this.timeStartLabel.textContent??""}get durationLabel(){return this.timeEndLabel.textContent??""}get showingClockTime(){return this.canShowClockTime}get canSwitchTimeDisplay(){return this.realStartMs!==void 0}toggleTimeDisplay(){this.canSwitchTimeDisplay&&(this.showClockTime=!this.showClockTime,this.updateTimeLabels(),this.updateTimeLabelTitles(),this.dispatchEvent(new CustomEvent("timedisplaychange",{bubbles:!0,composed:!0})))}get canShowClockTime(){return this.realStartMs!==void 0&&this.showClockTime}set showToolbar(e){this.toolbar.classList.toggle("hidden",!e)}get playbackState(){return this.player.playbackState}get selectedSourceIds(){return this.highlightedSourceIds}get durationSeconds(){return this.currentSighting.event.durationSeconds}set durationSeconds(e){this.currentSighting.event.durationSeconds=e,this.updateTimeLabels(),this.refresh(),this.updatePlayPauseButton()}set selectedSourceIds(e){const t=new Set(e);t.size===this.highlightedSourceIds.size&&[...t].every(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=t,this.refresh())}setOccludedSourceIds(e){e.size===this.occludedSourceIds.size&&[...e].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=e,this.refresh())}hasVisibleShapeAt(e,t){return this.currentSighting.timeline.hitTest(this.currentTime,e,t,this.occludedSourceIds)!==void 0}refresh(){this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}canvasPointFromEvent(e){const t=this.canvas.getBoundingClientRect();if(!(t.width===0||t.height===0))return{x:(e.clientX-t.left)/t.width*this.canvas.width,y:(e.clientY-t.top)/t.height*this.canvas.height}}onFrame(e,t){this.canvasRenderer.clear(this.canvas.width,this.canvas.height);const n=this.playbackState!=="playing"?this.highlightedSourceIds:vh;for(const[s,r]of t){if(this.occludedSourceIds.has(s))continue;const a=n.has(s);a&&n.size===1?this.canvasRenderer.paintShape({...r,selected:!0}):(this.canvasRenderer.paintShape(r),a&&this.canvasRenderer.paintMemberOutline(r))}if(n.size>1){const s=en.groupBoundsFor([...t].filter(([r])=>n.has(r)).map(([,r])=>r.bounds));this.canvasRenderer.paintGroupHandles(s)}this.seekInput.value=String(e),this.timeStartLabel.textContent=this.formatPosition(e),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Pf(this.currentSighting,e))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:e}}))}createPlayer(){const e=new If(this.currentSighting.timeline,(t,n)=>this.onFrame(t,n));return e.loop=this.loopEnabled,e}togglePlayPause(){this.player.seekableDuration<=0||(this.player.playbackState==="playing"?(this.player.pause(),this.soundPreview=void 0,this.sightingAudio.silence(),this.refresh()):(this.sightingAudio.resume(),this.player.play()),this.updatePlayPauseButton())}updatePlayPauseButton(){const e=this.player.playbackState==="playing";this.playPauseButton.textContent=e?"⏸":"▶";const t=this.player.seekableDuration>0;this.playPauseButton.disabled=!t;const n=t?e?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",e),this.fullscreenButton.classList.toggle("auto-hide",e)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(e=>{console.error("<rr0-ufo>: requestFullscreen() failed —",e)})}updateFullscreenButton(){const e=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=e?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const e=ka(navigator.languages,Ed);e!=="en"&&this.applyMessages(await Yf(e))}updateTimeLabelTitles(){const e=this.showClockTime?this.messages.switchToElapsed:this.messages.switchToClockTime,t=this.canSwitchTimeDisplay?` — ${e}`:"";this.timeStartLabel.title=this.messages.currentPosition+t,this.timeEndLabel.title=this.messages.duration+t;for(const 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(e){this.messages=e,this.updateTimeLabelTitles(),this.loopButton.title=e.autoReplay,this.loopButton.setAttribute("aria-label",e.autoReplay),this.updatePlayPauseButton(),this.updateFullscreenButton()}updateTimeLabels(){const e=this.currentSighting.event,t=Tf(e);this.realDurationMs=t!==void 0&&t>0?t:void 0,this.realStartMs=e.time?nl(e.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(e){if(this.realDurationMs===void 0)return Er(e);const t=this.currentSighting.timeline.duration,n=t>0&&e<=t?e/t*this.realDurationMs:e;return this.canShowClockTime?xh(_h(this.realStartMs+n)):Er(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Er(this.currentSighting.timeline.duration):this.canShowClockTime?xh(_h(this.realStartMs+this.realDurationMs)):Er(this.realDurationMs)}}function _h(i){const e=new Date(i);return{hour:e.getUTCHours(),minute:e.getUTCMinutes(),second:e.getUTCSeconds()}}function xh(i){if(i.hour===void 0)return"0:00";const e=t=>String(t).padStart(2,"0");return i.second?`${e(i.hour)}:${e(i.minute??0)}:${e(i.second)}`:`${e(i.hour)}:${e(i.minute??0)}`}function Er(i){const e=Math.round(i/1e3),t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,"0")}`}const sl="rr0-ufo";function wd(){customElements.get(sl)||customElements.define(sl,Jf)}/**
|
|
563
|
+
`;class tn{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/tn.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 Cf(i,t,e){const{bounds:n}=i;return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function gn(i,t,e){return i+(t-i)*e}function Mh(i){const t=/^#([0-9a-f]{6})$/i.exec(i);if(!t)return;const e=parseInt(t[1],16);return[e>>16&255,e>>8&255,e&255]}function Df(i){return`#${i.map(t=>Math.round(t).toString(16).padStart(2,"0")).join("")}`}function Pf(i,t,e){const n=Mh(i),s=Mh(t);return!n||!s?e<1?i:t:Df([gn(n[0],s[0],e),gn(n[1],s[1],e),gn(n[2],s[2],e)])}function If(i,t,e){const n={x:gn(i.bounds.x,t.bounds.x,e),y:gn(i.bounds.y,t.bounds.y,e),width:gn(i.bounds.width,t.bounds.width,e),height:gn(i.bounds.height,t.bounds.height,e)},s=gn(i.angle,t.angle,e),r=gn(i.transparency,t.transparency,e),a=gn(i.haloScale,t.haloScale,e),o=Pf(i.color,t.color,e),c=tn.lerpAngular(i.angular,t.angular,e);return i.kind==="polygon"&&t.kind==="polygon"&&i.points.length===t.points.length?{...i,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c,behindCloud:e<1?i.behindCloud:t.behindCloud,points:i.points.map((l,h)=>({x:gn(l.x,t.points[h].x,e),y:gn(l.y,t.points[h].y,e)}))}:{...e<1?i:t,bounds:n,angle:s,transparency:r,haloScale:a,color:o,angular:c}}class Ja{keyframes=[];order=[];groups=[];addKeyframe(t,e){const n=this.findInsertIndex(t);if(this.keyframes[n]?.t===t){const s=new Set(e.map(r=>r.sourceId));this.keyframes[n]={t,shapes:[...this.keyframes[n].shapes.filter(r=>!s.has(r.sourceId)),...e]}}else this.keyframes.splice(n,0,{t,shapes:[...e]});for(const s of e)this.order.includes(s.sourceId)||this.order.push(s.sourceId)}findInsertIndex(t){let e=0,n=this.keyframes.length;for(;e<n;){const s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}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 s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return s.shape}}getInterpolatedShapeAt(t,e){const n=this.findShapeAtOrBefore(t,e);if(n?.t===t)return n.shape;const s=this.findShapeAtOrAfter(t,e);return n?s?If(n.shape,s.shape,(t-n.t)/(s.t-n.t)):n.shape:s?.shape}findShapeAtOrBefore(t,e){let n=this.findInsertIndex(t);for(this.keyframes[n]?.t!==t&&(n-=1);n>=0;n--){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}findShapeAtOrAfter(t,e){for(let n=this.findInsertIndex(t);n<this.keyframes.length;n++){const s=this.keyframes[n].shapes.find(r=>r.sourceId===e);if(s)return{t:this.keyframes[n].t,shape:s.shape}}}hitTest(t,e,n,s){const r=this.sourceIds;for(let a=r.length-1;a>=0;a--){if(s?.has(r[a]))continue;const o=this.getInterpolatedShapeAt(t,r[a]);if(o&&Cf(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(s=>s.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(s=>s.includes(t));if(e===-1)return;const n=this.groups[e].filter(s=>s!==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 Ja;for(const n of t.keyframes)e.addKeyframe(n.t,n.shapes);if(t.order){const n=e.order.filter(s=>!t.order.includes(s));e.order=[...t.order,...n]}return t.groups&&(e.groups=t.groups.map(n=>n.filter(s=>e.order.includes(s))).filter(n=>n.length>=2)),e}}function Lf(i,t,e){return Math.max(t,Math.min(e,i))}function Nf(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Ks(i,t,e){return i+(t-i)*e}function Uf(i,t,e){return{lat:i.lat===void 0||t.lat===void 0?void 0:Ks(i.lat,t.lat,e),lng:i.lng===void 0||t.lng===void 0?void 0:Ks(i.lng,t.lng,e),elevationM:Ks(i.elevationM,t.elevationM,e),headingDeg:i.headingDeg===void 0||t.headingDeg===void 0?void 0:Nf(i.headingDeg,t.headingDeg,e),pitchDeg:Ks(i.pitchDeg,t.pitchDeg,e),fovDeg:Ks(i.fovDeg,t.fovDeg,e)}}class _r{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 s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}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 s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?Uf(n.pose,s.pose,Lf((t-n.t)/(s.t-n.t),0,1)):n.pose:s?.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 _r;for(const n of t.keyframes)e.addKeyframe(n.t,n.pose);return e}}function ui(i,t,e){return i+(t-i)*e}function Ff(i,t,e){const n=((t-i)%360+540)%360-180;return((i+n*e)%360+360)%360}function Of(i,t,e){return Math.max(t,Math.min(e,i))}function zf(i,t,e){return{cloudCover:ui(i.cloudCover,t.cloudCover,e),cloudDarkness:ui(i.cloudDarkness,t.cloudDarkness,e),highCloudCover:i.highCloudCover===void 0||t.highCloudCover===void 0?void 0:ui(i.highCloudCover,t.highCloudCover,e),iceCrystalAlignment:i.iceCrystalAlignment===void 0||t.iceCrystalAlignment===void 0?void 0:ui(i.iceCrystalAlignment,t.iceCrystalAlignment,e),lowerCloudCover:i.lowerCloudCover===void 0||t.lowerCloudCover===void 0?void 0:ui(i.lowerCloudCover,t.lowerCloudCover,e),cloudBaseM:i.cloudBaseM===void 0||t.cloudBaseM===void 0?void 0:ui(i.cloudBaseM,t.cloudBaseM,e),precipitationType:e<1?i.precipitationType:t.precipitationType,precipitationIntensity:ui(i.precipitationIntensity,t.precipitationIntensity,e),windDirectionDeg:Ff(i.windDirectionDeg,t.windDirectionDeg,e),windSpeed:ui(i.windSpeed,t.windSpeed,e),storm:e<1?i.storm:t.storm}}class xr{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 s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}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 s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];return n?s?zf(n.weather,s.weather,Of((t-n.t)/(s.t-n.t),0,1)):n.weather:s?.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 xr;for(const n of t.keyframes)e.addKeyframe(n.t,n.weather);return e}}class Mr{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 s=this.keyframes[e]?.t===t?void 0:this.keyframes[e];if(!n)return s?.sound;if(!s)return n.sound;const r=(t-n.t)/(s.t-n.t);return this.lerp(n.sound,s.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 Mr;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 s=e+n>>>1;this.keyframes[s].t<t?e=s+1:n=s}return e}}const Fd=1e3,Bf=.65,Od={cloudCover:0,cloudDarkness:0,precipitationType:"none",precipitationIntensity:0,windDirectionDeg:0,windSpeed:0,storm:!1},kf=100,Gf={kind:"none",volume:0,pitchHz:kf},yh=[{id:"eye",name:"Naked eye",projection:"equidistant"},{id:"rectilinear-lens",name:"Camera, rectilinear lens",projection:"rectilinear",apertureBlades:6}];class zd{static get default(){return yh[0]}static byId(t){return yh.find(e=>e.id===t)??this.default}static starPointsOf(t){const e=t.apertureBlades;return e===void 0||e<3?0:e%2===0?e:e*2}}function mc(i){if(i.year!==void 0)return Date.UTC(i.year,(i.month??1)-1,i.day??1,i.hour??0,i.minute??0,i.second??0)}function Sh(i){return(((i.day??0)*24+(i.hour??0))*60+(i.minute??0))*6e4+(i.second??0)*1e3}const Hf=["year","month","day","hour","minute"],Vf=["day","hour","minute"];function Eh(i,t){return t.filter(e=>i[e]!==void 0).join(",")}function Wf(i){if(i.durationSeconds!==void 0)return i.durationSeconds*1e3;if(!i.time||!i.endTime)return;const t=i.time.year!==void 0&&i.endTime.year!==void 0,e=t?Hf:Vf,n=Eh(i.time,e);if(!(n===""||n!==Eh(i.endTime,e)))return t?mc(i.endTime)-mc(i.time):Sh(i.endTime)-Sh(i.time)}class Qa{constructor(t,e,n,s,r,a,o,c,l=[],h,u){this.event=t,this.timeline=e,this.witnessTrack=n,this.weatherTrack=s,this.soundTrack=r,this.witness=a,this.caseId=o,this.weather=c,this.decor=l,this.weatherSource=h,this.instrumentId=u}get instrument(){return zd.byId(this.instrumentId)}static create(t,e,n){return new Qa({eventType:"sighting",time:t,place:e},new Ja,new _r,new xr,new Mr,n)}}const Xf=0,qf=0,Yf=60;function mr(i,t){const e=i.witnessTrack.getInterpolatedPoseAt(t);if(e)return e;const n=i.event.place?.[0];if(n)return{lat:n.lat,lng:n.lng,elevationM:Xf,headingDeg:void 0,pitchDeg:qf,fovDeg:Yf}}function bh(i,t){return i.weatherTrack.getInterpolatedWeatherAt(t)??i.weather??Od}function Kf(i,t){return i.soundTrack.getInterpolatedSoundAt(t)??Gf}class Zf{constructor(t,e){this.timeline=t,this.onFrame=e}rafId=null;state="stopped";currentT=0;lastWallTime=0;playbackRate=1;loop=!1;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);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 s=this.timeline.getInterpolatedShapeAt(t,n);s&&e.set(n,s)}this.onFrame(t,e)}}const Bd=["nw","n","ne","e","se","s","sw","w"],$f=24,Pr=8,Jf=3,Qf=8;function Ir(i,t,e){const n=i.x-t.x,s=i.y-t.y,r=Math.cos(e),a=Math.sin(e);return{x:t.x+n*r-s*a,y:t.y+n*a+s*r}}function Zs(i){return{x:i.x+i.width/2,y:i.y+i.height/2}}const jf={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 on{static handlePointsFor(t){const{x:e,y:n,width:s,height:r}=t.bounds,a={nw:{x:e,y:n},n:{x:e+s/2,y:n},ne:{x:e+s,y:n},e:{x:e+s,y:n+r/2},se:{x:e+s,y:n+r},s:{x:e+s/2,y:n+r},sw:{x:e,y:n+r},w:{x:e,y:n+r/2},rotate:{x:e+s/2,y:n-$f}},o=Zs(t.bounds),c={};for(const l of Object.keys(a))c[l]=Ir(a[l],o,t.angle);return c}static hitTestHandle(t,e,n=8,s=[...Bd,"rotate"]){const r=on.handlePointsFor(t);for(const a of s)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 s=((on.HANDLE_DIRECTION_DEG[t]+e*180/Math.PI)%180+180)%180/45,r=["ew","nwse","ns","nesw"];return r[Math.round(s)%r.length]}static resizeBounds(t,e,n,s){const r=Zs(t),a=Ir(s,r,-e),{x:o,y:c,width:l,height:h}=t,u=jf[n];let d=o,f=c,g=o+l,x=c+h;return u.left&&(d=Math.min(a.x,g-Pr)),u.right&&(g=Math.max(a.x,d+Pr)),u.top&&(f=Math.min(a.y,x-Pr)),u.bottom&&(x=Math.max(a.y,f+Pr)),{x:d,y:f,width:g-d,height:x-f}}static resizeShape(t,e,n){if(e==="rotate")throw new Error("resizeShape does not accept the rotate handle");const{width:s,height:r}=t.bounds,a=on.resizeBounds(t.bounds,t.angle,e,n);if(t.kind==="oval")return{...t,bounds:a};const o=s===0?1:a.width/s,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=Zs(t.bounds),s=Math.atan2(e.y-n.y,e.x-n.x)+Math.PI/2;return{...t,angle:s}}static groupBoundsFor(t){const e=Math.min(...t.map(a=>a.x)),n=Math.min(...t.map(a=>a.y)),s=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:s-e,height:r-n}}static vertexPointsFor(t){const e=Zs(t.bounds);return t.points.map(n=>Ir({x:t.bounds.x+n.x,y:t.bounds.y+n.y},e,t.angle))}static hitTestVertex(t,e,n=Qf){const s=on.vertexPointsFor(t);let r,a=n;return s.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=Zs(t.bounds),s=Ir(e,n,-t.angle);return{x:s.x-t.bounds.x,y:s.y-t.bounds.y}}static moveVertex(t,e,n){const s=t.points.map((u,d)=>d===e?on.toLocalPoint(t,n):u),r=Math.min(...s.map(u=>u.x)),a=Math.min(...s.map(u=>u.y)),o=Math.max(...s.map(u=>u.x)),c=Math.max(...s.map(u=>u.y)),l={x:t.bounds.x+r,y:t.bounds.y+a,width:o-r,height:c-a},h=s.map(u=>({x:u.x-r,y:u.y-a}));return{...t,bounds:l,points:h}}static insertVertexNear(t,e){const n=on.toLocalPoint(t,e),{points:s}=t;let r=s.length-1,a=1/0;for(let c=0;c<s.length;c++){const l=s[c],h=s[(c+1)%s.length],u=on.distanceToSegment(n,l,h);u<a&&(a=u,r=c)}const o=[...s.slice(0,r+1),n,...s.slice(r+1)];return{...t,points:o}}static distanceToSegment(t,e,n){const s=n.x-e.x,r=n.y-e.y,a=s*s+r*r,o=a===0?0:Math.max(0,Math.min(1,((t.x-e.x)*s+(t.y-e.y)*r)/a)),c=e.x+o*s,l=e.y+o*r;return Math.hypot(t.x-c,t.y-l)}static deleteVertex(t,e){return t.points.length<=Jf?t:{...t,points:t.points.filter((n,s)=>s!==e)}}}const gc=6,Lr=gc/2,tp=20,wh=4;class ep{constructor(t){this.ctx=t}clear(t,e){this.ctx.clearRect(0,0,t,e)}paintShape(t){this.ctx.save(),this.ctx.globalAlpha=1-t.transparency,t.haloScale>0&&this.paintHalo(t),this.paintBase(t),this.ctx.restore(),t.selected&&this.paintSelectionHandles(t)}paintBase(t){if(this.ctx.fillStyle=t.color,this.ctx.beginPath(),t.kind==="oval"){const{x:e,y:n,width:s,height:r}=t.bounds,a=s/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:s,height:r}=t.bounds;this.ctx.save(),this.ctx.translate(e+s/2,n+r/2),this.ctx.rotate(t.angle),this.ctx.translate(-s/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=tp*t.haloScale,this.paintBase(t),this.ctx.restore()}paintSelectionHandles(t){this.paintHandleFrame(on.handlePointsFor(t),{includeRotate:!0}),t.kind==="polygon"&&this.paintVertexHandles(t)}paintVertexHandles(t){this.ctx.fillStyle="#39f";for(const e of on.vertexPointsFor(t))this.ctx.beginPath(),this.ctx.ellipse(e.x,e.y,wh,wh,0,0,2*Math.PI),this.ctx.fill()}paintMemberOutline(t){this.paintOutline(on.handlePointsFor(t))}paintGroupHandles(t){this.paintHandleFrame(on.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 Bd){const s=t[n];this.ctx.fillRect(s.x-Lr,s.y-Lr,gc,gc)}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,Lr+1,Lr+1,0,0,2*Math.PI),this.ctx.fill())}}const Ah=.05,Th=.08,Rh=2,Ch=3,np=14,ip=.02;class sp{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 s=n.currentTime;t.volumeParam.setTargetAtTime(Math.max(0,Math.min(1,e.volume))*t.gainScale,s,Ah);for(const{param:r,ratio:a}of t.pitch)r.setTargetAtTime(Math.min(e.pitchHz*a,n.sampleRate/2-1),s,Ah)}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 s=t.createOscillator();s.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),s.connect(r),r.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],volumeParam:a.gain,gainScale:.16,pitch:[{param:n.frequency,ratio:1},{param:s.frequency,ratio:1.006},{param:r.frequency,ratio:6}]}}buildWhistle(t,e){const n=t.createOscillator();n.type="sine";const s=t.createOscillator();s.type="sine",s.frequency.value=5;const r=t.createGain(),a=t.createGain();return a.gain.value=0,s.connect(r).connect(n.frequency),n.connect(a).connect(t.destination),n.start(),s.start(),{key:e,nodes:[r,a],sources:[n,s],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 s=t.createBiquadFilter();s.type="lowpass",s.Q.value=.8;const r=t.createGain();return r.gain.value=0,n.connect(s).connect(r).connect(t.destination),n.start(),{key:e,nodes:[s,r],sources:[n],volumeParam:r.gain,gainScale:1.4,pitch:[{param:s.frequency,ratio:1}]}}buildCrackle(t,e){const n=t.createBufferSource();n.buffer=this.whiteNoise(t),n.loop=!0;const s=t.createBiquadFilter();s.type="bandpass",s.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(s).connect(r).connect(t.destination),n.start(),a.start(),{key:e,nodes:[s,r,o],sources:[n,a],volumeParam:o.gain,gainScale:.9,pitch:[{param:s.frequency,ratio:4}]}}async buildRecordedVoice(t,e,n){const s=this.context;if(!s)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=s.createBufferSource();a.buffer=r,a.loop=!0;const o=s.createGain();o.gain.value=0,a.connect(o).connect(s.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(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}whiteNoise(t){if(!this.noiseBuffer){const e=t.createBuffer(1,Math.floor(t.sampleRate*Rh),t.sampleRate),n=e.getChannelData(0);for(let s=0;s<n.length;s++)n[s]=Math.random()*2-1;this.noiseBuffer=e}return this.noiseBuffer}brownNoise(t){const e=t.createBuffer(1,Math.floor(t.sampleRate*Rh),t.sampleRate),n=e.getChannelData(0);let s=0,r=0;for(let a=0;a<n.length;a++)s=(s+.02*(Math.random()*2-1))/1.02,n[a]=s,r=Math.max(r,Math.abs(s));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*Ch),t.sampleRate),n=e.getChannelData(0),s=Math.max(1,Math.floor(ip*t.sampleRate)),r=Math.round(Ch*np);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<s&&o+l<n.length;l++)n[o+l]=Math.max(n[o+l],c*(1-l/s))}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,Th/3);const s=n+Th;for(const r of t.sources){r.onended=()=>{r.disconnect();for(const a of t.nodes)a.disconnect()};try{r.stop(s)}catch{r.disconnect();for(const a of t.nodes)a.disconnect()}}}}const uo=Math.PI/180,Nr=180/Math.PI;class Ps{constructor(t,e,n){this.kind=t,this.canvasHeightPx=e,this.fovDeg=n;const s=n*uo/2;this.focalPx=t==="equidistant"?e/2/s:e/2/Math.tan(s)}focalPx;static of(t,e,n){return new Ps(t.projection,e,n)}degToPx(t){const e=t*uo;return this.kind==="equidistant"?this.focalPx*e:2*this.focalPx*Math.tan(e/2)}pxToDeg(t){return this.kind==="equidistant"?t/this.focalPx*Nr:2*Math.atan(t/(2*this.focalPx))*Nr}angleDegToRadiusPx(t){const e=t*uo;return this.kind==="equidistant"?this.focalPx*e:this.focalPx*Math.tan(e)}radiusPxToAngleDeg(t){return this.kind==="equidistant"?t/this.focalPx*Nr:Math.atan(t/this.focalPx)*Nr}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(tn.angularWidthDeg(t))}}class zl{static DEFAULT_FOV_DEG=60;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:s,height:r}=n.toBoundsSize(e.angular),a={x:e.bounds.x+(e.bounds.width-s)/2,y:e.bounds.y+(e.bounds.height-r)/2,width:s,height:r};if(e.kind!=="polygon")return{...e,bounds:a};const o=e.bounds.width===0?1:s/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 reproject(t,e){const n=tn.CANVAS_WIDTH_PX/2,s=tn.CANVAS_HEIGHT_PX/2;for(const r of[...t.timeline.allKeyframes]){const a=mr(t,r.t)?.fovDeg??this.DEFAULT_FOV_DEG,o=Ps.of(e,tn.CANVAS_HEIGHT_PX,a),c=Ps.of(t.instrument,tn.CANVAS_HEIGHT_PX,a);t.timeline.addKeyframe(r.t,r.shapes.map(l=>{const{bounds:h}=l.shape,u=h.x+h.width/2-n,d=h.y+h.height/2-s,f=Math.hypot(u,d);if(f===0)return l;const g=c.angleDegToRadiusPx(o.radiusPxToAngleDeg(f))/f,x={...h,x:n+u*g-h.width/2,y:s+d*g-h.height/2};return{...l,shape:{...l.shape,bounds:x}}}))}this.toBounds(t)}static eachKeyframe(t,e){const{timeline:n}=t;for(const s of[...n.allKeyframes]){const r=mr(t,s.t)?.fovDeg??this.DEFAULT_FOV_DEG,a=Ps.of(t.instrument,tn.CANVAS_HEIGHT_PX,r);n.addKeyframe(s.t,s.shapes.map(o=>({...o,shape:e(o.shape,a)})))}}}function rp(i){return zl.toAngular(i),{version:1,time:i.event.time,endTime:i.event.endTime,durationSeconds:i.event.durationSeconds,utcOffsetHours:i.event.utcOffsetHours,timeZone:i.event.timeZone,place:i.event.place,witness:i.witness,caseId:i.caseId,description:i.event.description,tags:i.event.tags,timeline:i.timeline.toJSON(),witnessTrack:i.witnessTrack.toJSON(),weatherTrack:i.weatherTrack.toJSON(),soundTrack:i.soundTrack.toJSON(),weather:i.weather,decor:i.decor,weatherSource:i.weatherSource,instrument:i.instrumentId}}function ap(i){const t=new Qa({eventType:"sighting",time:i.time,endTime:i.endTime,durationSeconds:i.durationSeconds,utcOffsetHours:i.utcOffsetHours,timeZone:i.timeZone,place:i.place,description:i.description,tags:i.tags},Ja.fromJSON(i.timeline),i.witnessTrack?_r.fromJSON(i.witnessTrack):new _r,i.weatherTrack?xr.fromJSON(i.weatherTrack):new xr,i.soundTrack?Mr.fromJSON(i.soundTrack):new Mr,i.witness,i.caseId,i.weather,i.decor??[],i.weatherSource,i.instrument);return zl.toBounds(t),t}function ja(i,t){for(const e of i){const n=e.toLowerCase().split("-")[0];if(t.includes(n))return n}return"en"}const op="modulepreload",cp=function(i,t){return new URL(i,t).href},Dh={},Ua=function(t,e,n){let s=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");s=a(e.map(h=>{if(h=cp(h,n),h in Dh)return;Dh[h]=!0;const u=h.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(!!n)for(let x=o.length-1;x>=0;x--){const m=o[x];if(m.href===h&&(!u||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${h}"]${d}`))return;const g=document.createElement("link");if(g.rel=u?"stylesheet":op,u||(g.as="script"),g.crossOrigin="",g.href=h,l&&g.setAttribute("nonce",l),document.head.appendChild(g),u)return new Promise((x,m)=>{g.addEventListener("load",x),g.addEventListener("error",()=>m(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 s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return t().catch(r)})},kd=["en","fr"],lp={en:()=>Ua(()=>Promise.resolve().then(()=>fp),void 0,import.meta.url).then(i=>i.ufoMessages_en),fr:()=>Ua(()=>import("./UfoMessages_fr-Hq24iVzT.js"),[],import.meta.url).then(i=>i.ufoMessages_fr)};function hp(i){return lp[i]()}const up={en:()=>Ua(()=>Promise.resolve().then(()=>Ry),void 0,import.meta.url).then(i=>i.eyewitnessMessages_en),fr:()=>Ua(()=>import("./EyewitnessMessages_fr-CzOAdmOE.js"),[],import.meta.url).then(i=>i.eyewitnessMessages_fr)};function dp(i){return up[i]()}const Gd={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"},fp=Object.freeze(Object.defineProperty({__proto__:null,ufoMessages_en:Gd},Symbol.toStringTag,{value:"Module"})),Ph=new Set;class pp extends HTMLElement{static get observedAttributes(){return["src"]}shadow;stageElement;canvas;canvasRenderer;tooltip;toolbar;playPauseButton;loopButton;fullscreenButton;seekInput;timeStartLabel;timeEndLabel;currentSighting=Qa.create();sightingAudio=new sp;soundPreview;player;loopEnabled=!0;highlightedSourceIds=new Set;occludedSourceIds=Ph;enableClickToPlay=!0;fullscreenTarget;messages=Gd;realDurationMs;realStartMs;showClockTime=!0;handleFullscreenChange=()=>this.updateFullscreenButton();handlePointerMove=t=>{const e=this.canvasPointFromEvent(t),n=e&&this.currentSighting.timeline.hitTest(this.currentTime,e.x,e.y,this.occludedSourceIds);if(!n?.shape.title){this.tooltip.hidden=!0;return}this.tooltip.textContent=n.shape.title,this.tooltip.hidden=!1;const s=this.stageElement.getBoundingClientRect();this.tooltip.style.left=`${t.clientX-s.left+12}px`,this.tooltip.style.top=`${t.clientY-s.top+12}px`};handlePointerLeave=()=>{this.tooltip.hidden=!0};constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${Rf}</style>${Tf}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.canvas=this.shadow.getElementById("canvas"),this.canvasRenderer=new ep(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.seekInput=this.shadow.getElementById("seek"),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.seekInput.addEventListener("input",()=>this.player.seek(Number(this.seekInput.value))),this.canvas.addEventListener("click",()=>{this.enableClickToPlay&&this.togglePlayPause()}),this.canvas.addEventListener("pointermove",this.handlePointerMove),this.canvas.addEventListener("pointerleave",this.handlePointerLeave),document.addEventListener("fullscreenchange",this.handleFullscreenChange),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.updateFullscreenButton(),this.refresh(),this.loadLocaleMessages()}connectedCallback(){const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sightingAudio.dispose()}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(t){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return rp(this.currentSighting)}set sightingData(t){this.player.stop(),this.soundPreview=void 0,this.sightingAudio.silence(),this.currentSighting=ap(t),this.player=this.createPlayer(),this.updateTimeLabels(),this.updatePlayPauseButton(),this.refresh()}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}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(s=>this.highlightedSourceIds.has(s))||(this.highlightedSourceIds=e,this.refresh())}setOccludedSourceIds(t){t.size===this.occludedSourceIds.size&&[...t].every(n=>this.occludedSourceIds.has(n))||(this.occludedSourceIds=t,this.refresh())}hasVisibleShapeAt(t,e){return this.currentSighting.timeline.hitTest(this.currentTime,t,e,this.occludedSourceIds)!==void 0}refresh(){this.updateTimeLabels(),this.seekInput.max=String(this.player.seekableDuration),this.player.seek(this.player.time)}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:Ph;for(const[s,r]of e){if(this.occludedSourceIds.has(s))continue;const a=n.has(s);a&&n.size===1?this.canvasRenderer.paintShape({...r,selected:!0}):(this.canvasRenderer.paintShape(r),a&&this.canvasRenderer.paintMemberOutline(r))}if(n.size>1){const s=on.groupBoundsFor([...e].filter(([r])=>n.has(r)).map(([,r])=>r.bounds));this.canvasRenderer.paintGroupHandles(s)}this.seekInput.value=String(t),this.timeStartLabel.textContent=this.formatPosition(t),this.playbackState==="playing"?(this.soundPreview=void 0,this.sightingAudio.setSound(Kf(this.currentSighting,t))):this.soundPreview?this.sightingAudio.setSound(this.soundPreview):this.sightingAudio.silence(),this.updatePlayPauseButton(),this.dispatchEvent(new CustomEvent("timeupdate",{detail:{time:t}}))}createPlayer(){const t=new Zf(this.currentSighting.timeline,(e,n)=>this.onFrame(e,n));return t.loop=this.loopEnabled,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.fullscreenButton.classList.toggle("auto-hide",t)}toggleLoop(){this.loopEnabled=!this.loopEnabled,this.loopButton.setAttribute("aria-pressed",String(this.loopEnabled)),this.player.loop=this.loopEnabled}toggleFullscreen(){document.fullscreenElement?document.exitFullscreen():this.fullscreenTarget.requestFullscreen().catch(t=>{console.error("<rr0-ufo>: requestFullscreen() failed —",t)})}updateFullscreenButton(){const t=document.fullscreenElement===this.fullscreenTarget;this.fullscreenButton.title=t?this.messages.exitFullscreen:this.messages.fullscreen,this.fullscreenButton.setAttribute("aria-label",this.fullscreenButton.title)}async loadLocaleMessages(){const t=ja(navigator.languages,kd);t!=="en"&&this.applyMessages(await hp(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()}updateTimeLabels(){const t=this.currentSighting.event,e=Wf(t);this.realDurationMs=e!==void 0&&e>0?e:void 0,this.realStartMs=t.time?mc(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 Ur(t);const e=this.currentSighting.timeline.duration,n=e>0&&t<=e?t/e*this.realDurationMs:t;return this.canShowClockTime?Lh(Ih(this.realStartMs+n)):Ur(n)}formatEndOfTimeline(){return this.realDurationMs===void 0?Ur(this.currentSighting.timeline.duration):this.canShowClockTime?Lh(Ih(this.realStartMs+this.realDurationMs)):Ur(this.realDurationMs)}}function Ih(i){const t=new Date(i);return{hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds()}}function Lh(i){if(i.hour===void 0)return"0:00";const t=e=>String(e).padStart(2,"0");return i.second?`${t(i.hour)}:${t(i.minute??0)}:${t(i.second)}`:`${t(i.hour)}:${t(i.minute??0)}`}function Ur(i){const t=Math.round(i/1e3),e=Math.floor(t/60),n=t%60;return`${e}:${String(n).padStart(2,"0")}`}const vc="rr0-ufo";function Hd(){customElements.get(vc)||customElements.define(vc,pp)}/**
|
|
564
564
|
* @license
|
|
565
565
|
* Copyright 2010-2026 Three.js Authors
|
|
566
566
|
* SPDX-License-Identifier: MIT
|
|
567
|
-
*/const wc="185",Qf=0,Mh=1,jf=2,ar=1,ep=2,js=3,_i=0,Nt=1,vn=2,Zn=0,bs=1,Bi=2,yh=3,Sh=4,tp=5,Pi=100,np=101,ip=102,sp=103,rp=104,ap=200,op=201,lp=202,cp=203,rl=204,al=205,hp=206,up=207,dp=208,fp=209,pp=210,mp=211,gp=212,vp=213,_p=214,ol=0,ll=1,cl=2,Ds=3,hl=4,ul=5,dl=6,fl=7,Ac=0,xp=1,Mp=2,Fn=0,Ad=1,Td=2,Rd=3,Cd=4,Dd=5,Pd=6,Id=7,Ld=300,ki=301,Ps=302,ja=303,eo=304,Ga=306,pl=1e3,Kn=1001,ml=1002,Ut=1003,yp=1004,br=1005,Gt=1006,to=1007,Ui=1008,nn=1009,Nd=1010,Ud=1011,hr=1012,Tc=1013,zn=1014,Ln=1015,Jn=1016,Rc=1017,Cc=1018,ur=1020,Fd=35902,Od=35899,zd=1021,Bd=1022,_n=1023,Qn=1026,Fi=1027,kd=1028,Dc=1029,Gi=1030,Pc=1031,Ic=1033,ma=33776,ga=33777,va=33778,_a=33779,gl=35840,vl=35841,_l=35842,xl=35843,Ml=36196,yl=37492,Sl=37496,El=37488,bl=37489,ba=37490,wl=37491,Al=37808,Tl=37809,Rl=37810,Cl=37811,Dl=37812,Pl=37813,Il=37814,Ll=37815,Nl=37816,Ul=37817,Fl=37818,Ol=37819,zl=37820,Bl=37821,kl=36492,Gl=36494,Hl=36495,Vl=36283,Wl=36284,wa=36285,Xl=36286,Sp=3200,ql=0,Ep=1,fi="",hn="srgb",Aa="srgb-linear",Ta="linear",je="srgb",Zi=7680,Eh=519,bp=512,wp=513,Ap=514,Lc=515,Tp=516,Rp=517,Nc=518,Cp=519,Yl=35044,bh="300 es",Nn=2e3,dr=2001;function Dp(i){for(let e=i.length-1;e>=0;--e)if(i[e]>=65535)return!0;return!1}function Ra(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Pp(){const i=Ra("canvas");return i.style.display="block",i}const wh={};function Ca(...i){const e="THREE."+i.shift();console.log(e,...i)}function Gd(i){const e=i[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=i[1];t&&t.isStackTrace?i[0]+=" "+t.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Oe(...i){i=Gd(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...i)}}function qe(...i){i=Gd(i);const e="THREE."+i.shift();{const t=i[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...i)}}function ws(...i){const e=i.join(" ");e in wh||(wh[e]=!0,Oe(...i))}function Ip(i,e,t){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(e,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:n()}}setTimeout(r,t)})}const Lp={[ol]:ll,[cl]:dl,[hl]:fl,[Ds]:ul,[ll]:ol,[dl]:cl,[fl]:hl,[ul]:Ds};class Xi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const n=this._listeners;n[e]===void 0&&(n[e]=[]),n[e].indexOf(t)===-1&&n[e].push(t)}hasEventListener(e,t){const n=this._listeners;return n===void 0?!1:n[e]!==void 0&&n[e].indexOf(t)!==-1}removeEventListener(e,t){const n=this._listeners;if(n===void 0)return;const s=n[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const n=t[e.type];if(n!==void 0){e.target=this;const s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,e);e.target=null}}}const zt=["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"],no=Math.PI/180,Kl=180/Math.PI;function gi(){const i=Math.random()*4294967295|0,e=Math.random()*4294967295|0,t=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(zt[i&255]+zt[i>>8&255]+zt[i>>16&255]+zt[i>>24&255]+"-"+zt[e&255]+zt[e>>8&255]+"-"+zt[e>>16&15|64]+zt[e>>24&255]+"-"+zt[t&63|128]+zt[t>>8&255]+"-"+zt[t>>16&255]+zt[t>>24&255]+zt[n&255]+zt[n>>8&255]+zt[n>>16&255]+zt[n>>24&255]).toLowerCase()}function Ke(i,e,t){return Math.max(e,Math.min(t,i))}function Np(i,e){return(i%e+e)%e}function io(i,e,t){return(1-t)*i+t*e}function In(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function nt(i,e){switch(e.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class Fe{static{Fe.prototype.isVector2=!0}constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,n=this.y,s=e.elements;return this.x=s[0]*t+s[3]*n+s[6],this.y=s[1]*t+s[4]*n+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y;return t*t+n*n}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const n=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*n-a*s+e.x,this.y=r*s+a*n+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}}class Us{constructor(e=0,t=0,n=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=n,this._w=s}static slerpFlat(e,t,n,s,r,a,o){let l=n[s+0],c=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],p=r[a+1],g=r[a+2],x=r[a+3];if(u!==x||l!==d||c!==p||h!==g){let m=l*d+c*p+h*g+u*x;m<0&&(d=-d,p=-p,g=-g,x=-x,m=-m);let f=1-o;if(m<.9995){const w=Math.acos(m),T=Math.sin(w);f=Math.sin(f*w)/T,o=Math.sin(o*w)/T,l=l*f+d*o,c=c*f+p*o,h=h*f+g*o,u=u*f+x*o}else{l=l*f+d*o,c=c*f+p*o,h=h*f+g*o,u=u*f+x*o;const w=1/Math.sqrt(l*l+c*c+h*h+u*u);l*=w,c*=w,h*=w,u*=w}}e[t]=l,e[t+1]=c,e[t+2]=h,e[t+3]=u}static multiplyQuaternionsFlat(e,t,n,s,r,a){const o=n[s],l=n[s+1],c=n[s+2],h=n[s+3],u=r[a],d=r[a+1],p=r[a+2],g=r[a+3];return e[t]=o*g+h*u+l*p-c*d,e[t+1]=l*g+h*d+c*u-o*p,e[t+2]=c*g+h*p+o*d-l*u,e[t+3]=h*g-o*u-l*d-c*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,n,s){return this._x=e,this._y=t,this._z=n,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const n=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(n/2),h=o(s/2),u=o(r/2),d=l(n/2),p=l(s/2),g=l(r/2);switch(a){case"XYZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"YXZ":this._x=d*h*u+c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"ZXY":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u-d*p*g;break;case"ZYX":this._x=d*h*u-c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u+d*p*g;break;case"YZX":this._x=d*h*u+c*p*g,this._y=c*p*u+d*h*g,this._z=c*h*g-d*p*u,this._w=c*h*u-d*p*g;break;case"XZY":this._x=d*h*u-c*p*g,this._y=c*p*u-d*h*g,this._z=c*h*g+d*p*u,this._w=c*h*u+d*p*g;break;default:Oe("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const n=t/2,s=Math.sin(n);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,n=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],h=t[6],u=t[10],d=n+o+u;if(d>0){const p=.5/Math.sqrt(d+1);this._w=.25/p,this._x=(h-l)*p,this._y=(r-c)*p,this._z=(a-s)*p}else if(n>o&&n>u){const p=2*Math.sqrt(1+n-o-u);this._w=(h-l)/p,this._x=.25*p,this._y=(s+a)/p,this._z=(r+c)/p}else if(o>u){const p=2*Math.sqrt(1+o-n-u);this._w=(r-c)/p,this._x=(s+a)/p,this._y=.25*p,this._z=(l+h)/p}else{const p=2*Math.sqrt(1+u-n-o);this._w=(a-s)/p,this._x=(r+c)/p,this._y=(l+h)/p,this._z=.25*p}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let n=e.dot(t)+1;return n<1e-8?(n=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=n):(this._x=0,this._y=-e.z,this._z=e.y,this._w=n)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=n),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Ke(this.dot(e),-1,1)))}rotateTowards(e,t){const n=this.angleTo(e);if(n===0)return this;const s=Math.min(1,t/n);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const n=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,h=t._w;return this._x=n*h+a*o+s*c-r*l,this._y=s*h+a*l+r*o-n*c,this._z=r*h+a*c+n*l-s*o,this._w=a*h-n*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let n=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(n=-n,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),h=Math.sin(c);l=Math.sin(l*c)/h,t=Math.sin(t*c)/h,this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+n*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,n){return this.copy(e).slerp(t,n)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),n=Math.random(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}class U{static{U.prototype.isVector3=!0}constructor(e=0,t=0,n=0){this.x=e,this.y=t,this.z=n}set(e,t,n){return n===void 0&&(n=this.z),this.x=e,this.y=t,this.z=n,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Ah.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Ah.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*n+r[6]*s,this.y=r[1]*t+r[4]*n+r[7]*s,this.z=r[2]*t+r[5]*n+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,n=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*n),h=2*(o*t-r*s),u=2*(r*n-a*t);return this.x=t+l*c+a*u-o*h,this.y=n+l*h+o*c-r*u,this.z=s+l*u+r*h-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,n=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*n+r[8]*s,this.y=r[1]*t+r[5]*n+r[9]*s,this.z=r[2]*t+r[6]*n+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const n=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-n*l,this.z=n*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const n=e.dot(this)/t;return this.copy(e).multiplyScalar(n)}projectOnPlane(e){return so.copy(this).projectOnVector(e),this.sub(so)}reflect(e){return this.sub(so.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const n=this.dot(e)/t;return Math.acos(Ke(n,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,n=this.y-e.y,s=this.z-e.z;return t*t+n*n+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,n){const s=Math.sin(t)*e;return this.x=s*Math.sin(n),this.y=Math.cos(t)*e,this.z=s*Math.cos(n),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,n){return this.x=e*Math.sin(t),this.y=n,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),n=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=n,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,n=Math.sqrt(1-t*t);return this.x=n*Math.cos(e),this.y=t,this.z=n*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}}const so=new U,Ah=new Us;class ze{static{ze.prototype.isMatrix3=!0}constructor(e,t,n,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c)}set(e,t,n,s,r,a,o,l,c){const h=this.elements;return h[0]=e,h[1]=s,h[2]=o,h[3]=t,h[4]=r,h[5]=l,h[6]=n,h[7]=a,h[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],this}extractBasis(e,t,n){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),n.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[3],l=n[6],c=n[1],h=n[4],u=n[7],d=n[2],p=n[5],g=n[8],x=s[0],m=s[3],f=s[6],w=s[1],T=s[4],M=s[7],S=s[2],b=s[5],R=s[8];return r[0]=a*x+o*w+l*S,r[3]=a*m+o*T+l*b,r[6]=a*f+o*M+l*R,r[1]=c*x+h*w+u*S,r[4]=c*m+h*T+u*b,r[7]=c*f+h*M+u*R,r[2]=d*x+p*w+g*S,r[5]=d*m+p*T+g*b,r[8]=d*f+p*M+g*R,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8];return t*a*h-t*o*c-n*r*h+n*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=h*a-o*c,d=o*l-h*r,p=c*r-a*l,g=t*u+n*d+s*p;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return e[0]=u*x,e[1]=(s*c-h*n)*x,e[2]=(o*n-s*a)*x,e[3]=d*x,e[4]=(h*t-s*l)*x,e[5]=(s*r-o*t)*x,e[6]=p*x,e[7]=(n*l-c*t)*x,e[8]=(a*t-n*r)*x,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,n,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(n*l,n*c,-n*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return ws("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(ro.makeScale(e,t)),this}rotate(e){return ws("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(ro.makeRotation(-e)),this}translate(e,t){return ws("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(ro.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,n,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<9;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<9;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e}clone(){return new this.constructor().fromArray(this.elements)}}const ro=new ze,Th=new ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Rh=new ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Up(){const i={enabled:!0,workingColorSpace:Aa,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===je&&(s.r=$n(s.r),s.g=$n(s.g),s.b=$n(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===je&&(s.r=As(s.r),s.g=As(s.g),s.b=As(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===fi?Ta:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return ws("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return ws("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[Aa]:{primaries:e,whitePoint:n,transfer:Ta,toXYZ:Th,fromXYZ:Rh,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:hn},outputColorSpaceConfig:{drawingBufferColorSpace:hn}},[hn]:{primaries:e,whitePoint:n,transfer:je,toXYZ:Th,fromXYZ:Rh,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:hn}}}),i}const Ye=Up();function $n(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function As(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let $i;class Fp{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let n;if(e instanceof HTMLCanvasElement)n=e;else{$i===void 0&&($i=Ra("canvas")),$i.width=e.width,$i.height=e.height;const s=$i.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),n=$i}return n.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ra("canvas");t.width=e.width,t.height=e.height;const n=t.getContext("2d");n.drawImage(e,0,0,e.width,e.height);const s=n.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=$n(r[a]/255)*255;return n.putImageData(s,0,0),t}else if(e.data){const t=e.data.slice(0);for(let n=0;n<t.length;n++)t instanceof Uint8Array||t instanceof Uint8ClampedArray?t[n]=Math.floor($n(t[n]/255)*255):t[n]=$n(t[n]);return{data:t,width:e.width,height:e.height}}else return Oe("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),e}}let Op=0;class Uc{constructor(e=null){this.isSource=!0,Object.defineProperty(this,"id",{value:Op++}),this.uuid=gi(),this.data=e,this.dataReady=!0,this.version=0}getSize(e){const t=this.data;return typeof HTMLVideoElement<"u"&&t instanceof HTMLVideoElement?e.set(t.videoWidth,t.videoHeight,0):typeof VideoFrame<"u"&&t instanceof VideoFrame?e.set(t.displayWidth,t.displayHeight,0):t!==null?e.set(t.width,t.height,t.depth||0):e.set(0,0,0),e}set needsUpdate(e){e===!0&&this.version++}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.images[this.uuid]!==void 0)return e.images[this.uuid];const n={uuid:this.uuid,url:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(ao(s[a].image)):r.push(ao(s[a]))}else r=ao(s);n.url=r}return t||(e.images[this.uuid]=n),n}}function ao(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?Fp.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Oe("Texture: Unable to serialize Texture."),{})}let zp=0;const oo=new U;class Vt extends Xi{constructor(e=Vt.DEFAULT_IMAGE,t=Vt.DEFAULT_MAPPING,n=Kn,s=Kn,r=Gt,a=Ui,o=_n,l=nn,c=Vt.DEFAULT_ANISOTROPY,h=fi){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:zp++}),this.uuid=gi(),this.name="",this.source=new Uc(e),this.mipmaps=[],this.mapping=t,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=c,this.format=o,this.internalFormat=null,this.type=l,this.offset=new Fe(0,0),this.repeat=new Fe(1,1),this.center=new Fe(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new ze,this.generateMipmaps=!0,this.premultiplyAlpha=!1,this.flipY=!0,this.unpackAlignment=4,this.colorSpace=h,this.userData={},this.updateRanges=[],this.version=0,this.onUpdate=null,this.renderTarget=null,this.isRenderTargetTexture=!1,this.isArrayTexture=!!(e&&e.depth&&e.depth>1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(oo).x}get height(){return this.source.getSize(oo).y}get depth(){return this.source.getSize(oo).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const n=e[t];if(n===void 0){Oe(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const n={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(n.userData=this.userData),t||(e.textures[this.uuid]=n),n}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Ld)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case pl:e.x=e.x-Math.floor(e.x);break;case Kn:e.x=e.x<0?0:1;break;case ml:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case pl:e.y=e.y-Math.floor(e.y);break;case Kn:e.y=e.y<0?0:1;break;case ml:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Vt.DEFAULT_IMAGE=null;Vt.DEFAULT_MAPPING=Ld;Vt.DEFAULT_ANISOTROPY=1;class ft{static{ft.prototype.isVector4=!0}constructor(e=0,t=0,n=0,s=1){this.x=e,this.y=t,this.z=n,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,n,s){return this.x=e,this.y=t,this.z=n,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,n=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*n+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,n,s,r;const l=e.elements,c=l[0],h=l[4],u=l[8],d=l[1],p=l[5],g=l[9],x=l[2],m=l[6],f=l[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(c+p+f-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const T=(c+1)/2,M=(p+1)/2,S=(f+1)/2,b=(h+d)/4,R=(u+x)/4,_=(g+m)/4;return T>M&&T>S?T<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(T),s=b/n,r=R/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=_/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=R/r,s=_/r),this.set(n,s,r,t),this}let w=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(u-x)/w,this.z=(d-h)/w,this.w=Math.acos((c+p+f-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Ke(this.x,e.x,t.x),this.y=Ke(this.y,e.y,t.y),this.z=Ke(this.z,e.z,t.z),this.w=Ke(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Ke(this.x,e,t),this.y=Ke(this.y,e,t),this.z=Ke(this.z,e,t),this.w=Ke(this.w,e,t),this}clampLength(e,t){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Ke(n,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,n){return this.x=e.x+(t.x-e.x)*n,this.y=e.y+(t.y-e.y)*n,this.z=e.z+(t.z-e.z)*n,this.w=e.w+(t.w-e.w)*n,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}}class Bp extends Xi{constructor(e=1,t=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Gt,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=e,this.height=t,this.depth=n.depth,this.scissor=new ft(0,0,e,t),this.scissorTest=!1,this.viewport=new ft(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:n.depth},r=new Vt(s),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(e={}){const t={minFilter:Gt,generateMipmaps:!1,flipY:!1,internalFormat:null};e.mapping!==void 0&&(t.mapping=e.mapping),e.wrapS!==void 0&&(t.wrapS=e.wrapS),e.wrapT!==void 0&&(t.wrapT=e.wrapT),e.wrapR!==void 0&&(t.wrapR=e.wrapR),e.magFilter!==void 0&&(t.magFilter=e.magFilter),e.minFilter!==void 0&&(t.minFilter=e.minFilter),e.format!==void 0&&(t.format=e.format),e.type!==void 0&&(t.type=e.type),e.anisotropy!==void 0&&(t.anisotropy=e.anisotropy),e.colorSpace!==void 0&&(t.colorSpace=e.colorSpace),e.flipY!==void 0&&(t.flipY=e.flipY),e.generateMipmaps!==void 0&&(t.generateMipmaps=e.generateMipmaps),e.internalFormat!==void 0&&(t.internalFormat=e.internalFormat);for(let n=0;n<this.textures.length;n++)this.textures[n].setValues(t)}get texture(){return this.textures[0]}set texture(e){this.textures[0]=e}set depthTexture(e){this._depthTexture!==null&&(this._depthTexture.renderTarget=null),e!==null&&(e.renderTarget=this),this._depthTexture=e}get depthTexture(){return this._depthTexture}setSize(e,t,n=1){if(this.width!==e||this.height!==t||this.depth!==n){this.width=e,this.height=t,this.depth=n;for(let s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=e,this.textures[s].image.height=t,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].image.depth>1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,n=e.textures.length;t<n;t++){this.textures[t]=e.textures[t].clone(),this.textures[t].isRenderTargetTexture=!0,this.textures[t].renderTarget=this;const s=Object.assign({},e.textures[t].image);this.textures[t].source=new Uc(s)}return this.depthBuffer=e.depthBuffer,this.stencilBuffer=e.stencilBuffer,this.resolveDepthBuffer=e.resolveDepthBuffer,this.resolveStencilBuffer=e.resolveStencilBuffer,e.depthTexture!==null&&(this.depthTexture=e.depthTexture.clone()),this.samples=e.samples,this.multiview=e.multiview,this.useArrayDepthTexture=e.useArrayDepthTexture,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Mn extends Bp{constructor(e=1,t=1,n={}){super(e,t,n),this.isWebGLRenderTarget=!0}}class Hd extends Vt{constructor(e=null,t=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(e){this.layerUpdates.add(e)}clearLayerUpdates(){this.layerUpdates.clear()}}class kp extends Vt{constructor(e=null,t=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:e,width:t,height:n,depth:s},this.magFilter=Ut,this.minFilter=Ut,this.wrapR=Kn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class ht{static{ht.prototype.isMatrix4=!0}constructor(e,t,n,s,r,a,o,l,c,h,u,d,p,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,n,s,r,a,o,l,c,h,u,d,p,g,x,m)}set(e,t,n,s,r,a,o,l,c,h,u,d,p,g,x,m){const f=this.elements;return f[0]=e,f[4]=t,f[8]=n,f[12]=s,f[1]=r,f[5]=a,f[9]=o,f[13]=l,f[2]=c,f[6]=h,f[10]=u,f[14]=d,f[3]=p,f[7]=g,f[11]=x,f[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new ht().fromArray(this.elements)}copy(e){const t=this.elements,n=e.elements;return t[0]=n[0],t[1]=n[1],t[2]=n[2],t[3]=n[3],t[4]=n[4],t[5]=n[5],t[6]=n[6],t[7]=n[7],t[8]=n[8],t[9]=n[9],t[10]=n[10],t[11]=n[11],t[12]=n[12],t[13]=n[13],t[14]=n[14],t[15]=n[15],this}copyPosition(e){const t=this.elements,n=e.elements;return t[12]=n[12],t[13]=n[13],t[14]=n[14],this}setFromMatrix3(e){const t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,n){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),n.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),n.setFromMatrixColumn(this,2),this)}makeBasis(e,t,n){return this.set(e.x,t.x,n.x,0,e.y,t.y,n.y,0,e.z,t.z,n.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();const t=this.elements,n=e.elements,s=1/Ji.setFromMatrixColumn(e,0).length(),r=1/Ji.setFromMatrixColumn(e,1).length(),a=1/Ji.setFromMatrixColumn(e,2).length();return t[0]=n[0]*s,t[1]=n[1]*s,t[2]=n[2]*s,t[3]=0,t[4]=n[4]*r,t[5]=n[5]*r,t[6]=n[6]*r,t[7]=0,t[8]=n[8]*a,t[9]=n[9]*a,t[10]=n[10]*a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){const t=this.elements,n=e.x,s=e.y,r=e.z,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(e.order==="XYZ"){const d=a*h,p=a*u,g=o*h,x=o*u;t[0]=l*h,t[4]=-l*u,t[8]=c,t[1]=p+g*c,t[5]=d-x*c,t[9]=-o*l,t[2]=x-d*c,t[6]=g+p*c,t[10]=a*l}else if(e.order==="YXZ"){const d=l*h,p=l*u,g=c*h,x=c*u;t[0]=d+x*o,t[4]=g*o-p,t[8]=a*c,t[1]=a*u,t[5]=a*h,t[9]=-o,t[2]=p*o-g,t[6]=x+d*o,t[10]=a*l}else if(e.order==="ZXY"){const d=l*h,p=l*u,g=c*h,x=c*u;t[0]=d-x*o,t[4]=-a*u,t[8]=g+p*o,t[1]=p+g*o,t[5]=a*h,t[9]=x-d*o,t[2]=-a*c,t[6]=o,t[10]=a*l}else if(e.order==="ZYX"){const d=a*h,p=a*u,g=o*h,x=o*u;t[0]=l*h,t[4]=g*c-p,t[8]=d*c+x,t[1]=l*u,t[5]=x*c+d,t[9]=p*c-g,t[2]=-c,t[6]=o*l,t[10]=a*l}else if(e.order==="YZX"){const d=a*l,p=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=x-d*u,t[8]=g*u+p,t[1]=u,t[5]=a*h,t[9]=-o*h,t[2]=-c*h,t[6]=p*u+g,t[10]=d-x*u}else if(e.order==="XZY"){const d=a*l,p=a*c,g=o*l,x=o*c;t[0]=l*h,t[4]=-u,t[8]=c*h,t[1]=d*u+x,t[5]=a*h,t[9]=p*u-g,t[2]=g*u-p,t[6]=o*h,t[10]=x*u+d}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(Gp,e,Hp)}lookAt(e,t,n){const s=this.elements;return Jt.subVectors(e,t),Jt.lengthSq()===0&&(Jt.z=1),Jt.normalize(),ii.crossVectors(n,Jt),ii.lengthSq()===0&&(Math.abs(n.z)===1?Jt.x+=1e-4:Jt.z+=1e-4,Jt.normalize(),ii.crossVectors(n,Jt)),ii.normalize(),wr.crossVectors(Jt,ii),s[0]=ii.x,s[4]=wr.x,s[8]=Jt.x,s[1]=ii.y,s[5]=wr.y,s[9]=Jt.y,s[2]=ii.z,s[6]=wr.z,s[10]=Jt.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const n=e.elements,s=t.elements,r=this.elements,a=n[0],o=n[4],l=n[8],c=n[12],h=n[1],u=n[5],d=n[9],p=n[13],g=n[2],x=n[6],m=n[10],f=n[14],w=n[3],T=n[7],M=n[11],S=n[15],b=s[0],R=s[4],_=s[8],E=s[12],D=s[1],C=s[5],L=s[9],X=s[13],q=s[2],F=s[6],W=s[10],V=s[14],Q=s[3],te=s[7],ee=s[11],se=s[15];return r[0]=a*b+o*D+l*q+c*Q,r[4]=a*R+o*C+l*F+c*te,r[8]=a*_+o*L+l*W+c*ee,r[12]=a*E+o*X+l*V+c*se,r[1]=h*b+u*D+d*q+p*Q,r[5]=h*R+u*C+d*F+p*te,r[9]=h*_+u*L+d*W+p*ee,r[13]=h*E+u*X+d*V+p*se,r[2]=g*b+x*D+m*q+f*Q,r[6]=g*R+x*C+m*F+f*te,r[10]=g*_+x*L+m*W+f*ee,r[14]=g*E+x*X+m*V+f*se,r[3]=w*b+T*D+M*q+S*Q,r[7]=w*R+T*C+M*F+S*te,r[11]=w*_+T*L+M*W+S*ee,r[15]=w*E+T*X+M*V+S*se,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[12],a=e[1],o=e[5],l=e[9],c=e[13],h=e[2],u=e[6],d=e[10],p=e[14],g=e[3],x=e[7],m=e[11],f=e[15],w=l*p-c*d,T=o*p-c*u,M=o*d-l*u,S=a*p-c*h,b=a*d-l*h,R=a*u-o*h;return t*(x*w-m*T+f*M)-n*(g*w-m*S+f*b)+s*(g*T-x*S+f*R)-r*(g*M-x*b+m*R)}determinantAffine(){const e=this.elements,t=e[0],n=e[4],s=e[8],r=e[1],a=e[5],o=e[9],l=e[2],c=e[6],h=e[10];return t*(a*h-o*c)-n*(r*h-o*l)+s*(r*c-a*l)}transpose(){const e=this.elements;let t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,n){const s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=n),this}invert(){const e=this.elements,t=e[0],n=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],h=e[8],u=e[9],d=e[10],p=e[11],g=e[12],x=e[13],m=e[14],f=e[15],w=t*o-n*a,T=t*l-s*a,M=t*c-r*a,S=n*l-s*o,b=n*c-r*o,R=s*c-r*l,_=h*x-u*g,E=h*m-d*g,D=h*f-p*g,C=u*m-d*x,L=u*f-p*x,X=d*f-p*m,q=w*X-T*L+M*C+S*D-b*E+R*_;if(q===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const F=1/q;return e[0]=(o*X-l*L+c*C)*F,e[1]=(s*L-n*X-r*C)*F,e[2]=(x*R-m*b+f*S)*F,e[3]=(d*b-u*R-p*S)*F,e[4]=(l*D-a*X-c*E)*F,e[5]=(t*X-s*D+r*E)*F,e[6]=(m*M-g*R-f*T)*F,e[7]=(h*R-d*M+p*T)*F,e[8]=(a*L-o*D+c*_)*F,e[9]=(n*D-t*L-r*_)*F,e[10]=(g*b-x*M+f*w)*F,e[11]=(u*M-h*b-p*w)*F,e[12]=(o*E-a*C-l*_)*F,e[13]=(t*C-n*E+s*_)*F,e[14]=(x*T-g*S-m*w)*F,e[15]=(h*S-u*T+d*w)*F,this}scale(e){const t=this.elements,n=e.x,s=e.y,r=e.z;return t[0]*=n,t[4]*=s,t[8]*=r,t[1]*=n,t[5]*=s,t[9]*=r,t[2]*=n,t[6]*=s,t[10]*=r,t[3]*=n,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){const e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],n=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,n,s))}makeTranslation(e,t,n){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,n,0,0,0,1),this}makeRotationX(e){const t=Math.cos(e),n=Math.sin(e);return this.set(1,0,0,0,0,t,-n,0,0,n,t,0,0,0,0,1),this}makeRotationY(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,0,n,0,0,1,0,0,-n,0,t,0,0,0,0,1),this}makeRotationZ(e){const t=Math.cos(e),n=Math.sin(e);return this.set(t,-n,0,0,n,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){const n=Math.cos(t),s=Math.sin(t),r=1-n,a=e.x,o=e.y,l=e.z,c=r*a,h=r*o;return this.set(c*a+n,c*o-s*l,c*l+s*o,0,c*o+s*l,h*o+n,h*l-s*a,0,c*l-s*o,h*l+s*a,r*l*l+n,0,0,0,0,1),this}makeScale(e,t,n){return this.set(e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1),this}makeShear(e,t,n,s,r,a){return this.set(1,n,r,0,e,1,a,0,t,s,1,0,0,0,0,1),this}compose(e,t,n){const s=this.elements,r=t._x,a=t._y,o=t._z,l=t._w,c=r+r,h=a+a,u=o+o,d=r*c,p=r*h,g=r*u,x=a*h,m=a*u,f=o*u,w=l*c,T=l*h,M=l*u,S=n.x,b=n.y,R=n.z;return s[0]=(1-(x+f))*S,s[1]=(p+M)*S,s[2]=(g-T)*S,s[3]=0,s[4]=(p-M)*b,s[5]=(1-(d+f))*b,s[6]=(m+w)*b,s[7]=0,s[8]=(g+T)*R,s[9]=(m-w)*R,s[10]=(1-(d+x))*R,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,n){const s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),t.identity(),this;let a=Ji.set(s[0],s[1],s[2]).length();const o=Ji.set(s[4],s[5],s[6]).length(),l=Ji.set(s[8],s[9],s[10]).length();r<0&&(a=-a),fn.copy(this);const c=1/a,h=1/o,u=1/l;return fn.elements[0]*=c,fn.elements[1]*=c,fn.elements[2]*=c,fn.elements[4]*=h,fn.elements[5]*=h,fn.elements[6]*=h,fn.elements[8]*=u,fn.elements[9]*=u,fn.elements[10]*=u,t.setFromRotationMatrix(fn),n.x=a,n.y=o,n.z=l,this}makePerspective(e,t,n,s,r,a,o=Nn,l=!1){const c=this.elements,h=2*r/(t-e),u=2*r/(n-s),d=(t+e)/(t-e),p=(n+s)/(n-s);let g,x;if(l)g=r/(a-r),x=a*r/(a-r);else if(o===Nn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===dr)g=-a/(a-r),x=-a*r/(a-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=d,c[12]=0,c[1]=0,c[5]=u,c[9]=p,c[13]=0,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=-1,c[15]=0,this}makeOrthographic(e,t,n,s,r,a,o=Nn,l=!1){const c=this.elements,h=2/(t-e),u=2/(n-s),d=-(t+e)/(t-e),p=-(n+s)/(n-s);let g,x;if(l)g=1/(a-r),x=a/(a-r);else if(o===Nn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===dr)g=-1/(a-r),x=-r/(a-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+o);return c[0]=h,c[4]=0,c[8]=0,c[12]=d,c[1]=0,c[5]=u,c[9]=0,c[13]=p,c[2]=0,c[6]=0,c[10]=g,c[14]=x,c[3]=0,c[7]=0,c[11]=0,c[15]=1,this}equals(e){const t=this.elements,n=e.elements;for(let s=0;s<16;s++)if(t[s]!==n[s])return!1;return!0}fromArray(e,t=0){for(let n=0;n<16;n++)this.elements[n]=e[n+t];return this}toArray(e=[],t=0){const n=this.elements;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[15],e}}const Ji=new U,fn=new ht,Gp=new U(0,0,0),Hp=new U(1,1,1),ii=new U,wr=new U,Jt=new U,Ch=new ht,Dh=new Us;class xi{constructor(e=0,t=0,n=0,s=xi.DEFAULT_ORDER){this.isEuler=!0,this._x=e,this._y=t,this._z=n,this._order=s}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get order(){return this._order}set order(e){this._order=e,this._onChangeCallback()}set(e,t,n,s=this._order){return this._x=e,this._y=t,this._z=n,this._order=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._order)}copy(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this._onChangeCallback(),this}setFromRotationMatrix(e,t=this._order,n=!0){const s=e.elements,r=s[0],a=s[4],o=s[8],l=s[1],c=s[5],h=s[9],u=s[2],d=s[6],p=s[10];switch(t){case"XYZ":this._y=Math.asin(Ke(o,-1,1)),Math.abs(o)<.9999999?(this._x=Math.atan2(-h,p),this._z=Math.atan2(-a,r)):(this._x=Math.atan2(d,c),this._z=0);break;case"YXZ":this._x=Math.asin(-Ke(h,-1,1)),Math.abs(h)<.9999999?(this._y=Math.atan2(o,p),this._z=Math.atan2(l,c)):(this._y=Math.atan2(-u,r),this._z=0);break;case"ZXY":this._x=Math.asin(Ke(d,-1,1)),Math.abs(d)<.9999999?(this._y=Math.atan2(-u,p),this._z=Math.atan2(-a,c)):(this._y=0,this._z=Math.atan2(l,r));break;case"ZYX":this._y=Math.asin(-Ke(u,-1,1)),Math.abs(u)<.9999999?(this._x=Math.atan2(d,p),this._z=Math.atan2(l,r)):(this._x=0,this._z=Math.atan2(-a,c));break;case"YZX":this._z=Math.asin(Ke(l,-1,1)),Math.abs(l)<.9999999?(this._x=Math.atan2(-h,c),this._y=Math.atan2(-u,r)):(this._x=0,this._y=Math.atan2(o,p));break;case"XZY":this._z=Math.asin(-Ke(a,-1,1)),Math.abs(a)<.9999999?(this._x=Math.atan2(d,c),this._y=Math.atan2(o,r)):(this._x=Math.atan2(-h,p),this._y=0);break;default:Oe("Euler: .setFromRotationMatrix() encountered an unknown order: "+t)}return this._order=t,n===!0&&this._onChangeCallback(),this}setFromQuaternion(e,t,n){return Ch.makeRotationFromQuaternion(e),this.setFromRotationMatrix(Ch,t,n)}setFromVector3(e,t=this._order){return this.set(e.x,e.y,e.z,t)}reorder(e){return Dh.setFromEuler(this),this.setFromQuaternion(Dh,e)}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order}fromArray(e){return this._x=e[0],this._y=e[1],this._z=e[2],e[3]!==void 0&&(this._order=e[3]),this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._order}}xi.DEFAULT_ORDER="XYZ";class Fc{constructor(){this.mask=1}set(e){this.mask=(1<<e|0)>>>0}enable(e){this.mask|=1<<e|0}enableAll(){this.mask=-1}toggle(e){this.mask^=1<<e|0}disable(e){this.mask&=~(1<<e|0)}disableAll(){this.mask=0}test(e){return(this.mask&e.mask)!==0}isEnabled(e){return(this.mask&(1<<e|0))!==0}}let Vp=0;const Ph=new U,Qi=new Us,kn=new ht,Ar=new U,ks=new U,Wp=new U,Xp=new Us,Ih=new U(1,0,0),Lh=new U(0,1,0),Nh=new U(0,0,1),Uh={type:"added"},qp={type:"removed"},ji={type:"childadded",child:null},lo={type:"childremoved",child:null};class wt extends Xi{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:Vp++}),this.uuid=gi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=wt.DEFAULT_UP.clone();const e=new U,t=new xi,n=new Us,s=new U(1,1,1);function r(){n.setFromEuler(t,!1)}function a(){t.setFromQuaternion(n,void 0,!1)}t._onChange(r),n._onChange(a),Object.defineProperties(this,{position:{configurable:!0,enumerable:!0,value:e},rotation:{configurable:!0,enumerable:!0,value:t},quaternion:{configurable:!0,enumerable:!0,value:n},scale:{configurable:!0,enumerable:!0,value:s},modelViewMatrix:{value:new ht},normalMatrix:{value:new ze}}),this.matrix=new ht,this.matrixWorld=new ht,this.matrixAutoUpdate=wt.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new Fc,this.visible=!0,this.castShadow=!1,this.receiveShadow=!1,this.frustumCulled=!0,this.renderOrder=0,this.animations=[],this.customDepthMaterial=void 0,this.customDistanceMaterial=void 0,this.static=!1,this.userData={},this.pivot=null}onBeforeShadow(){}onAfterShadow(){}onBeforeRender(){}onAfterRender(){}applyMatrix4(e){this.matrixAutoUpdate&&this.updateMatrix(),this.matrix.premultiply(e),this.matrix.decompose(this.position,this.quaternion,this.scale)}applyQuaternion(e){return this.quaternion.premultiply(e),this}setRotationFromAxisAngle(e,t){this.quaternion.setFromAxisAngle(e,t)}setRotationFromEuler(e){this.quaternion.setFromEuler(e,!0)}setRotationFromMatrix(e){this.quaternion.setFromRotationMatrix(e)}setRotationFromQuaternion(e){this.quaternion.copy(e)}rotateOnAxis(e,t){return Qi.setFromAxisAngle(e,t),this.quaternion.multiply(Qi),this}rotateOnWorldAxis(e,t){return Qi.setFromAxisAngle(e,t),this.quaternion.premultiply(Qi),this}rotateX(e){return this.rotateOnAxis(Ih,e)}rotateY(e){return this.rotateOnAxis(Lh,e)}rotateZ(e){return this.rotateOnAxis(Nh,e)}translateOnAxis(e,t){return Ph.copy(e).applyQuaternion(this.quaternion),this.position.add(Ph.multiplyScalar(t)),this}translateX(e){return this.translateOnAxis(Ih,e)}translateY(e){return this.translateOnAxis(Lh,e)}translateZ(e){return this.translateOnAxis(Nh,e)}localToWorld(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(this.matrixWorld)}worldToLocal(e){return this.updateWorldMatrix(!0,!1),e.applyMatrix4(kn.copy(this.matrixWorld).invert())}lookAt(e,t,n){e.isVector3?Ar.copy(e):Ar.set(e,t,n);const s=this.parent;this.updateWorldMatrix(!0,!1),ks.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?kn.lookAt(ks,Ar,this.up):kn.lookAt(Ar,ks,this.up),this.quaternion.setFromRotationMatrix(kn),s&&(kn.extractRotation(s.matrixWorld),Qi.setFromRotationMatrix(kn),this.quaternion.premultiply(Qi.invert()))}add(e){if(arguments.length>1){for(let t=0;t<arguments.length;t++)this.add(arguments[t]);return this}return e===this?(qe("Object3D.add: object can't be added as a child of itself.",e),this):(e&&e.isObject3D?(e.removeFromParent(),e.parent=this,this.children.push(e),e.dispatchEvent(Uh),ji.child=e,this.dispatchEvent(ji),ji.child=null):qe("Object3D.add: object not an instance of THREE.Object3D.",e),this)}remove(e){if(arguments.length>1){for(let n=0;n<arguments.length;n++)this.remove(arguments[n]);return this}const t=this.children.indexOf(e);return t!==-1&&(e.parent=null,this.children.splice(t,1),e.dispatchEvent(qp),lo.child=e,this.dispatchEvent(lo),lo.child=null),this}removeFromParent(){const e=this.parent;return e!==null&&e.remove(this),this}clear(){return this.remove(...this.children)}attach(e){return this.updateWorldMatrix(!0,!1),kn.copy(this.matrixWorld).invert(),e.parent!==null&&(e.parent.updateWorldMatrix(!0,!1),kn.multiply(e.parent.matrixWorld)),e.applyMatrix4(kn),e.removeFromParent(),e.parent=this,this.children.push(e),e.updateWorldMatrix(!1,!0),e.dispatchEvent(Uh),ji.child=e,this.dispatchEvent(ji),ji.child=null,this}getObjectById(e){return this.getObjectByProperty("id",e)}getObjectByName(e){return this.getObjectByProperty("name",e)}getObjectByProperty(e,t){if(this[e]===t)return this;for(let n=0,s=this.children.length;n<s;n++){const a=this.children[n].getObjectByProperty(e,t);if(a!==void 0)return a}}getObjectsByProperty(e,t,n=[]){this[e]===t&&n.push(this);const s=this.children;for(let r=0,a=s.length;r<a;r++)s[r].getObjectsByProperty(e,t,n);return n}getWorldPosition(e){return this.updateWorldMatrix(!0,!1),e.setFromMatrixPosition(this.matrixWorld)}getWorldQuaternion(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ks,e,Wp),e}getWorldScale(e){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose(ks,Xp,e),e}getWorldDirection(e){this.updateWorldMatrix(!0,!1);const t=this.matrixWorld.elements;return e.set(t[8],t[9],t[10]).normalize()}raycast(){}traverse(e){e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverse(e)}traverseVisible(e){if(this.visible===!1)return;e(this);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].traverseVisible(e)}traverseAncestors(e){const t=this.parent;t!==null&&(e(t),t.traverseAncestors(e))}updateMatrix(){this.matrix.compose(this.position,this.quaternion,this.scale);const e=this.pivot;if(e!==null){const t=e.x,n=e.y,s=e.z,r=this.matrix.elements;r[12]+=t-r[0]*t-r[4]*n-r[8]*s,r[13]+=n-r[1]*t-r[5]*n-r[9]*s,r[14]+=s-r[2]*t-r[6]*n-r[10]*s}this.matrixWorldNeedsUpdate=!0}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(this.matrixWorldAutoUpdate===!0&&(this.parent===null?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);const t=this.children;for(let n=0,s=t.length;n<s;n++)t[n].updateMatrixWorld(e)}updateWorldMatrix(e,t,n=!1){const s=this.parent;if(e===!0&&s!==null&&s.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),t===!0){const r=this.children;for(let a=0,o=r.length;a<o;a++)r[a].updateWorldMatrix(!1,!0,n)}}toJSON(e){const t=e===void 0||typeof e=="string",n={};t&&(e={geometries:{},materials:{},textures:{},images:{},shapes:{},skeletons:{},animations:{},nodes:{}},n.metadata={version:4.7,type:"Object",generator:"Object3D.toJSON"});const s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,h=l.length;c<h;c++){const u=l[c];r(e.shapes,u)}else r(e.shapes,l)}}if(this.isSkinnedMesh&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(e.skeletons,this.skeleton),s.skeleton=this.skeleton.uuid)),this.material!==void 0)if(Array.isArray(this.material)){const o=[];for(let l=0,c=this.material.length;l<c;l++)o.push(r(e.materials,this.material[l]));s.material=o}else s.material=r(e.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(e).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const l=this.animations[o];s.animations.push(r(e.animations,l))}}if(t){const o=a(e.geometries),l=a(e.materials),c=a(e.textures),h=a(e.images),u=a(e.shapes),d=a(e.skeletons),p=a(e.animations),g=a(e.nodes);o.length>0&&(n.geometries=o),l.length>0&&(n.materials=l),c.length>0&&(n.textures=c),h.length>0&&(n.images=h),u.length>0&&(n.shapes=u),d.length>0&&(n.skeletons=d),p.length>0&&(n.animations=p),g.length>0&&(n.nodes=g)}return n.object=s,n;function a(o){const l=[];for(const c in o){const h=o[c];delete h.metadata,l.push(h)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let n=0;n<e.children.length;n++){const s=e.children[n];this.add(s.clone())}return this}}wt.DEFAULT_UP=new U(0,1,0);wt.DEFAULT_MATRIX_AUTO_UPDATE=!0;wt.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class xn extends wt{constructor(){super(),this.isGroup=!0,this.type="Group"}}const Yp={type:"move"};class co{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new xn,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 xn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new U,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new U),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new xn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new U,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new U,this._grip.eventsEnabled=!1),this._grip}dispatchEvent(e){return this._targetRay!==null&&this._targetRay.dispatchEvent(e),this._grip!==null&&this._grip.dispatchEvent(e),this._hand!==null&&this._hand.dispatchEvent(e),this}connect(e){if(e&&e.hand){const t=this._hand;if(t)for(const n of e.hand.values())this._getHandJoint(t,n)}return this.dispatchEvent({type:"connected",data:e}),this}disconnect(e){return this.dispatchEvent({type:"disconnected",data:e}),this._targetRay!==null&&(this._targetRay.visible=!1),this._grip!==null&&(this._grip.visible=!1),this._hand!==null&&(this._hand.visible=!1),this}update(e,t,n){let s=null,r=null,a=null;const o=this._targetRay,l=this._grip,c=this._hand;if(e&&t.session.visibilityState!=="visible-blurred"){if(c&&e.hand){a=!0;for(const x of e.hand.values()){const m=t.getJointPose(x,n),f=this._getHandJoint(c,x);m!==null&&(f.matrix.fromArray(m.transform.matrix),f.matrix.decompose(f.position,f.rotation,f.scale),f.matrixWorldNeedsUpdate=!0,f.jointRadius=m.radius),f.visible=m!==null}const h=c.joints["index-finger-tip"],u=c.joints["thumb-tip"],d=h.position.distanceTo(u.position),p=.02,g=.005;c.inputState.pinching&&d>p+g?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&d<=p-g&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,n),r!==null&&(l.matrix.fromArray(r.transform.matrix),l.matrix.decompose(l.position,l.rotation,l.scale),l.matrixWorldNeedsUpdate=!0,r.linearVelocity?(l.hasLinearVelocity=!0,l.linearVelocity.copy(r.linearVelocity)):l.hasLinearVelocity=!1,r.angularVelocity?(l.hasAngularVelocity=!0,l.angularVelocity.copy(r.angularVelocity)):l.hasAngularVelocity=!1,l.eventsEnabled&&l.dispatchEvent({type:"gripUpdated",data:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(Yp)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const n=new xn;n.matrixAutoUpdate=!1,n.visible=!1,e.joints[t.jointName]=n,e.add(n)}return e.joints[t.jointName]}}const Vd={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},si={h:0,s:0,l:0},Tr={h:0,s:0,l:0};function ho(i,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?i+(e-i)*6*t:t<1/2?e:t<2/3?i+(e-i)*6*(2/3-t):i}class xe{constructor(e,t,n){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,n)}set(e,t,n){if(t===void 0&&n===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,n);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=hn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,Ye.colorSpaceToWorking(this,t),this}setRGB(e,t,n,s=Ye.workingColorSpace){return this.r=e,this.g=t,this.b=n,Ye.colorSpaceToWorking(this,s),this}setHSL(e,t,n,s=Ye.workingColorSpace){if(e=Np(e,1),t=Ke(t,0,1),n=Ke(n,0,1),t===0)this.r=this.g=this.b=n;else{const r=n<=.5?n*(1+t):n+t-n*t,a=2*n-r;this.r=ho(a,r,e+1/3),this.g=ho(a,r,e),this.b=ho(a,r,e-1/3)}return Ye.colorSpaceToWorking(this,s),this}setStyle(e,t=hn){function n(r){r!==void 0&&parseFloat(r)<1&&Oe("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[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,t);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,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return n(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Oe("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Oe("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=hn){const n=Vd[e.toLowerCase()];return n!==void 0?this.setHex(n,t):Oe("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=$n(e.r),this.g=$n(e.g),this.b=$n(e.b),this}copyLinearToSRGB(e){return this.r=As(e.r),this.g=As(e.g),this.b=As(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=hn){return Ye.workingToColorSpace(Bt.copy(this),e),Math.round(Ke(Bt.r*255,0,255))*65536+Math.round(Ke(Bt.g*255,0,255))*256+Math.round(Ke(Bt.b*255,0,255))}getHexString(e=hn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=Ye.workingColorSpace){Ye.workingToColorSpace(Bt.copy(this),t);const n=Bt.r,s=Bt.g,r=Bt.b,a=Math.max(n,s,r),o=Math.min(n,s,r);let l,c;const h=(o+a)/2;if(o===a)l=0,c=0;else{const u=a-o;switch(c=h<=.5?u/(a+o):u/(2-a-o),a){case n:l=(s-r)/u+(s<r?6:0);break;case s:l=(r-n)/u+2;break;case r:l=(n-s)/u+4;break}l/=6}return e.h=l,e.s=c,e.l=h,e}getRGB(e,t=Ye.workingColorSpace){return Ye.workingToColorSpace(Bt.copy(this),t),e.r=Bt.r,e.g=Bt.g,e.b=Bt.b,e}getStyle(e=hn){Ye.workingToColorSpace(Bt.copy(this),e);const t=Bt.r,n=Bt.g,s=Bt.b;return e!==hn?`color(${e} ${t.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(e,t,n){return this.getHSL(si),this.setHSL(si.h+e,si.s+t,si.l+n)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,n){return this.r=e.r+(t.r-e.r)*n,this.g=e.g+(t.g-e.g)*n,this.b=e.b+(t.b-e.b)*n,this}lerpHSL(e,t){this.getHSL(si),e.getHSL(Tr);const n=io(si.h,Tr.h,t),s=io(si.s,Tr.s,t),r=io(si.l,Tr.l,t);return this.setHSL(n,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){const t=this.r,n=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*n+r[6]*s,this.g=r[1]*t+r[4]*n+r[7]*s,this.b=r[2]*t+r[5]*n+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b}}const Bt=new xe;xe.NAMES=Vd;class Oc{constructor(e,t=1,n=1e3){this.isFog=!0,this.name="",this.color=new xe(e),this.near=t,this.far=n}clone(){return new Oc(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class Wd extends wt{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 xi,this.environmentIntensity=1,this.environmentRotation=new xi,this.overrideMaterial=null,typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}copy(e,t){return super.copy(e,t),e.background!==null&&(this.background=e.background.clone()),e.environment!==null&&(this.environment=e.environment.clone()),e.fog!==null&&(this.fog=e.fog.clone()),this.backgroundBlurriness=e.backgroundBlurriness,this.backgroundIntensity=e.backgroundIntensity,this.backgroundRotation.copy(e.backgroundRotation),this.environmentIntensity=e.environmentIntensity,this.environmentRotation.copy(e.environmentRotation),e.overrideMaterial!==null&&(this.overrideMaterial=e.overrideMaterial.clone()),this.matrixAutoUpdate=e.matrixAutoUpdate,this}toJSON(e){const t=super.toJSON(e);return this.fog!==null&&(t.object.fog=this.fog.toJSON()),this.backgroundBlurriness>0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const pn=new U,Gn=new U,uo=new U,Hn=new U,es=new U,ts=new U,Fh=new U,fo=new U,po=new U,mo=new U,go=new ft,vo=new ft,_o=new ft;class un{constructor(e=new U,t=new U,n=new U){this.a=e,this.b=t,this.c=n}static getNormal(e,t,n,s){s.subVectors(n,t),pn.subVectors(e,t),s.cross(pn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,n,s,r){pn.subVectors(s,t),Gn.subVectors(n,t),uo.subVectors(e,t);const a=pn.dot(pn),o=pn.dot(Gn),l=pn.dot(uo),c=Gn.dot(Gn),h=Gn.dot(uo),u=a*c-o*o;if(u===0)return r.set(0,0,0),null;const d=1/u,p=(c*l-o*h)*d,g=(a*h-o*l)*d;return r.set(1-p-g,g,p)}static containsPoint(e,t,n,s){return this.getBarycoord(e,t,n,s,Hn)===null?!1:Hn.x>=0&&Hn.y>=0&&Hn.x+Hn.y<=1}static getInterpolation(e,t,n,s,r,a,o,l){return this.getBarycoord(e,t,n,s,Hn)===null?(l.x=0,l.y=0,"z"in l&&(l.z=0),"w"in l&&(l.w=0),null):(l.setScalar(0),l.addScaledVector(r,Hn.x),l.addScaledVector(a,Hn.y),l.addScaledVector(o,Hn.z),l)}static getInterpolatedAttribute(e,t,n,s,r,a){return go.setScalar(0),vo.setScalar(0),_o.setScalar(0),go.fromBufferAttribute(e,t),vo.fromBufferAttribute(e,n),_o.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(go,r.x),a.addScaledVector(vo,r.y),a.addScaledVector(_o,r.z),a}static isFrontFacing(e,t,n,s){return pn.subVectors(n,t),Gn.subVectors(e,t),pn.cross(Gn).dot(s)<0}set(e,t,n){return this.a.copy(e),this.b.copy(t),this.c.copy(n),this}setFromPointsAndIndices(e,t,n,s){return this.a.copy(e[t]),this.b.copy(e[n]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,n,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,n),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return pn.subVectors(this.c,this.b),Gn.subVectors(this.a,this.b),pn.cross(Gn).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return un.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return un.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,n,s,r){return un.getInterpolation(e,this.a,this.b,this.c,t,n,s,r)}containsPoint(e){return un.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return un.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const n=this.a,s=this.b,r=this.c;let a,o;es.subVectors(s,n),ts.subVectors(r,n),fo.subVectors(e,n);const l=es.dot(fo),c=ts.dot(fo);if(l<=0&&c<=0)return t.copy(n);po.subVectors(e,s);const h=es.dot(po),u=ts.dot(po);if(h>=0&&u<=h)return t.copy(s);const d=l*u-h*c;if(d<=0&&l>=0&&h<=0)return a=l/(l-h),t.copy(n).addScaledVector(es,a);mo.subVectors(e,r);const p=es.dot(mo),g=ts.dot(mo);if(g>=0&&p<=g)return t.copy(r);const x=p*c-l*g;if(x<=0&&c>=0&&g<=0)return o=c/(c-g),t.copy(n).addScaledVector(ts,o);const m=h*g-p*u;if(m<=0&&u-h>=0&&p-g>=0)return Fh.subVectors(r,s),o=(u-h)/(u-h+(p-g)),t.copy(s).addScaledVector(Fh,o);const f=1/(m+x+d);return a=x*f,o=d*f,t.copy(n).addScaledVector(es,a).addScaledVector(ts,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class fr{constructor(e=new U(1/0,1/0,1/0),t=new U(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t+=3)this.expandByPoint(mn.fromArray(e,t));return this}setFromBufferAttribute(e){this.makeEmpty();for(let t=0,n=e.count;t<n;t++)this.expandByPoint(mn.fromBufferAttribute(e,t));return this}setFromPoints(e){this.makeEmpty();for(let t=0,n=e.length;t<n;t++)this.expandByPoint(e[t]);return this}setFromCenterAndSize(e,t){const n=mn.copy(t).multiplyScalar(.5);return this.min.copy(e).sub(n),this.max.copy(e).add(n),this}setFromObject(e,t=!1){return this.makeEmpty(),this.expandByObject(e,t)}clone(){return new this.constructor().copy(this)}copy(e){return this.min.copy(e.min),this.max.copy(e.max),this}makeEmpty(){return this.min.x=this.min.y=this.min.z=1/0,this.max.x=this.max.y=this.max.z=-1/0,this}isEmpty(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z}getCenter(e){return this.isEmpty()?e.set(0,0,0):e.addVectors(this.min,this.max).multiplyScalar(.5)}getSize(e){return this.isEmpty()?e.set(0,0,0):e.subVectors(this.max,this.min)}expandByPoint(e){return this.min.min(e),this.max.max(e),this}expandByVector(e){return this.min.sub(e),this.max.add(e),this}expandByScalar(e){return this.min.addScalar(-e),this.max.addScalar(e),this}expandByObject(e,t=!1){e.updateWorldMatrix(!1,!1);const n=e.geometry;if(n!==void 0){const r=n.getAttribute("position");if(t===!0&&r!==void 0&&e.isInstancedMesh!==!0)for(let a=0,o=r.count;a<o;a++)e.isMesh===!0?e.getVertexPosition(a,mn):mn.fromBufferAttribute(r,a),mn.applyMatrix4(e.matrixWorld),this.expandByPoint(mn);else e.boundingBox!==void 0?(e.boundingBox===null&&e.computeBoundingBox(),Rr.copy(e.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),Rr.copy(n.boundingBox)),Rr.applyMatrix4(e.matrixWorld),this.union(Rr)}const s=e.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[r],t);return this}containsPoint(e){return e.x>=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,mn),mn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,n;return e.normal.x>0?(t=e.normal.x*this.min.x,n=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,n=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,n+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,n+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,n+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,n+=e.normal.z*this.min.z),t<=-e.constant&&n>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(Gs),Cr.subVectors(this.max,Gs),ns.subVectors(e.a,Gs),is.subVectors(e.b,Gs),ss.subVectors(e.c,Gs),ri.subVectors(is,ns),ai.subVectors(ss,is),bi.subVectors(ns,ss);let t=[0,-ri.z,ri.y,0,-ai.z,ai.y,0,-bi.z,bi.y,ri.z,0,-ri.x,ai.z,0,-ai.x,bi.z,0,-bi.x,-ri.y,ri.x,0,-ai.y,ai.x,0,-bi.y,bi.x,0];return!xo(t,ns,is,ss,Cr)||(t=[1,0,0,0,1,0,0,0,1],!xo(t,ns,is,ss,Cr))?!1:(Dr.crossVectors(ri,ai),t=[Dr.x,Dr.y,Dr.z],xo(t,ns,is,ss,Cr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,mn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(mn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(Vn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),Vn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),Vn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),Vn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),Vn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),Vn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),Vn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),Vn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(Vn),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const Vn=[new U,new U,new U,new U,new U,new U,new U,new U],mn=new U,Rr=new fr,ns=new U,is=new U,ss=new U,ri=new U,ai=new U,bi=new U,Gs=new U,Cr=new U,Dr=new U,wi=new U;function xo(i,e,t,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){wi.fromArray(i,r);const o=s.x*Math.abs(wi.x)+s.y*Math.abs(wi.y)+s.z*Math.abs(wi.z),l=e.dot(wi),c=t.dot(wi),h=n.dot(wi);if(Math.max(-Math.max(l,c,h),Math.min(l,c,h))>o)return!1}return!0}const Et=new U,Pr=new Fe;let Kp=0;class ct extends Xi{constructor(e,t,n=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:Kp++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=n,this.usage=Yl,this.updateRanges=[],this.gpuType=Ln,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,n){e*=this.itemSize,n*=t.itemSize;for(let s=0,r=this.itemSize;s<r;s++)this.array[e+s]=t.array[n+s];return this}copyArray(e){return this.array.set(e),this}applyMatrix3(e){if(this.itemSize===2)for(let t=0,n=this.count;t<n;t++)Pr.fromBufferAttribute(this,t),Pr.applyMatrix3(e),this.setXY(t,Pr.x,Pr.y);else if(this.itemSize===3)for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix3(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyMatrix4(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyMatrix4(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.applyNormalMatrix(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Et.fromBufferAttribute(this,t),Et.transformDirection(e),this.setXYZ(t,Et.x,Et.y,Et.z);return this}set(e,t=0){return this.array.set(e,t),this}getComponent(e,t){let n=this.array[e*this.itemSize+t];return this.normalized&&(n=In(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.array[e*this.itemSize+t]=n,this}getX(e){let t=this.array[e*this.itemSize];return this.normalized&&(t=In(t,this.array)),t}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize]=t,this}getY(e){let t=this.array[e*this.itemSize+1];return this.normalized&&(t=In(t,this.array)),t}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+1]=t,this}getZ(e){let t=this.array[e*this.itemSize+2];return this.normalized&&(t=In(t,this.array)),t}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+2]=t,this}getW(e){let t=this.array[e*this.itemSize+3];return this.normalized&&(t=In(t,this.array)),t}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.array[e*this.itemSize+3]=t,this}setXY(e,t,n){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.array[e+0]=t,this.array[e+1]=n,this}setXYZ(e,t,n,s){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),s=nt(s,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e*=this.itemSize,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),s=nt(s,this.array),r=nt(r,this.array)),this.array[e+0]=t,this.array[e+1]=n,this.array[e+2]=s,this.array[e+3]=r,this}onUpload(e){return this.onUploadCallback=e,this}clone(){return new this.constructor(this.array,this.itemSize).copy(this)}toJSON(){const e={itemSize:this.itemSize,type:this.array.constructor.name,array:Array.from(this.array),normalized:this.normalized};return this.name!==""&&(e.name=this.name),this.usage!==Yl&&(e.usage=this.usage),e}dispose(){this.dispatchEvent({type:"dispose"})}}class Xd extends ct{constructor(e,t,n){super(new Uint16Array(e),t,n)}}class qd extends ct{constructor(e,t,n){super(new Uint32Array(e),t,n)}}class At extends ct{constructor(e,t,n){super(new Float32Array(e),t,n)}}const Zp=new fr,Hs=new U,Mo=new U;class Ha{constructor(e=new U,t=-1){this.isSphere=!0,this.center=e,this.radius=t}set(e,t){return this.center.copy(e),this.radius=t,this}setFromPoints(e,t){const n=this.center;t!==void 0?n.copy(t):Zp.setFromPoints(e).getCenter(n);let s=0;for(let r=0,a=e.length;r<a;r++)s=Math.max(s,n.distanceToSquared(e[r]));return this.radius=Math.sqrt(s),this}copy(e){return this.center.copy(e.center),this.radius=e.radius,this}isEmpty(){return this.radius<0}makeEmpty(){return this.center.set(0,0,0),this.radius=-1,this}containsPoint(e){return e.distanceToSquared(this.center)<=this.radius*this.radius}distanceToPoint(e){return e.distanceTo(this.center)-this.radius}intersectsSphere(e){const t=this.radius+e.radius;return e.center.distanceToSquared(this.center)<=t*t}intersectsBox(e){return e.intersectsSphere(this)}intersectsPlane(e){return Math.abs(e.distanceToPoint(this.center))<=this.radius}clampPoint(e,t){const n=this.center.distanceToSquared(e);return t.copy(e),n>this.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;Hs.subVectors(e,this.center);const t=Hs.lengthSq();if(t>this.radius*this.radius){const n=Math.sqrt(t),s=(n-this.radius)*.5;this.center.addScaledVector(Hs,s/n),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Mo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(Hs.copy(e.center).add(Mo)),this.expandByPoint(Hs.copy(e.center).sub(Mo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let $p=0;const rn=new ht,yo=new wt,rs=new U,Qt=new fr,Vs=new fr,Dt=new U;class yt extends Xi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:$p++}),this.uuid=gi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(Dp(e)?qd:Xd)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,n=0){this.groups.push({start:e,count:t,materialIndex:n})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const n=this.attributes.normal;if(n!==void 0){const r=new ze().getNormalMatrix(e);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return rn.makeRotationFromQuaternion(e),this.applyMatrix4(rn),this}rotateX(e){return rn.makeRotationX(e),this.applyMatrix4(rn),this}rotateY(e){return rn.makeRotationY(e),this.applyMatrix4(rn),this}rotateZ(e){return rn.makeRotationZ(e),this.applyMatrix4(rn),this}translate(e,t,n){return rn.makeTranslation(e,t,n),this.applyMatrix4(rn),this}scale(e,t,n){return rn.makeScale(e,t,n),this.applyMatrix4(rn),this}lookAt(e){return yo.lookAt(e),yo.updateMatrix(),this.applyMatrix4(yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(rs).negate(),this.translate(rs.x,rs.y,rs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const n=[];for(let s=0,r=e.length;s<r;s++){const a=e[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new At(n,3))}else{const n=Math.min(e.length,t.count);for(let s=0;s<n;s++){const r=e[s];t.setXYZ(s,r.x,r.y,r.z||0)}e.length>t.count&&Oe("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new fr);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new U(-1/0,-1/0,-1/0),new U(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let n=0,s=t.length;n<s;n++){const r=t[n];Qt.setFromBufferAttribute(r),this.morphTargetsRelative?(Dt.addVectors(this.boundingBox.min,Qt.min),this.boundingBox.expandByPoint(Dt),Dt.addVectors(this.boundingBox.max,Qt.max),this.boundingBox.expandByPoint(Dt)):(this.boundingBox.expandByPoint(Qt.min),this.boundingBox.expandByPoint(Qt.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&qe('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 Ha);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){qe("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new U,1/0);return}if(e){const n=this.boundingSphere.center;if(Qt.setFromBufferAttribute(e),t)for(let r=0,a=t.length;r<a;r++){const o=t[r];Vs.setFromBufferAttribute(o),this.morphTargetsRelative?(Dt.addVectors(Qt.min,Vs.min),Qt.expandByPoint(Dt),Dt.addVectors(Qt.max,Vs.max),Qt.expandByPoint(Dt)):(Qt.expandByPoint(Vs.min),Qt.expandByPoint(Vs.max))}Qt.getCenter(n);let s=0;for(let r=0,a=e.count;r<a;r++)Dt.fromBufferAttribute(e,r),s=Math.max(s,n.distanceToSquared(Dt));if(t)for(let r=0,a=t.length;r<a;r++){const o=t[r],l=this.morphTargetsRelative;for(let c=0,h=o.count;c<h;c++)Dt.fromBufferAttribute(o,c),l&&(rs.fromBufferAttribute(e,c),Dt.add(rs)),s=Math.max(s,n.distanceToSquared(Dt))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&qe('BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}computeTangents(){const e=this.index,t=this.attributes;if(e===null||t.position===void 0||t.normal===void 0||t.uv===void 0){qe("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=t.position,s=t.normal,r=t.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new ct(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],l=[];for(let _=0;_<n.count;_++)o[_]=new U,l[_]=new U;const c=new U,h=new U,u=new U,d=new Fe,p=new Fe,g=new Fe,x=new U,m=new U;function f(_,E,D){c.fromBufferAttribute(n,_),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,_),p.fromBufferAttribute(r,E),g.fromBufferAttribute(r,D),h.sub(c),u.sub(c),p.sub(d),g.sub(d);const C=1/(p.x*g.y-g.x*p.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-p.y).multiplyScalar(C),m.copy(u).multiplyScalar(p.x).addScaledVector(h,-g.x).multiplyScalar(C),o[_].add(x),o[E].add(x),o[D].add(x),l[_].add(m),l[E].add(m),l[D].add(m))}let w=this.groups;w.length===0&&(w=[{start:0,count:e.count}]);for(let _=0,E=w.length;_<E;++_){const D=w[_],C=D.start,L=D.count;for(let X=C,q=C+L;X<q;X+=3)f(e.getX(X+0),e.getX(X+1),e.getX(X+2))}const T=new U,M=new U,S=new U,b=new U;function R(_){S.fromBufferAttribute(s,_),b.copy(S);const E=o[_];T.copy(E),T.sub(S.multiplyScalar(S.dot(E))).normalize(),M.crossVectors(b,E);const C=M.dot(l[_])<0?-1:1;a.setXYZW(_,T.x,T.y,T.z,C)}for(let _=0,E=w.length;_<E;++_){const D=w[_],C=D.start,L=D.count;for(let X=C,q=C+L;X<q;X+=3)R(e.getX(X+0)),R(e.getX(X+1)),R(e.getX(X+2))}this._transformed=!0}computeVertexNormals(){const e=this.index,t=this.getAttribute("position");if(t!==void 0){let n=this.getAttribute("normal");if(n===void 0||n.count!==t.count)n=new ct(new Float32Array(t.count*3),3),this.setAttribute("normal",n);else for(let d=0,p=n.count;d<p;d++)n.setXYZ(d,0,0,0);const s=new U,r=new U,a=new U,o=new U,l=new U,c=new U,h=new U,u=new U;if(e)for(let d=0,p=e.count;d<p;d+=3){const g=e.getX(d+0),x=e.getX(d+1),m=e.getX(d+2);s.fromBufferAttribute(t,g),r.fromBufferAttribute(t,x),a.fromBufferAttribute(t,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),l.fromBufferAttribute(n,x),c.fromBufferAttribute(n,m),o.add(h),l.add(h),c.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,l.x,l.y,l.z),n.setXYZ(m,c.x,c.y,c.z)}else for(let d=0,p=t.count;d<p;d+=3)s.fromBufferAttribute(t,d+0),r.fromBufferAttribute(t,d+1),a.fromBufferAttribute(t,d+2),h.subVectors(a,r),u.subVectors(s,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 e=this.attributes.normal;for(let t=0,n=e.count;t<n;t++)Dt.fromBufferAttribute(e,t),Dt.normalize(),e.setXYZ(t,Dt.x,Dt.y,Dt.z)}toNonIndexed(){function e(o,l){const c=o.array,h=o.itemSize,u=o.normalized,d=new c.constructor(l.length*h);let p=0,g=0;for(let x=0,m=l.length;x<m;x++){o.isInterleavedBufferAttribute?p=l[x]*o.data.stride+o.offset:p=l[x]*h;for(let f=0;f<h;f++)d[g++]=c[p++]}return new ct(d,h,u)}if(this.index===null)return Oe("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const t=new yt,n=this.index.array,s=this.attributes;for(const o in s){const l=s[o],c=e(l,n);t.setAttribute(o,c)}const r=this.morphAttributes;for(const o in r){const l=[],c=r[o];for(let h=0,u=c.length;h<u;h++){const d=c[h],p=e(d,n);l.push(p)}t.morphAttributes[o]=l}t.morphTargetsRelative=this.morphTargetsRelative;const a=this.groups;for(let o=0,l=a.length;o<l;o++){const c=a[o];t.addGroup(c.start,c.count,c.materialIndex)}return t}toJSON(){const e={metadata:{version:4.7,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.parameters!==void 0&&this._transformed===!0?"BufferGeometry":this.type,this.name!==""&&(e.name=this.name),Object.keys(this.userData).length>0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const n=this.attributes;for(const l in n){const c=n[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],h=[];for(let u=0,d=c.length;u<d;u++){const p=c[u];h.push(p.toJSON(e.data))}h.length>0&&(s[l]=h,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const n=e.index;n!==null&&this.setIndex(n.clone());const s=e.attributes;for(const c in s){const h=s[c];this.setAttribute(c,h.clone(t))}const r=e.morphAttributes;for(const c in r){const h=[],u=r[c];for(let d=0,p=u.length;d<p;d++)h.push(u[d].clone(t));this.morphAttributes[c]=h}this.morphTargetsRelative=e.morphTargetsRelative;const a=e.groups;for(let c=0,h=a.length;c<h;c++){const u=a[c];this.addGroup(u.start,u.count,u.materialIndex)}const o=e.boundingBox;o!==null&&(this.boundingBox=o.clone());const l=e.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.drawRange.start=e.drawRange.start,this.drawRange.count=e.drawRange.count,this.userData=e.userData,this._transformed=e._transformed,this}dispose(){this.dispatchEvent({type:"dispose"})}}class Jp{constructor(e,t){this.isInterleavedBuffer=!0,this.array=e,this.stride=t,this.count=e!==void 0?e.length/t:0,this.usage=Yl,this.updateRanges=[],this.version=0,this.uuid=gi()}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.array=new e.array.constructor(e.array),this.count=e.count,this.stride=e.stride,this.usage=e.usage,this}copyAt(e,t,n){e*=this.stride,n*=t.stride;for(let s=0,r=this.stride;s<r;s++)this.array[e+s]=t.array[n+s];return this}set(e,t=0){return this.array.set(e,t),this}clone(e){e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=this.array.slice(0).buffer);const t=new this.array.constructor(e.arrayBuffers[this.array.buffer._uuid]),n=new this.constructor(t,this.stride);return n.setUsage(this.usage),n}onUpload(e){return this.onUploadCallback=e,this}toJSON(e){return e.arrayBuffers===void 0&&(e.arrayBuffers={}),this.array.buffer._uuid===void 0&&(this.array.buffer._uuid=gi()),e.arrayBuffers[this.array.buffer._uuid]===void 0&&(e.arrayBuffers[this.array.buffer._uuid]=Array.from(new Uint32Array(this.array.buffer))),{uuid:this.uuid,buffer:this.array.buffer._uuid,type:this.array.constructor.name,stride:this.stride}}}const Wt=new U;class Da{constructor(e,t,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=e,this.itemSize=t,this.offset=n,this.normalized=s}get count(){return this.data.count}get array(){return this.data.array}set needsUpdate(e){this.data.needsUpdate=e}applyMatrix4(e){for(let t=0,n=this.data.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyMatrix4(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}applyNormalMatrix(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.applyNormalMatrix(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}transformDirection(e){for(let t=0,n=this.count;t<n;t++)Wt.fromBufferAttribute(this,t),Wt.transformDirection(e),this.setXYZ(t,Wt.x,Wt.y,Wt.z);return this}getComponent(e,t){let n=this.array[e*this.data.stride+this.offset+t];return this.normalized&&(n=In(n,this.array)),n}setComponent(e,t,n){return this.normalized&&(n=nt(n,this.array)),this.data.array[e*this.data.stride+this.offset+t]=n,this}setX(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset]=t,this}setY(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+1]=t,this}setZ(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+2]=t,this}setW(e,t){return this.normalized&&(t=nt(t,this.array)),this.data.array[e*this.data.stride+this.offset+3]=t,this}getX(e){let t=this.data.array[e*this.data.stride+this.offset];return this.normalized&&(t=In(t,this.array)),t}getY(e){let t=this.data.array[e*this.data.stride+this.offset+1];return this.normalized&&(t=In(t,this.array)),t}getZ(e){let t=this.data.array[e*this.data.stride+this.offset+2];return this.normalized&&(t=In(t,this.array)),t}getW(e){let t=this.data.array[e*this.data.stride+this.offset+3];return this.normalized&&(t=In(t,this.array)),t}setXY(e,t,n){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this}setXYZ(e,t,n,s){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),s=nt(s,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this}setXYZW(e,t,n,s,r){return e=e*this.data.stride+this.offset,this.normalized&&(t=nt(t,this.array),n=nt(n,this.array),s=nt(s,this.array),r=nt(r,this.array)),this.data.array[e+0]=t,this.data.array[e+1]=n,this.data.array[e+2]=s,this.data.array[e+3]=r,this}clone(e){if(e===void 0){Ca("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return new ct(new this.array.constructor(t),this.itemSize,this.normalized)}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.clone(e)),new Da(e.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(e){if(e===void 0){Ca("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const t=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)t.push(this.data.array[s+r])}return{itemSize:this.itemSize,type:this.array.constructor.name,array:t,normalized:this.normalized}}else return e.interleavedBuffers===void 0&&(e.interleavedBuffers={}),e.interleavedBuffers[this.data.uuid]===void 0&&(e.interleavedBuffers[this.data.uuid]=this.data.toJSON(e)),{isInterleavedBufferAttribute:!0,itemSize:this.itemSize,data:this.data.uuid,offset:this.offset,normalized:this.normalized}}}let Qp=0;class qi extends Xi{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:Qp++}),this.uuid=gi(),this.name="",this.type="Material",this.blending=bs,this.side=_i,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=rl,this.blendDst=al,this.blendEquation=Pi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new xe(0,0,0),this.blendAlpha=0,this.depthFunc=Ds,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Eh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=Zi,this.stencilZFail=Zi,this.stencilZPass=Zi,this.stencilWrite=!1,this.clippingPlanes=null,this.clipIntersection=!1,this.clipShadows=!1,this.shadowSide=null,this.colorWrite=!0,this.precision=null,this.polygonOffset=!1,this.polygonOffsetFactor=0,this.polygonOffsetUnits=0,this.dithering=!1,this.alphaToCoverage=!1,this.premultipliedAlpha=!1,this.forceSinglePass=!1,this.allowOverride=!0,this.visible=!0,this.toneMapped=!0,this.userData={},this.version=0,this._alphaTest=0}get alphaTest(){return this._alphaTest}set alphaTest(e){this._alphaTest>0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const n=e[t];if(n===void 0){Oe(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Oe(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.copy(n):this[t]=n}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={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(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(n.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(n.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,n.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(n.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(n.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).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(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(n.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).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(e).uuid),this.map&&this.map.isTexture&&(n.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(n.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(n.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(n.lightMap=this.lightMap.toJSON(e).uuid,n.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(n.aoMap=this.aoMap.toJSON(e).uuid,n.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(n.bumpMap=this.bumpMap.toJSON(e).uuid,n.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(n.normalMap=this.normalMap.toJSON(e).uuid,n.normalMapType=this.normalMapType,n.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(n.displacementMap=this.displacementMap.toJSON(e).uuid,n.displacementScale=this.displacementScale,n.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(n.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(n.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(n.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(n.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(n.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(n.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(n.envMap=this.envMap.toJSON(e).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(e).uuid),this.transmission!==void 0&&(n.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(n.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(n.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(n.thicknessMap=this.thicknessMap.toJSON(e).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!==bs&&(n.blending=this.blending),this.side!==_i&&(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!==rl&&(n.blendSrc=this.blendSrc),this.blendDst!==al&&(n.blendDst=this.blendDst),this.blendEquation!==Pi&&(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!==Ds&&(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!==Eh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==Zi&&(n.stencilFail=this.stencilFail),this.stencilZFail!==Zi&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==Zi&&(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 s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(n.textures=r),a.length>0&&(n.images=a)}return n}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new xe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let n=e.normalScale;Array.isArray(n)===!1&&(n=[n,n]),this.normalScale=new Fe().fromArray(n)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Fe().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let n=null;if(t!==null){const s=t.length;n=new Array(s);for(let r=0;r!==s;++r)n[r]=t[r].clone()}return this.clippingPlanes=n,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class er extends qi{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let as;const Ws=new U,os=new U,ls=new U,cs=new Fe,Xs=new Fe,Yd=new ht,Ir=new U,qs=new U,Lr=new U,Oh=new Fe,So=new Fe,zh=new Fe;class Nr extends wt{constructor(e=new er){if(super(),this.isSprite=!0,this.type="Sprite",as===void 0){as=new yt;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),n=new Jp(t,5);as.setIndex([0,1,2,0,2,3]),as.setAttribute("position",new Da(n,3,0,!1)),as.setAttribute("uv",new Da(n,2,3,!1))}this.geometry=as,this.material=e,this.center=new Fe(.5,.5),this.count=1}raycast(e,t){e.camera===null&&qe('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),os.setFromMatrixScale(this.matrixWorld),Yd.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),ls.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&os.multiplyScalar(-ls.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Ur(Ir.set(-.5,-.5,0),ls,a,os,s,r),Ur(qs.set(.5,-.5,0),ls,a,os,s,r),Ur(Lr.set(.5,.5,0),ls,a,os,s,r),Oh.set(0,0),So.set(1,0),zh.set(1,1);let o=e.ray.intersectTriangle(Ir,qs,Lr,!1,Ws);if(o===null&&(Ur(qs.set(-.5,.5,0),ls,a,os,s,r),So.set(0,1),o=e.ray.intersectTriangle(Ir,Lr,qs,!1,Ws),o===null))return;const l=e.ray.origin.distanceTo(Ws);l<e.near||l>e.far||t.push({distance:l,point:Ws.clone(),uv:un.getInterpolation(Ws,Ir,qs,Lr,Oh,So,zh,new Fe),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function Ur(i,e,t,n,s,r){cs.subVectors(i,t).addScalar(.5).multiply(n),s!==void 0?(Xs.x=r*cs.x-s*cs.y,Xs.y=s*cs.x+r*cs.y):Xs.copy(cs),i.copy(e),i.x+=Xs.x,i.y+=Xs.y,i.applyMatrix4(Yd)}const Wn=new U,Eo=new U,Fr=new U,oi=new U,bo=new U,Or=new U,wo=new U;class zc{constructor(e=new U,t=new U(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,Wn)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const n=t.dot(this.direction);return n<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,n)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=Wn.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(Wn.copy(this.origin).addScaledVector(this.direction,t),Wn.distanceToSquared(e))}distanceSqToSegment(e,t,n,s){Eo.copy(e).add(t).multiplyScalar(.5),Fr.copy(t).sub(e).normalize(),oi.copy(this.origin).sub(Eo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(Fr),o=oi.dot(this.direction),l=-oi.dot(Fr),c=oi.lengthSq(),h=Math.abs(1-a*a);let u,d,p,g;if(h>0)if(u=a*l-o,d=a*o-l,g=r*h,u>=0)if(d>=-g)if(d<=g){const x=1/h;u*=x,d*=x,p=u*(u+a*d+2*o)+d*(a*u+d+2*l)+c}else d=r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d=-r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;else d<=-g?(u=Math.max(0,-(-a*r+o)),d=u>0?-r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c):d<=g?(u=0,d=Math.min(Math.max(-r,-l),r),p=d*(d+2*l)+c):(u=Math.max(0,-(a*r+o)),d=u>0?r:Math.min(Math.max(-r,-l),r),p=-u*u+d*(d+2*l)+c);else d=a>0?-r:r,u=Math.max(0,-(a*d+o)),p=-u*u+d*(d+2*l)+c;return n&&n.copy(this.origin).addScaledVector(this.direction,u),s&&s.copy(Eo).addScaledVector(Fr,d),p}intersectSphere(e,t){Wn.subVectors(e.center,this.origin);const n=Wn.dot(this.direction),s=Wn.dot(Wn)-n*n,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=n-a,l=n+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const n=-(this.origin.dot(e.normal)+e.constant)/t;return n>=0?n:null}intersectPlane(e,t){const n=this.distanceToPlane(e);return n===null?null:this.at(n,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let n,s,r,a,o,l;const c=1/this.direction.x,h=1/this.direction.y,u=1/this.direction.z,d=this.origin;return c>=0?(n=(e.min.x-d.x)*c,s=(e.max.x-d.x)*c):(n=(e.max.x-d.x)*c,s=(e.min.x-d.x)*c),h>=0?(r=(e.min.y-d.y)*h,a=(e.max.y-d.y)*h):(r=(e.max.y-d.y)*h,a=(e.min.y-d.y)*h),n>a||r>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=a),u>=0?(o=(e.min.z-d.z)*u,l=(e.max.z-d.z)*u):(o=(e.max.z-d.z)*u,l=(e.min.z-d.z)*u),n>l||o>s)||((o>n||n!==n)&&(n=o),(l<s||s!==s)&&(s=l),s<0)?null:this.at(n>=0?n:s,t)}intersectsBox(e){return this.intersectBox(e,Wn)!==null}intersectTriangle(e,t,n,s,r){bo.subVectors(t,e),Or.subVectors(n,e),wo.crossVectors(bo,Or);let a=this.direction.dot(wo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;oi.subVectors(this.origin,e);const l=o*this.direction.dot(Or.crossVectors(oi,Or));if(l<0)return null;const c=o*this.direction.dot(bo.cross(oi));if(c<0||l+c>a)return null;const h=-o*oi.dot(wo);return h<0?null:this.at(h/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Hi extends qi{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new xe(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 xi,this.combine=Ac,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Bh=new ht,Ai=new zc,zr=new Ha,kh=new U,Br=new U,kr=new U,Gr=new U,Ao=new U,Hr=new U,Gh=new U,Vr=new U;class rt extends wt{constructor(e=new yt,t=new Hi){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(e,t){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;t.fromBufferAttribute(s,e);const o=this.morphTargetInfluences;if(r&&o){Hr.set(0,0,0);for(let l=0,c=r.length;l<c;l++){const h=o[l],u=r[l];h!==0&&(Ao.fromBufferAttribute(u,e),a?Hr.addScaledVector(Ao,h):Hr.addScaledVector(Ao.sub(t),h))}t.add(Hr)}return t}raycast(e,t){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),zr.copy(n.boundingSphere),zr.applyMatrix4(r),Ai.copy(e.ray).recast(e.near),!(zr.containsPoint(Ai.origin)===!1&&(Ai.intersectSphere(zr,kh)===null||Ai.origin.distanceToSquared(kh)>(e.far-e.near)**2))&&(Bh.copy(r).invert(),Ai.copy(e.ray).applyMatrix4(Bh),!(n.boundingBox!==null&&Ai.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(e,t,Ai)))}_computeIntersections(e,t,n){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,h=r.attributes.uv1,u=r.attributes.normal,d=r.groups,p=r.drawRange;if(o!==null)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],f=a[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(o.count,Math.min(m.start+m.count,p.start+p.count));for(let M=w,S=T;M<S;M+=3){const b=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);s=Wr(this,f,e,n,c,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),x=Math.min(o.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){const w=o.getX(m),T=o.getX(m+1),M=o.getX(m+2);s=Wr(this,a,e,n,c,h,u,w,T,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}else if(l!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],f=a[m.materialIndex],w=Math.max(m.start,p.start),T=Math.min(l.count,Math.min(m.start+m.count,p.start+p.count));for(let M=w,S=T;M<S;M+=3){const b=M,R=M+1,_=M+2;s=Wr(this,f,e,n,c,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,t.push(s))}}else{const g=Math.max(0,p.start),x=Math.min(l.count,p.start+p.count);for(let m=g,f=x;m<f;m+=3){const w=m,T=m+1,M=m+2;s=Wr(this,a,e,n,c,h,u,w,T,M),s&&(s.faceIndex=Math.floor(m/3),t.push(s))}}}}function jp(i,e,t,n,s,r,a,o){let l;if(e.side===Nt?l=n.intersectTriangle(a,r,s,!0,o):l=n.intersectTriangle(s,r,a,e.side===_i,o),l===null)return null;Vr.copy(o),Vr.applyMatrix4(i.matrixWorld);const c=t.ray.origin.distanceTo(Vr);return c<t.near||c>t.far?null:{distance:c,point:Vr.clone(),object:i}}function Wr(i,e,t,n,s,r,a,o,l,c){i.getVertexPosition(o,Br),i.getVertexPosition(l,kr),i.getVertexPosition(c,Gr);const h=jp(i,e,t,n,Br,kr,Gr,Gh);if(h){const u=new U;un.getBarycoord(Gh,Br,kr,Gr,u),s&&(h.uv=un.getInterpolatedAttribute(s,o,l,c,u,new Fe)),r&&(h.uv1=un.getInterpolatedAttribute(r,o,l,c,u,new Fe)),a&&(h.normal=un.getInterpolatedAttribute(a,o,l,c,u,new U),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:l,c,normal:new U,materialIndex:0};un.getNormal(Br,kr,Gr,d.normal),h.face=d,h.barycoord=u}return h}class em extends Vt{constructor(e=null,t=1,n=1,s,r,a,o,l,c=Ut,h=Ut,u,d){super(null,a,o,l,c,h,s,r,u,d),this.isDataTexture=!0,this.image={data:e,width:t,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const To=new U,tm=new U,nm=new ze;class Di{constructor(e=new U(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,n,s){return this.normal.set(e,t,n),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,n){const s=To.subVectors(n,t).cross(tm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,n=!0){const s=e.delta(To),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return n===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),n=this.distanceToPoint(e.end);return t<0&&n>0||n<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const n=t||nm.getNormalMatrix(e),s=this.coplanarPoint(To).applyMatrix4(e),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ti=new Ha,im=new Fe(.5,.5),Xr=new U;class Bc{constructor(e=new Di,t=new Di,n=new Di,s=new Di,r=new Di,a=new Di){this.planes=[e,t,n,s,r,a]}set(e,t,n,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(n),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let n=0;n<6;n++)t[n].copy(e.planes[n]);return this}setFromProjectionMatrix(e,t=Nn,n=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],h=r[4],u=r[5],d=r[6],p=r[7],g=r[8],x=r[9],m=r[10],f=r[11],w=r[12],T=r[13],M=r[14],S=r[15];if(s[0].setComponents(c-a,p-h,f-g,S-w).normalize(),s[1].setComponents(c+a,p+h,f+g,S+w).normalize(),s[2].setComponents(c+o,p+u,f+x,S+T).normalize(),s[3].setComponents(c-o,p-u,f-x,S-T).normalize(),n)s[4].setComponents(l,d,m,M).normalize(),s[5].setComponents(c-l,p-d,f-m,S-M).normalize();else if(s[4].setComponents(c-l,p-d,f-m,S-M).normalize(),t===Nn)s[5].setComponents(c+l,p+d,f+m,S+M).normalize();else if(t===dr)s[5].setComponents(l,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ti.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ti.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ti)}intersectsSprite(e){Ti.center.set(0,0,0);const t=im.distanceTo(e.center);return Ti.radius=.7071067811865476+t,Ti.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ti)}intersectsSphere(e){const t=this.planes,n=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(e){const t=this.planes;for(let n=0;n<6;n++){const s=t[n];if(Xr.x=s.normal.x>0?e.max.x:e.min.x,Xr.y=s.normal.y>0?e.max.y:e.min.y,Xr.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(Xr)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let n=0;n<6;n++)if(t[n].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Kd extends qi{constructor(e){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new xe(16777215),this.map=null,this.alphaMap=null,this.size=1,this.sizeAttenuation=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.size=e.size,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}const Hh=new ht,Zl=new zc,qr=new Ha,Yr=new U;class xa extends wt{constructor(e=new yt,t=new Kd){super(),this.isPoints=!0,this.type="Points",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}raycast(e,t){const n=this.geometry,s=this.matrixWorld,r=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),qr.copy(n.boundingSphere),qr.applyMatrix4(s),qr.radius+=r,e.ray.intersectsSphere(qr)===!1)return;Hh.copy(s).invert(),Zl.copy(e.ray).applyMatrix4(Hh);const o=r/((this.scale.x+this.scale.y+this.scale.z)/3),l=o*o,c=n.index,u=n.attributes.position;if(c!==null){const d=Math.max(0,a.start),p=Math.min(c.count,a.start+a.count);for(let g=d,x=p;g<x;g++){const m=c.getX(g);Yr.fromBufferAttribute(u,m),Vh(Yr,m,l,s,e,t,this)}}else{const d=Math.max(0,a.start),p=Math.min(u.count,a.start+a.count);for(let g=d,x=p;g<x;g++)Yr.fromBufferAttribute(u,g),Vh(Yr,g,l,s,e,t,this)}}updateMorphTargets(){const t=this.geometry.morphAttributes,n=Object.keys(t);if(n.length>0){const s=t[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function Vh(i,e,t,n,s,r,a){const o=Zl.distanceSqToPoint(i);if(o<t){const l=new U;Zl.closestPointToPoint(i,l),l.applyMatrix4(n);const c=s.ray.origin.distanceTo(l);if(c<s.near||c>s.far)return;r.push({distance:c,distanceToRay:Math.sqrt(o),point:l,index:e,face:null,faceIndex:null,barycoord:null,object:a})}}class Zd extends Vt{constructor(e=[],t=ki,n,s,r,a,o,l,c,h){super(e,t,n,s,r,a,o,l,c,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(e){this.image=e}}class jn extends Vt{constructor(e,t,n,s,r,a,o,l,c){super(e,t,n,s,r,a,o,l,c),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Is extends Vt{constructor(e,t,n=zn,s,r,a,o=Ut,l=Ut,c,h=Qn,u=1){if(h!==Qn&&h!==Fi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:e,height:t,depth:u};super(d,s,r,a,o,l,h,n,c),this.isDepthTexture=!0,this.flipY=!1,this.generateMipmaps=!1,this.compareFunction=null}copy(e){return super.copy(e),this.source=new Uc(Object.assign({},e.image)),this.compareFunction=e.compareFunction,this}toJSON(e){const t=super.toJSON(e);return this.compareFunction!==null&&(t.compareFunction=this.compareFunction),t}}class sm extends Is{constructor(e,t=zn,n=ki,s,r,a=Ut,o=Ut,l,c=Qn){const h={width:e,height:e,depth:1},u=[h,h,h,h,h,h];super(e,e,t,n,s,r,a,o,l,c),this.image=u,this.isCubeDepthTexture=!0,this.isCubeTexture=!0}get images(){return this.image}set images(e){this.image=e}}class $d extends Vt{constructor(e=null){super(),this.sourceTexture=e,this.isExternalTexture=!0}copy(e){return super.copy(e),this.sourceTexture=e.sourceTexture,this}}class dn extends yt{constructor(e=1,t=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:e,height:t,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),r=Math.floor(r),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0,p=0;g("z","y","x",-1,-1,n,t,e,a,r,0),g("z","y","x",1,-1,n,t,-e,a,r,1),g("x","z","y",1,1,e,n,t,s,a,2),g("x","z","y",1,-1,e,n,-t,s,a,3),g("x","y","z",1,-1,e,t,n,s,r,4),g("x","y","z",-1,-1,e,t,-n,s,r,5),this.setIndex(l),this.setAttribute("position",new At(c,3)),this.setAttribute("normal",new At(h,3)),this.setAttribute("uv",new At(u,2));function g(x,m,f,w,T,M,S,b,R,_,E){const D=M/R,C=S/_,L=M/2,X=S/2,q=b/2,F=R+1,W=_+1;let V=0,Q=0;const te=new U;for(let ee=0;ee<W;ee++){const se=ee*C-X;for(let ge=0;ge<F;ge++){const Ve=ge*D-L;te[x]=Ve*w,te[m]=se*T,te[f]=q,c.push(te.x,te.y,te.z),te[x]=0,te[m]=0,te[f]=b>0?1:-1,h.push(te.x,te.y,te.z),u.push(ge/R),u.push(1-ee/_),V+=1}}for(let ee=0;ee<_;ee++)for(let se=0;se<R;se++){const ge=d+se+F*ee,Ve=d+se+F*(ee+1),at=d+(se+1)+F*(ee+1),We=d+(se+1)+F*ee;l.push(ge,Ve,We),l.push(Ve,at,We),Q+=6}o.addGroup(p,Q,E),p+=Q,d+=V}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new dn(e.width,e.height,e.depth,e.widthSegments,e.heightSegments,e.depthSegments)}}class kc extends yt{constructor(e=1,t=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:e,segments:t,thetaStart:n,thetaLength:s},t=Math.max(3,t);const r=[],a=[],o=[],l=[],c=new U,h=new Fe;a.push(0,0,0),o.push(0,0,1),l.push(.5,.5);for(let u=0,d=3;u<=t;u++,d+=3){const p=n+u/t*s;c.x=e*Math.cos(p),c.y=e*Math.sin(p),a.push(c.x,c.y,c.z),o.push(0,0,1),h.x=(a[d]/e+1)/2,h.y=(a[d+1]/e+1)/2,l.push(h.x,h.y)}for(let u=1;u<=t;u++)r.push(u,u+1,0);this.setIndex(r),this.setAttribute("position",new At(a,3)),this.setAttribute("normal",new At(o,3)),this.setAttribute("uv",new At(l,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new kc(e.radius,e.segments,e.thetaStart,e.thetaLength)}}class yi extends yt{constructor(e=1,t=1,n=1,s=32,r=1,a=!1,o=0,l=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:e,radiusBottom:t,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:l};const c=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],p=[];let g=0;const x=[],m=n/2;let f=0;w(),a===!1&&(e>0&&T(!0),t>0&&T(!1)),this.setIndex(h),this.setAttribute("position",new At(u,3)),this.setAttribute("normal",new At(d,3)),this.setAttribute("uv",new At(p,2));function w(){const M=new U,S=new U;let b=0;const R=(t-e)/n;for(let _=0;_<=r;_++){const E=[],D=_/r,C=D*(t-e)+e;for(let L=0;L<=s;L++){const X=L/s,q=X*l+o,F=Math.sin(q),W=Math.cos(q);S.x=C*F,S.y=-D*n+m,S.z=C*W,u.push(S.x,S.y,S.z),M.set(F,R,W).normalize(),d.push(M.x,M.y,M.z),p.push(X,1-D),E.push(g++)}x.push(E)}for(let _=0;_<s;_++)for(let E=0;E<r;E++){const D=x[E][_],C=x[E+1][_],L=x[E+1][_+1],X=x[E][_+1];(e>0||E!==0)&&(h.push(D,C,X),b+=3),(t>0||E!==r-1)&&(h.push(C,L,X),b+=3)}c.addGroup(f,b,0),f+=b}function T(M){const S=g,b=new Fe,R=new U;let _=0;const E=M===!0?e:t,D=M===!0?1:-1;for(let L=1;L<=s;L++)u.push(0,m*D,0),d.push(0,D,0),p.push(.5,.5),g++;const C=g;for(let L=0;L<=s;L++){const q=L/s*l+o,F=Math.cos(q),W=Math.sin(q);R.x=E*W,R.y=m*D,R.z=E*F,u.push(R.x,R.y,R.z),d.push(0,D,0),b.x=F*.5+.5,b.y=W*.5*D+.5,p.push(b.x,b.y),g++}for(let L=0;L<s;L++){const X=S+L,q=C+L;M===!0?h.push(q,q+1,X):h.push(q+1,q,X),_+=3}c.addGroup(f,_,M===!0?1:2),f+=_}}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new yi(e.radiusTop,e.radiusBottom,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Va extends yi{constructor(e=1,t=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,e,t,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:e,height:t,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(e){return new Va(e.radius,e.height,e.radialSegments,e.heightSegments,e.openEnded,e.thetaStart,e.thetaLength)}}class Fs extends yt{constructor(e=1,t=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:e,height:t,widthSegments:n,heightSegments:s};const r=e/2,a=t/2,o=Math.floor(n),l=Math.floor(s),c=o+1,h=l+1,u=e/o,d=t/l,p=[],g=[],x=[],m=[];for(let f=0;f<h;f++){const w=f*d-a;for(let T=0;T<c;T++){const M=T*u-r;g.push(M,-w,0),x.push(0,0,1),m.push(T/o),m.push(1-f/l)}}for(let f=0;f<l;f++)for(let w=0;w<o;w++){const T=w+c*f,M=w+c*(f+1),S=w+1+c*(f+1),b=w+1+c*f;p.push(T,M,b),p.push(M,S,b)}this.setIndex(p),this.setAttribute("position",new At(g,3)),this.setAttribute("normal",new At(x,3)),this.setAttribute("uv",new At(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Fs(e.width,e.height,e.widthSegments,e.heightSegments)}}class Bn extends yt{constructor(e=1,t=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:e,widthSegments:t,heightSegments:n,phiStart:s,phiLength:r,thetaStart:a,thetaLength:o},t=Math.max(3,Math.floor(t)),n=Math.max(2,Math.floor(n));const l=Math.min(a+o,Math.PI);let c=0;const h=[],u=new U,d=new U,p=[],g=[],x=[],m=[];for(let f=0;f<=n;f++){const w=[],T=f/n,M=a+T*o,S=e*Math.cos(M),b=Math.sqrt(e*e-S*S);let R=0;f===0&&a===0?R=.5/t:f===n&&l===Math.PI&&(R=-.5/t);for(let _=0;_<=t;_++){const E=_/t,D=s+E*r;u.x=-b*Math.cos(D),u.y=S,u.z=b*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(E+R,1-T),w.push(c++)}h.push(w)}for(let f=0;f<n;f++)for(let w=0;w<t;w++){const T=h[f][w+1],M=h[f][w],S=h[f+1][w],b=h[f+1][w+1];(f!==0||a>0)&&p.push(T,M,b),(f!==n-1||l<Math.PI)&&p.push(M,S,b)}this.setIndex(p),this.setAttribute("position",new At(g,3)),this.setAttribute("normal",new At(x,3)),this.setAttribute("uv",new At(m,2))}copy(e){return super.copy(e),this.parameters=Object.assign({},e.parameters),this}static fromJSON(e){return new Bn(e.radius,e.widthSegments,e.heightSegments,e.phiStart,e.phiLength,e.thetaStart,e.thetaLength)}}function Ls(i){const e={};for(const t in i){e[t]={};for(const n in i[t]){const s=i[t][n];if(Wh(s))s.isRenderTargetTexture?(Oe("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][n]=null):e[t][n]=s.clone();else if(Array.isArray(s))if(Wh(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();e[t][n]=r}else e[t][n]=s.slice();else e[t][n]=s}}return e}function Xt(i){const e={};for(let t=0;t<i.length;t++){const n=Ls(i[t]);for(const s in n)e[s]=n[s]}return e}function Wh(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function rm(i){const e=[];for(let t=0;t<i.length;t++)e.push(i[t].clone());return e}function Jd(i){const e=i.getRenderTarget();return e===null?i.outputColorSpace:e.isXRRenderTarget===!0?e.texture.colorSpace:Ye.workingColorSpace}const am={clone:Ls,merge:Xt};var om=`void main() {
|
|
567
|
+
*/const Bl="185",mp=0,Nh=1,gp=2,gr=1,vp=2,lr=3,Ti=0,Ce=1,wn=2,si=0,Is=1,Ri=2,Uh=3,Fh=4,_p=5,Gi=100,xp=101,Mp=102,yp=103,Sp=104,Ep=200,bp=201,wp=202,Ap=203,_c=204,xc=205,Tp=206,Rp=207,Cp=208,Dp=209,Pp=210,Ip=211,Lp=212,Np=213,Up=214,Mc=0,yc=1,Sc=2,ks=3,Ec=4,bc=5,wc=6,Ac=7,kl=0,Fp=1,Op=2,qn=0,Vd=1,Wd=2,Xd=3,qd=4,Yd=5,Kd=6,Zd=7,$d=300,Zi=301,Gs=302,fo=303,po=304,to=306,Tc=1e3,hn=1001,Rc=1002,ke=1003,zp=1004,Fr=1005,Te=1006,mo=1007,Xi=1008,ln=1009,Jd=1010,Qd=1011,yr=1012,Gl=1013,Kn=1014,Vn=1015,xn=1016,Hl=1017,Vl=1018,Sr=1020,jd=35902,t0=35899,e0=1021,n0=1022,un=1023,ai=1026,qi=1027,i0=1028,Wl=1029,$i=1030,Xl=1031,ql=1033,Ta=33776,Ra=33777,Ca=33778,Da=33779,Cc=35840,Dc=35841,Pc=35842,Ic=35843,Lc=36196,Nc=37492,Uc=37496,Fc=37488,Oc=37489,Fa=37490,zc=37491,Bc=37808,kc=37809,Gc=37810,Hc=37811,Vc=37812,Wc=37813,Xc=37814,qc=37815,Yc=37816,Kc=37817,Zc=37818,$c=37819,Jc=37820,Qc=37821,jc=36492,tl=36494,el=36495,nl=36283,il=36284,Oa=36285,sl=36286,Bp=3200,rl=0,kp=1,Si="",vn="srgb",za="srgb-linear",Ba="linear",te="srgb",ss=7680,Oh=519,Gp=512,Hp=513,Vp=514,Yl=515,Wp=516,Xp=517,Kl=518,qp=519,al=35044,zh="300 es",Wn=2e3,Er=2001;function Yp(i){for(let t=i.length-1;t>=0;--t)if(i[t]>=65535)return!0;return!1}function ka(i){return document.createElementNS("http://www.w3.org/1999/xhtml",i)}function Kp(){const i=ka("canvas");return i.style.display="block",i}const Bh={};function Ga(...i){const t="THREE."+i.shift();console.log(t,...i)}function s0(i){const t=i[0];if(typeof t=="string"&&t.startsWith("TSL:")){const e=i[1];e&&e.isStackTrace?i[0]+=" "+e.getLocation():i[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return i}function Ot(...i){i=s0(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.warn(e.getError(t)):console.warn(t,...i)}}function Yt(...i){i=s0(i);const t="THREE."+i.shift();{const e=i[0];e&&e.isStackTrace?console.error(e.getError(t)):console.error(t,...i)}}function Ls(...i){const t=i.join(" ");t in Bh||(Bh[t]=!0,Ot(...i))}function Zp(i,t,e){return new Promise(function(n,s){function r(){switch(i.clientWaitSync(t,i.SYNC_FLUSH_COMMANDS_BIT,0)){case i.WAIT_FAILED:s();break;case i.TIMEOUT_EXPIRED:setTimeout(r,e);break;default:n()}}setTimeout(r,e)})}const $p={[Mc]:yc,[Sc]:wc,[Ec]:Ac,[ks]:bc,[yc]:Mc,[wc]:Sc,[Ac]:Ec,[bc]:ks};class ts{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 s=n[t];if(s!==void 0){const r=s.indexOf(e);r!==-1&&s.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 s=n.slice(0);for(let r=0,a=s.length;r<a;r++)s[r].call(this,t);t.target=null}}}const He=["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"],go=Math.PI/180,ol=180/Math.PI;function wi(){const i=Math.random()*4294967295|0,t=Math.random()*4294967295|0,e=Math.random()*4294967295|0,n=Math.random()*4294967295|0;return(He[i&255]+He[i>>8&255]+He[i>>16&255]+He[i>>24&255]+"-"+He[t&255]+He[t>>8&255]+"-"+He[t>>16&15|64]+He[t>>24&255]+"-"+He[e&63|128]+He[e>>8&255]+"-"+He[e>>16&255]+He[e>>24&255]+He[n&255]+He[n>>8&255]+He[n>>16&255]+He[n>>24&255]).toLowerCase()}function Xt(i,t,e){return Math.max(t,Math.min(e,i))}function Jp(i,t){return(i%t+t)%t}function vo(i,t,e){return(1-e)*i+e*t}function Hn(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return i/4294967295;case Uint16Array:return i/65535;case Uint8Array:return i/255;case Int32Array:return Math.max(i/2147483647,-1);case Int16Array:return Math.max(i/32767,-1);case Int8Array:return Math.max(i/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function ie(i,t){switch(t.constructor){case Float32Array:return i;case Uint32Array:return Math.round(i*4294967295);case Uint16Array:return Math.round(i*65535);case Uint8Array:return Math.round(i*255);case Int32Array:return Math.round(i*2147483647);case Int16Array:return Math.round(i*32767);case Int8Array:return Math.round(i*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}class Ft{static{Ft.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,s=t.elements;return this.x=s[0]*e+s[3]*n+s[6],this.y=s[1]*e+s[4]*n+s[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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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(Xt(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),s=Math.sin(e),r=this.x-t.x,a=this.y-t.y;return this.x=r*n-a*s+t.x,this.y=r*s+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 Xs{constructor(t=0,e=0,n=0,s=1){this.isQuaternion=!0,this._x=t,this._y=e,this._z=n,this._w=s}static slerpFlat(t,e,n,s,r,a,o){let c=n[s+0],l=n[s+1],h=n[s+2],u=n[s+3],d=r[a+0],f=r[a+1],g=r[a+2],x=r[a+3];if(u!==x||c!==d||l!==f||h!==g){let m=c*d+l*f+h*g+u*x;m<0&&(d=-d,f=-f,g=-g,x=-x,m=-m);let p=1-o;if(m<.9995){const w=Math.acos(m),A=Math.sin(w);p=Math.sin(p*w)/A,o=Math.sin(o*w)/A,c=c*p+d*o,l=l*p+f*o,h=h*p+g*o,u=u*p+x*o}else{c=c*p+d*o,l=l*p+f*o,h=h*p+g*o,u=u*p+x*o;const w=1/Math.sqrt(c*c+l*l+h*h+u*u);c*=w,l*=w,h*=w,u*=w}}t[e]=c,t[e+1]=l,t[e+2]=h,t[e+3]=u}static multiplyQuaternionsFlat(t,e,n,s,r,a){const o=n[s],c=n[s+1],l=n[s+2],h=n[s+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,s){return this._x=t,this._y=e,this._z=n,this._w=s,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,s=t._y,r=t._z,a=t._order,o=Math.cos,c=Math.sin,l=o(n/2),h=o(s/2),u=o(r/2),d=c(n/2),f=c(s/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:Ot("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return e===!0&&this._onChangeCallback(),this}setFromAxisAngle(t,e){const n=e/2,s=Math.sin(n);return this._x=t.x*s,this._y=t.y*s,this._z=t.z*s,this._w=Math.cos(n),this._onChangeCallback(),this}setFromRotationMatrix(t){const e=t.elements,n=e[0],s=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-s)*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=(s+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=(s+a)/f,this._y=.25*f,this._z=(c+h)/f}else{const f=2*Math.sqrt(1+u-n-o);this._w=(a-s)/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(Xt(this.dot(t),-1,1)))}rotateTowards(t,e){const n=this.angleTo(t);if(n===0)return this;const s=Math.min(1,e/n);return this.slerp(t,s),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,s=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+s*l-r*c,this._y=s*h+a*c+r*o-n*l,this._z=r*h+a*l+n*c-s*o,this._w=a*h-n*o-s*c-r*l,this._onChangeCallback(),this}slerp(t,e){let n=t._x,s=t._y,r=t._z,a=t._w,o=this.dot(t);o<0&&(n=-n,s=-s,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+s*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+s*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(),s=Math.sqrt(1-n),r=Math.sqrt(n);return this.set(s*Math.sin(t),s*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 F{static{F.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(kh.setFromEuler(t))}applyAxisAngle(t,e){return this.applyQuaternion(kh.setFromAxisAngle(t,e))}applyMatrix3(t){const e=this.x,n=this.y,s=this.z,r=t.elements;return this.x=r[0]*e+r[3]*n+r[6]*s,this.y=r[1]*e+r[4]*n+r[7]*s,this.z=r[2]*e+r[5]*n+r[8]*s,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const e=this.x,n=this.y,s=this.z,r=t.elements,a=1/(r[3]*e+r[7]*n+r[11]*s+r[15]);return this.x=(r[0]*e+r[4]*n+r[8]*s+r[12])*a,this.y=(r[1]*e+r[5]*n+r[9]*s+r[13])*a,this.z=(r[2]*e+r[6]*n+r[10]*s+r[14])*a,this}applyQuaternion(t){const e=this.x,n=this.y,s=this.z,r=t.x,a=t.y,o=t.z,c=t.w,l=2*(a*s-o*n),h=2*(o*e-r*s),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=s+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,s=this.z,r=t.elements;return this.x=r[0]*e+r[4]*n+r[8]*s,this.y=r[1]*e+r[5]*n+r[9]*s,this.z=r[2]*e+r[6]*n+r[10]*s,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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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,s=t.y,r=t.z,a=e.x,o=e.y,c=e.z;return this.x=s*c-r*o,this.y=r*a-n*c,this.z=n*o-s*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 _o.copy(this).projectOnVector(t),this.sub(_o)}reflect(t){return this.sub(_o.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(Xt(n,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const e=this.x-t.x,n=this.y-t.y,s=this.z-t.z;return e*e+n*n+s*s}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 s=Math.sin(e)*t;return this.x=s*Math.sin(n),this.y=Math.cos(e)*t,this.z=s*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(),s=this.setFromMatrixColumn(t,2).length();return this.x=e,this.y=n,this.z=s,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 _o=new F,kh=new Xs;class zt{static{zt.prototype.isMatrix3=!0}constructor(t,e,n,s,r,a,o,c,l){this.elements=[1,0,0,0,1,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l)}set(t,e,n,s,r,a,o,c,l){const h=this.elements;return h[0]=t,h[1]=s,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,s=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],x=s[0],m=s[3],p=s[6],w=s[1],A=s[4],M=s[7],S=s[2],b=s[5],R=s[8];return r[0]=a*x+o*w+c*S,r[3]=a*m+o*A+c*b,r[6]=a*p+o*M+c*R,r[1]=l*x+h*w+u*S,r[4]=l*m+h*A+u*b,r[7]=l*p+h*M+u*R,r[2]=d*x+f*w+g*S,r[5]=d*m+f*A+g*b,r[8]=d*p+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],s=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+s*r*l-s*a*c}invert(){const t=this.elements,e=t[0],n=t[1],s=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+s*f;if(g===0)return this.set(0,0,0,0,0,0,0,0,0);const x=1/g;return t[0]=u*x,t[1]=(s*l-h*n)*x,t[2]=(o*n-s*a)*x,t[3]=d*x,t[4]=(h*e-s*c)*x,t[5]=(s*r-o*e)*x,t[6]=f*x,t[7]=(n*c-l*e)*x,t[8]=(a*e-n*r)*x,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,s,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,-s*l,s*c,-s*(-l*a+c*o)+o+e,0,0,1),this}scale(t,e){return Ls("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(xo.makeScale(t,e)),this}rotate(t){return Ls("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(xo.makeRotation(-t)),this}translate(t,e){return Ls("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(xo.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 s=0;s<9;s++)if(e[s]!==n[s])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 xo=new zt,Gh=new zt().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Hh=new zt().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function Qp(){const i={enabled:!0,workingColorSpace:za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===te&&(s.r=ri(s.r),s.g=ri(s.g),s.b=ri(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===te&&(s.r=Ns(s.r),s.g=Ns(s.g),s.b=Ns(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===Si?Ba:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Ls("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),i.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Ls("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),i.colorSpaceToWorking(s,r)}},t=[.64,.33,.3,.6,.15,.06],e=[.2126,.7152,.0722],n=[.3127,.329];return i.define({[za]:{primaries:t,whitePoint:n,transfer:Ba,toXYZ:Gh,fromXYZ:Hh,luminanceCoefficients:e,workingColorSpaceConfig:{unpackColorSpace:vn},outputColorSpaceConfig:{drawingBufferColorSpace:vn}},[vn]:{primaries:t,whitePoint:n,transfer:te,toXYZ:Gh,fromXYZ:Hh,luminanceCoefficients:e,outputColorSpaceConfig:{drawingBufferColorSpace:vn}}}),i}const Kt=Qp();function ri(i){return i<.04045?i*.0773993808:Math.pow(i*.9478672986+.0521327014,2.4)}function Ns(i){return i<.0031308?i*12.92:1.055*Math.pow(i,.41666)-.055}let rs;class jp{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{rs===void 0&&(rs=ka("canvas")),rs.width=t.width,rs.height=t.height;const s=rs.getContext("2d");t instanceof ImageData?s.putImageData(t,0,0):s.drawImage(t,0,0,t.width,t.height),n=rs}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=ka("canvas");e.width=t.width,e.height=t.height;const n=e.getContext("2d");n.drawImage(t,0,0,t.width,t.height);const s=n.getImageData(0,0,t.width,t.height),r=s.data;for(let a=0;a<r.length;a++)r[a]=ri(r[a]/255)*255;return n.putImageData(s,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(ri(e[n]/255)*255):e[n]=ri(e[n]);return{data:e,width:t.width,height:t.height}}else return Ot("ImageUtils.sRGBToLinear(): Unsupported image type. No color space conversion applied."),t}}let tm=0;class Zl{constructor(t=null){this.isSource=!0,Object.defineProperty(this,"id",{value:tm++}),this.uuid=wi(),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:""},s=this.data;if(s!==null){let r;if(Array.isArray(s)){r=[];for(let a=0,o=s.length;a<o;a++)s[a].isDataTexture?r.push(Mo(s[a].image)):r.push(Mo(s[a]))}else r=Mo(s);n.url=r}return e||(t.images[this.uuid]=n),n}}function Mo(i){return typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&i instanceof ImageBitmap?jp.getDataURL(i):i.data?{data:Array.from(i.data),width:i.width,height:i.height,type:i.data.constructor.name}:(Ot("Texture: Unable to serialize Texture."),{})}let em=0;const yo=new F;class qe extends ts{constructor(t=qe.DEFAULT_IMAGE,e=qe.DEFAULT_MAPPING,n=hn,s=hn,r=Te,a=Xi,o=un,c=ln,l=qe.DEFAULT_ANISOTROPY,h=Si){super(),this.isTexture=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=wi(),this.name="",this.source=new Zl(t),this.mipmaps=[],this.mapping=e,this.channel=0,this.wrapS=n,this.wrapT=s,this.magFilter=r,this.minFilter=a,this.anisotropy=l,this.format=o,this.internalFormat=null,this.type=c,this.offset=new Ft(0,0),this.repeat=new Ft(1,1),this.center=new Ft(0,0),this.rotation=0,this.matrixAutoUpdate=!0,this.matrix=new zt,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(yo).x}get height(){return this.source.getSize(yo).y}get depth(){return this.source.getSize(yo).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){Ot(`Texture.setValues(): parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`Texture.setValues(): property '${e}' does not exist.`);continue}s&&n&&s.isVector2&&n.isVector2||s&&n&&s.isVector3&&n.isVector3||s&&n&&s.isMatrix3&&n.isMatrix3?s.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!==$d)return t;if(t.applyMatrix3(this.matrix),t.x<0||t.x>1)switch(this.wrapS){case Tc:t.x=t.x-Math.floor(t.x);break;case hn:t.x=t.x<0?0:1;break;case Rc: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 Tc:t.y=t.y-Math.floor(t.y);break;case hn:t.y=t.y<0?0:1;break;case Rc: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++}}qe.DEFAULT_IMAGE=null;qe.DEFAULT_MAPPING=$d;qe.DEFAULT_ANISOTROPY=1;class pe{static{pe.prototype.isVector4=!0}constructor(t=0,e=0,n=0,s=1){this.x=t,this.y=e,this.z=n,this.w=s}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,s){return this.x=t,this.y=e,this.z=n,this.w=s,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,s=this.z,r=this.w,a=t.elements;return this.x=a[0]*e+a[4]*n+a[8]*s+a[12]*r,this.y=a[1]*e+a[5]*n+a[9]*s+a[13]*r,this.z=a[2]*e+a[6]*n+a[10]*s+a[14]*r,this.w=a[3]*e+a[7]*n+a[11]*s+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,s,r;const c=t.elements,l=c[0],h=c[4],u=c[8],d=c[1],f=c[5],g=c[9],x=c[2],m=c[6],p=c[10];if(Math.abs(h-d)<.01&&Math.abs(u-x)<.01&&Math.abs(g-m)<.01){if(Math.abs(h+d)<.1&&Math.abs(u+x)<.1&&Math.abs(g+m)<.1&&Math.abs(l+f+p-3)<.1)return this.set(1,0,0,0),this;e=Math.PI;const A=(l+1)/2,M=(f+1)/2,S=(p+1)/2,b=(h+d)/4,R=(u+x)/4,_=(g+m)/4;return A>M&&A>S?A<.01?(n=0,s=.707106781,r=.707106781):(n=Math.sqrt(A),s=b/n,r=R/n):M>S?M<.01?(n=.707106781,s=0,r=.707106781):(s=Math.sqrt(M),n=b/s,r=_/s):S<.01?(n=.707106781,s=.707106781,r=0):(r=Math.sqrt(S),n=R/r,s=_/r),this.set(n,s,r,e),this}let w=Math.sqrt((m-g)*(m-g)+(u-x)*(u-x)+(d-h)*(d-h));return Math.abs(w)<.001&&(w=1),this.x=(m-g)/w,this.y=(u-x)/w,this.z=(d-h)/w,this.w=Math.acos((l+f+p-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=Xt(this.x,t.x,e.x),this.y=Xt(this.y,t.y,e.y),this.z=Xt(this.z,t.z,e.z),this.w=Xt(this.w,t.w,e.w),this}clampScalar(t,e){return this.x=Xt(this.x,t,e),this.y=Xt(this.y,t,e),this.z=Xt(this.z,t,e),this.w=Xt(this.w,t,e),this}clampLength(t,e){const n=this.length();return this.divideScalar(n||1).multiplyScalar(Xt(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 nm extends ts{constructor(t=1,e=1,n={}){super(),n=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Te,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 pe(0,0,t,e),this.scissorTest=!1,this.viewport=new pe(0,0,t,e),this.textures=[];const s={width:t,height:e,depth:n.depth},r=new qe(s),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:Te,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 s=0,r=this.textures.length;s<r;s++)this.textures[s].image.width=t,this.textures[s].image.height=e,this.textures[s].image.depth=n,this.textures[s].isData3DTexture!==!0&&(this.textures[s].isArrayTexture=this.textures[s].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 s=Object.assign({},t.textures[e].image);this.textures[e].source=new Zl(s)}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 Rn extends nm{constructor(t=1,e=1,n={}){super(t,e,n),this.isWebGLRenderTarget=!0}}class r0 extends qe{constructor(t=null,e=1,n=1,s=1){super(null),this.isDataArrayTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=ke,this.minFilter=ke,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1,this.layerUpdates=new Set}addLayerUpdate(t){this.layerUpdates.add(t)}clearLayerUpdates(){this.layerUpdates.clear()}}class im extends qe{constructor(t=null,e=1,n=1,s=1){super(null),this.isData3DTexture=!0,this.image={data:t,width:e,height:n,depth:s},this.magFilter=ke,this.minFilter=ke,this.wrapR=hn,this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}class he{static{he.prototype.isMatrix4=!0}constructor(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],t!==void 0&&this.set(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m)}set(t,e,n,s,r,a,o,c,l,h,u,d,f,g,x,m){const p=this.elements;return p[0]=t,p[4]=e,p[8]=n,p[12]=s,p[1]=r,p[5]=a,p[9]=o,p[13]=c,p[2]=l,p[6]=h,p[10]=u,p[14]=d,p[3]=f,p[7]=g,p[11]=x,p[15]=m,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new he().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,s=1/as.setFromMatrixColumn(t,0).length(),r=1/as.setFromMatrixColumn(t,1).length(),a=1/as.setFromMatrixColumn(t,2).length();return e[0]=n[0]*s,e[1]=n[1]*s,e[2]=n[2]*s,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,s=t.y,r=t.z,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r);if(t.order==="XYZ"){const d=a*h,f=a*u,g=o*h,x=o*u;e[0]=c*h,e[4]=-c*u,e[8]=l,e[1]=f+g*l,e[5]=d-x*l,e[9]=-o*c,e[2]=x-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,x=l*u;e[0]=d+x*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]=x+d*o,e[10]=a*c}else if(t.order==="ZXY"){const d=c*h,f=c*u,g=l*h,x=l*u;e[0]=d-x*o,e[4]=-a*u,e[8]=g+f*o,e[1]=f+g*o,e[5]=a*h,e[9]=x-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,x=o*u;e[0]=c*h,e[4]=g*l-f,e[8]=d*l+x,e[1]=c*u,e[5]=x*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,x=o*l;e[0]=c*h,e[4]=x-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-x*u}else if(t.order==="XZY"){const d=a*c,f=a*l,g=o*c,x=o*l;e[0]=c*h,e[4]=-u,e[8]=l*h,e[1]=d*u+x,e[5]=a*h,e[9]=f*u-g,e[2]=g*u-f,e[6]=o*h,e[10]=x*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(sm,t,rm)}lookAt(t,e,n){const s=this.elements;return nn.subVectors(t,e),nn.lengthSq()===0&&(nn.z=1),nn.normalize(),di.crossVectors(n,nn),di.lengthSq()===0&&(Math.abs(n.z)===1?nn.x+=1e-4:nn.z+=1e-4,nn.normalize(),di.crossVectors(n,nn)),di.normalize(),Or.crossVectors(nn,di),s[0]=di.x,s[4]=Or.x,s[8]=nn.x,s[1]=di.y,s[5]=Or.y,s[9]=nn.y,s[2]=di.z,s[6]=Or.z,s[10]=nn.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,e){const n=t.elements,s=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],x=n[6],m=n[10],p=n[14],w=n[3],A=n[7],M=n[11],S=n[15],b=s[0],R=s[4],_=s[8],E=s[12],D=s[1],C=s[5],I=s[9],W=s[13],X=s[2],U=s[6],q=s[10],H=s[14],$=s[3],et=s[7],j=s[11],it=s[15];return r[0]=a*b+o*D+c*X+l*$,r[4]=a*R+o*C+c*U+l*et,r[8]=a*_+o*I+c*q+l*j,r[12]=a*E+o*W+c*H+l*it,r[1]=h*b+u*D+d*X+f*$,r[5]=h*R+u*C+d*U+f*et,r[9]=h*_+u*I+d*q+f*j,r[13]=h*E+u*W+d*H+f*it,r[2]=g*b+x*D+m*X+p*$,r[6]=g*R+x*C+m*U+p*et,r[10]=g*_+x*I+m*q+p*j,r[14]=g*E+x*W+m*H+p*it,r[3]=w*b+A*D+M*X+S*$,r[7]=w*R+A*C+M*U+S*et,r[11]=w*_+A*I+M*q+S*j,r[15]=w*E+A*W+M*H+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],s=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],x=t[7],m=t[11],p=t[15],w=c*f-l*d,A=o*f-l*u,M=o*d-c*u,S=a*f-l*h,b=a*d-c*h,R=a*u-o*h;return e*(x*w-m*A+p*M)-n*(g*w-m*S+p*b)+s*(g*A-x*S+p*R)-r*(g*M-x*b+m*R)}determinantAffine(){const t=this.elements,e=t[0],n=t[4],s=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)+s*(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 s=this.elements;return t.isVector3?(s[12]=t.x,s[13]=t.y,s[14]=t.z):(s[12]=t,s[13]=e,s[14]=n),this}invert(){const t=this.elements,e=t[0],n=t[1],s=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],x=t[13],m=t[14],p=t[15],w=e*o-n*a,A=e*c-s*a,M=e*l-r*a,S=n*c-s*o,b=n*l-r*o,R=s*l-r*c,_=h*x-u*g,E=h*m-d*g,D=h*p-f*g,C=u*m-d*x,I=u*p-f*x,W=d*p-f*m,X=w*W-A*I+M*C+S*D-b*E+R*_;if(X===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const U=1/X;return t[0]=(o*W-c*I+l*C)*U,t[1]=(s*I-n*W-r*C)*U,t[2]=(x*R-m*b+p*S)*U,t[3]=(d*b-u*R-f*S)*U,t[4]=(c*D-a*W-l*E)*U,t[5]=(e*W-s*D+r*E)*U,t[6]=(m*M-g*R-p*A)*U,t[7]=(h*R-d*M+f*A)*U,t[8]=(a*I-o*D+l*_)*U,t[9]=(n*D-e*I-r*_)*U,t[10]=(g*b-x*M+p*w)*U,t[11]=(u*M-h*b-f*w)*U,t[12]=(o*E-a*C-c*_)*U,t[13]=(e*C-n*E+s*_)*U,t[14]=(x*A-g*S-m*w)*U,t[15]=(h*S-u*A+d*w)*U,this}scale(t){const e=this.elements,n=t.x,s=t.y,r=t.z;return e[0]*=n,e[4]*=s,e[8]*=r,e[1]*=n,e[5]*=s,e[9]*=r,e[2]*=n,e[6]*=s,e[10]*=r,e[3]*=n,e[7]*=s,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],s=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(e,n,s))}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),s=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-s*c,l*c+s*o,0,l*o+s*c,h*o+n,h*c-s*a,0,l*c-s*o,h*c+s*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,s,r,a){return this.set(1,n,r,0,t,1,a,0,e,s,1,0,0,0,0,1),this}compose(t,e,n){const s=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,x=a*h,m=a*u,p=o*u,w=c*l,A=c*h,M=c*u,S=n.x,b=n.y,R=n.z;return s[0]=(1-(x+p))*S,s[1]=(f+M)*S,s[2]=(g-A)*S,s[3]=0,s[4]=(f-M)*b,s[5]=(1-(d+p))*b,s[6]=(m+w)*b,s[7]=0,s[8]=(g+A)*R,s[9]=(m-w)*R,s[10]=(1-(d+x))*R,s[11]=0,s[12]=t.x,s[13]=t.y,s[14]=t.z,s[15]=1,this}decompose(t,e,n){const s=this.elements;t.x=s[12],t.y=s[13],t.z=s[14];const r=this.determinantAffine();if(r===0)return n.set(1,1,1),e.identity(),this;let a=as.set(s[0],s[1],s[2]).length();const o=as.set(s[4],s[5],s[6]).length(),c=as.set(s[8],s[9],s[10]).length();r<0&&(a=-a),yn.copy(this);const l=1/a,h=1/o,u=1/c;return yn.elements[0]*=l,yn.elements[1]*=l,yn.elements[2]*=l,yn.elements[4]*=h,yn.elements[5]*=h,yn.elements[6]*=h,yn.elements[8]*=u,yn.elements[9]*=u,yn.elements[10]*=u,e.setFromRotationMatrix(yn),n.x=a,n.y=o,n.z=c,this}makePerspective(t,e,n,s,r,a,o=Wn,c=!1){const l=this.elements,h=2*r/(e-t),u=2*r/(n-s),d=(e+t)/(e-t),f=(n+s)/(n-s);let g,x;if(c)g=r/(a-r),x=a*r/(a-r);else if(o===Wn)g=-(a+r)/(a-r),x=-2*a*r/(a-r);else if(o===Er)g=-a/(a-r),x=-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]=x,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(t,e,n,s,r,a,o=Wn,c=!1){const l=this.elements,h=2/(e-t),u=2/(n-s),d=-(e+t)/(e-t),f=-(n+s)/(n-s);let g,x;if(c)g=1/(a-r),x=a/(a-r);else if(o===Wn)g=-2/(a-r),x=-(a+r)/(a-r);else if(o===Er)g=-1/(a-r),x=-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]=x,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(t){const e=this.elements,n=t.elements;for(let s=0;s<16;s++)if(e[s]!==n[s])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 as=new F,yn=new he,sm=new F(0,0,0),rm=new F(1,1,1),di=new F,Or=new F,nn=new F,Vh=new he,Wh=new Xs;class Ci{constructor(t=0,e=0,n=0,s=Ci.DEFAULT_ORDER){this.isEuler=!0,this._x=t,this._y=e,this._z=n,this._order=s}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,s=this._order){return this._x=t,this._y=e,this._z=n,this._order=s,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 s=t.elements,r=s[0],a=s[4],o=s[8],c=s[1],l=s[5],h=s[9],u=s[2],d=s[6],f=s[10];switch(e){case"XYZ":this._y=Math.asin(Xt(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(-Xt(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(Xt(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(-Xt(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(Xt(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(-Xt(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:Ot("Euler: .setFromRotationMatrix() encountered an unknown order: "+e)}return this._order=e,n===!0&&this._onChangeCallback(),this}setFromQuaternion(t,e,n){return Vh.makeRotationFromQuaternion(t),this.setFromRotationMatrix(Vh,e,n)}setFromVector3(t,e=this._order){return this.set(t.x,t.y,t.z,e)}reorder(t){return Wh.setFromEuler(this),this.setFromQuaternion(Wh,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}}Ci.DEFAULT_ORDER="XYZ";class $l{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 am=0;const Xh=new F,os=new Xs,Zn=new he,zr=new F,$s=new F,om=new F,cm=new Xs,qh=new F(1,0,0),Yh=new F(0,1,0),Kh=new F(0,0,1),Zh={type:"added"},lm={type:"removed"},cs={type:"childadded",child:null},So={type:"childremoved",child:null};class Re extends ts{constructor(){super(),this.isObject3D=!0,Object.defineProperty(this,"id",{value:am++}),this.uuid=wi(),this.name="",this.type="Object3D",this.parent=null,this.children=[],this.up=Re.DEFAULT_UP.clone();const t=new F,e=new Ci,n=new Xs,s=new F(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:s},modelViewMatrix:{value:new he},normalMatrix:{value:new zt}}),this.matrix=new he,this.matrixWorld=new he,this.matrixAutoUpdate=Re.DEFAULT_MATRIX_AUTO_UPDATE,this.matrixWorldAutoUpdate=Re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE,this.matrixWorldNeedsUpdate=!1,this.layers=new $l,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 os.setFromAxisAngle(t,e),this.quaternion.multiply(os),this}rotateOnWorldAxis(t,e){return os.setFromAxisAngle(t,e),this.quaternion.premultiply(os),this}rotateX(t){return this.rotateOnAxis(qh,t)}rotateY(t){return this.rotateOnAxis(Yh,t)}rotateZ(t){return this.rotateOnAxis(Kh,t)}translateOnAxis(t,e){return Xh.copy(t).applyQuaternion(this.quaternion),this.position.add(Xh.multiplyScalar(e)),this}translateX(t){return this.translateOnAxis(qh,t)}translateY(t){return this.translateOnAxis(Yh,t)}translateZ(t){return this.translateOnAxis(Kh,t)}localToWorld(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(this.matrixWorld)}worldToLocal(t){return this.updateWorldMatrix(!0,!1),t.applyMatrix4(Zn.copy(this.matrixWorld).invert())}lookAt(t,e,n){t.isVector3?zr.copy(t):zr.set(t,e,n);const s=this.parent;this.updateWorldMatrix(!0,!1),$s.setFromMatrixPosition(this.matrixWorld),this.isCamera||this.isLight?Zn.lookAt($s,zr,this.up):Zn.lookAt(zr,$s,this.up),this.quaternion.setFromRotationMatrix(Zn),s&&(Zn.extractRotation(s.matrixWorld),os.setFromRotationMatrix(Zn),this.quaternion.premultiply(os.invert()))}add(t){if(arguments.length>1){for(let e=0;e<arguments.length;e++)this.add(arguments[e]);return this}return t===this?(Yt("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(Zh),cs.child=t,this.dispatchEvent(cs),cs.child=null):Yt("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(lm),So.child=t,this.dispatchEvent(So),So.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),Zn.copy(this.matrixWorld).invert(),t.parent!==null&&(t.parent.updateWorldMatrix(!0,!1),Zn.multiply(t.parent.matrixWorld)),t.applyMatrix4(Zn),t.removeFromParent(),t.parent=this,this.children.push(t),t.updateWorldMatrix(!1,!0),t.dispatchEvent(Zh),cs.child=t,this.dispatchEvent(cs),cs.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,s=this.children.length;n<s;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 s=this.children;for(let r=0,a=s.length;r<a;r++)s[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($s,t,om),t}getWorldScale(t){return this.updateWorldMatrix(!0,!1),this.matrixWorld.decompose($s,cm,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,s=e.length;n<s;n++)e[n].traverse(t)}traverseVisible(t){if(this.visible===!1)return;t(this);const e=this.children;for(let n=0,s=e.length;n<s;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,s=t.z,r=this.matrix.elements;r[12]+=e-r[0]*e-r[4]*n-r[8]*s,r[13]+=n-r[1]*e-r[5]*n-r[9]*s,r[14]+=s-r[2]*e-r[6]*n-r[10]*s}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,s=e.length;n<s;n++)e[n].updateMatrixWorld(t)}updateWorldMatrix(t,e,n=!1){const s=this.parent;if(t===!0&&s!==null&&s.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 s={};s.uuid=this.uuid,s.type=this.type,this.name!==""&&(s.name=this.name),this.castShadow===!0&&(s.castShadow=!0),this.receiveShadow===!0&&(s.receiveShadow=!0),this.visible===!1&&(s.visible=!1),this.frustumCulled===!1&&(s.frustumCulled=!1),this.renderOrder!==0&&(s.renderOrder=this.renderOrder),this.static!==!1&&(s.static=this.static),Object.keys(this.userData).length>0&&(s.userData=this.userData),s.layers=this.layers.mask,s.matrix=this.matrix.toArray(),s.up=this.up.toArray(),this.pivot!==null&&(s.pivot=this.pivot.toArray()),this.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(t),s.indirectTexture=this._indirectTexture.toJSON(t),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(t)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.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?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(t).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(t).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.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&&(s.bindMode=this.bindMode,s.bindMatrix=this.bindMatrix.toArray(),this.skeleton!==void 0&&(r(t.skeletons,this.skeleton),s.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]));s.material=o}else s.material=r(t.materials,this.material);if(this.children.length>0){s.children=[];for(let o=0;o<this.children.length;o++)s.children.push(this.children[o].toJSON(t).object)}if(this.animations.length>0){s.animations=[];for(let o=0;o<this.animations.length;o++){const c=this.animations[o];s.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=s,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 s=t.children[n];this.add(s.clone())}return this}}Re.DEFAULT_UP=new F(0,1,0);Re.DEFAULT_MATRIX_AUTO_UPDATE=!0;Re.DEFAULT_MATRIX_WORLD_AUTO_UPDATE=!0;class Tn extends Re{constructor(){super(),this.isGroup=!0,this.type="Group"}}const hm={type:"move"};class Eo{constructor(){this._targetRay=null,this._grip=null,this._hand=null}getHandSpace(){return this._hand===null&&(this._hand=new Tn,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 Tn,this._targetRay.matrixAutoUpdate=!1,this._targetRay.visible=!1,this._targetRay.hasLinearVelocity=!1,this._targetRay.linearVelocity=new F,this._targetRay.hasAngularVelocity=!1,this._targetRay.angularVelocity=new F),this._targetRay}getGripSpace(){return this._grip===null&&(this._grip=new Tn,this._grip.matrixAutoUpdate=!1,this._grip.visible=!1,this._grip.hasLinearVelocity=!1,this._grip.linearVelocity=new F,this._grip.hasAngularVelocity=!1,this._grip.angularVelocity=new F,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 s=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 x of t.hand.values()){const m=e.getJointPose(x,n),p=this._getHandJoint(l,x);m!==null&&(p.matrix.fromArray(m.transform.matrix),p.matrix.decompose(p.position,p.rotation,p.scale),p.matrixWorldNeedsUpdate=!0,p.jointRadius=m.radius),p.visible=m!==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&&(s=e.getPose(t.targetRaySpace,n),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(hm)))}return o!==null&&(o.visible=s!==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 Tn;n.matrixAutoUpdate=!1,n.visible=!1,t.joints[e.jointName]=n,t.add(n)}return t.joints[e.jointName]}}const a0={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},fi={h:0,s:0,l:0},Br={h:0,s:0,l:0};function bo(i,t,e){return e<0&&(e+=1),e>1&&(e-=1),e<1/6?i+(t-i)*6*e:e<1/2?t:e<2/3?i+(t-i)*6*(2/3-e):i}class Mt{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 s=t;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(t,e,n);return this}setScalar(t){return this.r=t,this.g=t,this.b=t,this}setHex(t,e=vn){return t=Math.floor(t),this.r=(t>>16&255)/255,this.g=(t>>8&255)/255,this.b=(t&255)/255,Kt.colorSpaceToWorking(this,e),this}setRGB(t,e,n,s=Kt.workingColorSpace){return this.r=t,this.g=e,this.b=n,Kt.colorSpaceToWorking(this,s),this}setHSL(t,e,n,s=Kt.workingColorSpace){if(t=Jp(t,1),e=Xt(e,0,1),n=Xt(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=bo(a,r,t+1/3),this.g=bo(a,r,t),this.b=bo(a,r,t-1/3)}return Kt.colorSpaceToWorking(this,s),this}setStyle(t,e=vn){function n(r){r!==void 0&&parseFloat(r)<1&&Ot("Color: Alpha component of "+t+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(t)){let r;const a=s[1],o=s[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:Ot("Color: Unknown color model "+t)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(t)){const r=s[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);Ot("Color: Invalid hex color "+t)}else if(t&&t.length>0)return this.setColorName(t,e);return this}setColorName(t,e=vn){const n=a0[t.toLowerCase()];return n!==void 0?this.setHex(n,e):Ot("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=ri(t.r),this.g=ri(t.g),this.b=ri(t.b),this}copyLinearToSRGB(t){return this.r=Ns(t.r),this.g=Ns(t.g),this.b=Ns(t.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(t=vn){return Kt.workingToColorSpace(Ve.copy(this),t),Math.round(Xt(Ve.r*255,0,255))*65536+Math.round(Xt(Ve.g*255,0,255))*256+Math.round(Xt(Ve.b*255,0,255))}getHexString(t=vn){return("000000"+this.getHex(t).toString(16)).slice(-6)}getHSL(t,e=Kt.workingColorSpace){Kt.workingToColorSpace(Ve.copy(this),e);const n=Ve.r,s=Ve.g,r=Ve.b,a=Math.max(n,s,r),o=Math.min(n,s,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=(s-r)/u+(s<r?6:0);break;case s:c=(r-n)/u+2;break;case r:c=(n-s)/u+4;break}c/=6}return t.h=c,t.s=l,t.l=h,t}getRGB(t,e=Kt.workingColorSpace){return Kt.workingToColorSpace(Ve.copy(this),e),t.r=Ve.r,t.g=Ve.g,t.b=Ve.b,t}getStyle(t=vn){Kt.workingToColorSpace(Ve.copy(this),t);const e=Ve.r,n=Ve.g,s=Ve.b;return t!==vn?`color(${t} ${e.toFixed(3)} ${n.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(e*255)},${Math.round(n*255)},${Math.round(s*255)})`}offsetHSL(t,e,n){return this.getHSL(fi),this.setHSL(fi.h+t,fi.s+e,fi.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(fi),t.getHSL(Br);const n=vo(fi.h,Br.h,e),s=vo(fi.s,Br.s,e),r=vo(fi.l,Br.l,e);return this.setHSL(n,s,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,s=this.b,r=t.elements;return this.r=r[0]*e+r[3]*n+r[6]*s,this.g=r[1]*e+r[4]*n+r[7]*s,this.b=r[2]*e+r[5]*n+r[8]*s,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 Ve=new Mt;Mt.NAMES=a0;class Jl{constructor(t,e=1,n=1e3){this.isFog=!0,this.name="",this.color=new Mt(t),this.near=e,this.far=n}clone(){return new Jl(this.color,this.near,this.far)}toJSON(){return{type:"Fog",name:this.name,color:this.color.getHex(),near:this.near,far:this.far}}}class o0 extends Re{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 Ci,this.environmentIntensity=1,this.environmentRotation=new Ci,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 Sn=new F,$n=new F,wo=new F,Jn=new F,ls=new F,hs=new F,$h=new F,Ao=new F,To=new F,Ro=new F,Co=new pe,Do=new pe,Po=new pe;class _n{constructor(t=new F,e=new F,n=new F){this.a=t,this.b=e,this.c=n}static getNormal(t,e,n,s){s.subVectors(n,e),Sn.subVectors(t,e),s.cross(Sn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(t,e,n,s,r){Sn.subVectors(s,e),$n.subVectors(n,e),wo.subVectors(t,e);const a=Sn.dot(Sn),o=Sn.dot($n),c=Sn.dot(wo),l=$n.dot($n),h=$n.dot(wo),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,s){return this.getBarycoord(t,e,n,s,Jn)===null?!1:Jn.x>=0&&Jn.y>=0&&Jn.x+Jn.y<=1}static getInterpolation(t,e,n,s,r,a,o,c){return this.getBarycoord(t,e,n,s,Jn)===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,Jn.x),c.addScaledVector(a,Jn.y),c.addScaledVector(o,Jn.z),c)}static getInterpolatedAttribute(t,e,n,s,r,a){return Co.setScalar(0),Do.setScalar(0),Po.setScalar(0),Co.fromBufferAttribute(t,e),Do.fromBufferAttribute(t,n),Po.fromBufferAttribute(t,s),a.setScalar(0),a.addScaledVector(Co,r.x),a.addScaledVector(Do,r.y),a.addScaledVector(Po,r.z),a}static isFrontFacing(t,e,n,s){return Sn.subVectors(n,e),$n.subVectors(t,e),Sn.cross($n).dot(s)<0}set(t,e,n){return this.a.copy(t),this.b.copy(e),this.c.copy(n),this}setFromPointsAndIndices(t,e,n,s){return this.a.copy(t[e]),this.b.copy(t[n]),this.c.copy(t[s]),this}setFromAttributeAndIndices(t,e,n,s){return this.a.fromBufferAttribute(t,e),this.b.fromBufferAttribute(t,n),this.c.fromBufferAttribute(t,s),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 Sn.subVectors(this.c,this.b),$n.subVectors(this.a,this.b),Sn.cross($n).length()*.5}getMidpoint(t){return t.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(t){return _n.getNormal(this.a,this.b,this.c,t)}getPlane(t){return t.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(t,e){return _n.getBarycoord(t,this.a,this.b,this.c,e)}getInterpolation(t,e,n,s,r){return _n.getInterpolation(t,this.a,this.b,this.c,e,n,s,r)}containsPoint(t){return _n.containsPoint(t,this.a,this.b,this.c)}isFrontFacing(t){return _n.isFrontFacing(this.a,this.b,this.c,t)}intersectsBox(t){return t.intersectsTriangle(this)}closestPointToPoint(t,e){const n=this.a,s=this.b,r=this.c;let a,o;ls.subVectors(s,n),hs.subVectors(r,n),Ao.subVectors(t,n);const c=ls.dot(Ao),l=hs.dot(Ao);if(c<=0&&l<=0)return e.copy(n);To.subVectors(t,s);const h=ls.dot(To),u=hs.dot(To);if(h>=0&&u<=h)return e.copy(s);const d=c*u-h*l;if(d<=0&&c>=0&&h<=0)return a=c/(c-h),e.copy(n).addScaledVector(ls,a);Ro.subVectors(t,r);const f=ls.dot(Ro),g=hs.dot(Ro);if(g>=0&&f<=g)return e.copy(r);const x=f*l-c*g;if(x<=0&&l>=0&&g<=0)return o=l/(l-g),e.copy(n).addScaledVector(hs,o);const m=h*g-f*u;if(m<=0&&u-h>=0&&f-g>=0)return $h.subVectors(r,s),o=(u-h)/(u-h+(f-g)),e.copy(s).addScaledVector($h,o);const p=1/(m+x+d);return a=x*p,o=d*p,e.copy(n).addScaledVector(ls,a).addScaledVector(hs,o)}equals(t){return t.a.equals(this.a)&&t.b.equals(this.b)&&t.c.equals(this.c)}}class wr{constructor(t=new F(1/0,1/0,1/0),e=new F(-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(En.fromArray(t,e));return this}setFromBufferAttribute(t){this.makeEmpty();for(let e=0,n=t.count;e<n;e++)this.expandByPoint(En.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=En.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,En):En.fromBufferAttribute(r,a),En.applyMatrix4(t.matrixWorld),this.expandByPoint(En);else t.boundingBox!==void 0?(t.boundingBox===null&&t.computeBoundingBox(),kr.copy(t.boundingBox)):(n.boundingBox===null&&n.computeBoundingBox(),kr.copy(n.boundingBox)),kr.applyMatrix4(t.matrixWorld),this.union(kr)}const s=t.children;for(let r=0,a=s.length;r<a;r++)this.expandByObject(s[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,En),En.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(Js),Gr.subVectors(this.max,Js),us.subVectors(t.a,Js),ds.subVectors(t.b,Js),fs.subVectors(t.c,Js),pi.subVectors(ds,us),mi.subVectors(fs,ds),Li.subVectors(us,fs);let e=[0,-pi.z,pi.y,0,-mi.z,mi.y,0,-Li.z,Li.y,pi.z,0,-pi.x,mi.z,0,-mi.x,Li.z,0,-Li.x,-pi.y,pi.x,0,-mi.y,mi.x,0,-Li.y,Li.x,0];return!Io(e,us,ds,fs,Gr)||(e=[1,0,0,0,1,0,0,0,1],!Io(e,us,ds,fs,Gr))?!1:(Hr.crossVectors(pi,mi),e=[Hr.x,Hr.y,Hr.z],Io(e,us,ds,fs,Gr))}clampPoint(t,e){return e.copy(t).clamp(this.min,this.max)}distanceToPoint(t){return this.clampPoint(t,En).distanceTo(t)}getBoundingSphere(t){return this.isEmpty()?t.makeEmpty():(this.getCenter(t.center),t.radius=this.getSize(En).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:(Qn[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),Qn[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),Qn[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),Qn[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),Qn[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),Qn[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),Qn[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),Qn[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(Qn),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 Qn=[new F,new F,new F,new F,new F,new F,new F,new F],En=new F,kr=new wr,us=new F,ds=new F,fs=new F,pi=new F,mi=new F,Li=new F,Js=new F,Gr=new F,Hr=new F,Ni=new F;function Io(i,t,e,n,s){for(let r=0,a=i.length-3;r<=a;r+=3){Ni.fromArray(i,r);const o=s.x*Math.abs(Ni.x)+s.y*Math.abs(Ni.y)+s.z*Math.abs(Ni.z),c=t.dot(Ni),l=e.dot(Ni),h=n.dot(Ni);if(Math.max(-Math.max(c,l,h),Math.min(c,l,h))>o)return!1}return!0}const ii=um();function um(){const i=new ArrayBuffer(4),t=new Float32Array(i),e=new Uint32Array(i),n=new Uint32Array(512),s=new Uint32Array(512);for(let c=0;c<256;++c){const l=c-127;l<-27?(n[c]=0,n[c|256]=32768,s[c]=24,s[c|256]=24):l<-14?(n[c]=1024>>-l-14,n[c|256]=1024>>-l-14|32768,s[c]=-l-1,s[c|256]=-l-1):l<=15?(n[c]=l+15<<10,n[c|256]=l+15<<10|32768,s[c]=13,s[c|256]=13):l<128?(n[c]=31744,n[c|256]=64512,s[c]=24,s[c|256]=24):(n[c]=31744,n[c|256]=64512,s[c]=13,s[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:s,mantissaTable:r,exponentTable:a,offsetTable:o}}function dm(i){Math.abs(i)>65504&&Ot("DataUtils.toHalfFloat(): Value out of range."),i=Xt(i,-65504,65504),ii.floatView[0]=i;const t=ii.uint32View[0],e=t>>23&511;return ii.baseTable[e]+((t&8388607)>>ii.shiftTable[e])}function fm(i){const t=i>>10;return ii.uint32View[0]=ii.mantissaTable[ii.offsetTable[t]+(i&1023)]+ii.exponentTable[t],ii.floatView[0]}class Us{static toHalfFloat(t){return dm(t)}static fromHalfFloat(t){return fm(t)}}const we=new F,Vr=new Ft;let pm=0;class le extends ts{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:pm++}),this.name="",this.array=t,this.itemSize=e,this.count=t!==void 0?t.length/e:0,this.normalized=n,this.usage=al,this.updateRanges=[],this.gpuType=Vn,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 s=0,r=this.itemSize;s<r;s++)this.array[t+s]=e.array[n+s];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++)Vr.fromBufferAttribute(this,e),Vr.applyMatrix3(t),this.setXY(e,Vr.x,Vr.y);else if(this.itemSize===3)for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.applyMatrix3(t),this.setXYZ(e,we.x,we.y,we.z);return this}applyMatrix4(t){for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.applyMatrix4(t),this.setXYZ(e,we.x,we.y,we.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.applyNormalMatrix(t),this.setXYZ(e,we.x,we.y,we.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)we.fromBufferAttribute(this,e),we.transformDirection(t),this.setXYZ(e,we.x,we.y,we.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=Hn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ie(n,this.array)),this.array[t*this.itemSize+e]=n,this}getX(t){let e=this.array[t*this.itemSize];return this.normalized&&(e=Hn(e,this.array)),e}setX(t,e){return this.normalized&&(e=ie(e,this.array)),this.array[t*this.itemSize]=e,this}getY(t){let e=this.array[t*this.itemSize+1];return this.normalized&&(e=Hn(e,this.array)),e}setY(t,e){return this.normalized&&(e=ie(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=Hn(e,this.array)),e}setZ(t,e){return this.normalized&&(e=ie(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=Hn(e,this.array)),e}setW(t,e){return this.normalized&&(e=ie(e,this.array)),this.array[t*this.itemSize+3]=e,this}setXY(t,e,n){return t*=this.itemSize,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array)),this.array[t+0]=e,this.array[t+1]=n,this}setXYZ(t,e,n,s){return t*=this.itemSize,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t*=this.itemSize,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array),r=ie(r,this.array)),this.array[t+0]=e,this.array[t+1]=n,this.array[t+2]=s,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!==al&&(t.usage=this.usage),t}dispose(){this.dispatchEvent({type:"dispose"})}}class c0 extends le{constructor(t,e,n){super(new Uint16Array(t),e,n)}}class l0 extends le{constructor(t,e,n){super(new Uint32Array(t),e,n)}}class De extends le{constructor(t,e,n){super(new Float32Array(t),e,n)}}const mm=new wr,Qs=new F,Lo=new F;class eo{constructor(t=new F,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):mm.setFromPoints(t).getCenter(n);let s=0;for(let r=0,a=t.length;r<a;r++)s=Math.max(s,n.distanceToSquared(t[r]));return this.radius=Math.sqrt(s),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;Qs.subVectors(t,this.center);const e=Qs.lengthSq();if(e>this.radius*this.radius){const n=Math.sqrt(e),s=(n-this.radius)*.5;this.center.addScaledVector(Qs,s/n),this.radius+=s}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):(Lo.subVectors(t.center,this.center).setLength(t.radius),this.expandByPoint(Qs.copy(t.center).add(Lo)),this.expandByPoint(Qs.copy(t.center).sub(Lo))),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 gm=0;const fn=new he,No=new Re,ps=new F,sn=new wr,js=new wr,Ne=new F;class Ee extends ts{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:gm++}),this.uuid=wi(),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(Yp(t)?l0:c0)(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 zt().getNormalMatrix(t);n.applyNormalMatrix(r),n.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(t),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(t){return fn.makeRotationFromQuaternion(t),this.applyMatrix4(fn),this}rotateX(t){return fn.makeRotationX(t),this.applyMatrix4(fn),this}rotateY(t){return fn.makeRotationY(t),this.applyMatrix4(fn),this}rotateZ(t){return fn.makeRotationZ(t),this.applyMatrix4(fn),this}translate(t,e,n){return fn.makeTranslation(t,e,n),this.applyMatrix4(fn),this}scale(t,e,n){return fn.makeScale(t,e,n),this.applyMatrix4(fn),this}lookAt(t){return No.lookAt(t),No.updateMatrix(),this.applyMatrix4(No.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(ps).negate(),this.translate(ps.x,ps.y,ps.z),this}setFromPoints(t){const e=this.getAttribute("position");if(e===void 0){const n=[];for(let s=0,r=t.length;s<r;s++){const a=t[s];n.push(a.x,a.y,a.z||0)}this.setAttribute("position",new De(n,3))}else{const n=Math.min(t.length,e.count);for(let s=0;s<n;s++){const r=t[s];e.setXYZ(s,r.x,r.y,r.z||0)}t.length>e.count&&Ot("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 wr);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new F(-1/0,-1/0,-1/0),new F(1/0,1/0,1/0));return}if(t!==void 0){if(this.boundingBox.setFromBufferAttribute(t),e)for(let n=0,s=e.length;n<s;n++){const r=e[n];sn.setFromBufferAttribute(r),this.morphTargetsRelative?(Ne.addVectors(this.boundingBox.min,sn.min),this.boundingBox.expandByPoint(Ne),Ne.addVectors(this.boundingBox.max,sn.max),this.boundingBox.expandByPoint(Ne)):(this.boundingBox.expandByPoint(sn.min),this.boundingBox.expandByPoint(sn.max))}}else this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||isNaN(this.boundingBox.min.z))&&Yt('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 eo);const t=this.attributes.position,e=this.morphAttributes.position;if(t&&t.isGLBufferAttribute){Yt("BufferGeometry.computeBoundingSphere(): GLBufferAttribute requires a manual bounding sphere.",this),this.boundingSphere.set(new F,1/0);return}if(t){const n=this.boundingSphere.center;if(sn.setFromBufferAttribute(t),e)for(let r=0,a=e.length;r<a;r++){const o=e[r];js.setFromBufferAttribute(o),this.morphTargetsRelative?(Ne.addVectors(sn.min,js.min),sn.expandByPoint(Ne),Ne.addVectors(sn.max,js.max),sn.expandByPoint(Ne)):(sn.expandByPoint(js.min),sn.expandByPoint(js.max))}sn.getCenter(n);let s=0;for(let r=0,a=t.count;r<a;r++)Ne.fromBufferAttribute(t,r),s=Math.max(s,n.distanceToSquared(Ne));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++)Ne.fromBufferAttribute(o,l),c&&(ps.fromBufferAttribute(t,l),Ne.add(ps)),s=Math.max(s,n.distanceToSquared(Ne))}this.boundingSphere.radius=Math.sqrt(s),isNaN(this.boundingSphere.radius)&&Yt('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){Yt("BufferGeometry: .computeTangents() failed. Missing required attributes (index, position, normal or uv)");return}const n=e.position,s=e.normal,r=e.uv;let a=this.getAttribute("tangent");(a===void 0||a.count!==n.count)&&(a=new le(new Float32Array(4*n.count),4),this.setAttribute("tangent",a));const o=[],c=[];for(let _=0;_<n.count;_++)o[_]=new F,c[_]=new F;const l=new F,h=new F,u=new F,d=new Ft,f=new Ft,g=new Ft,x=new F,m=new F;function p(_,E,D){l.fromBufferAttribute(n,_),h.fromBufferAttribute(n,E),u.fromBufferAttribute(n,D),d.fromBufferAttribute(r,_),f.fromBufferAttribute(r,E),g.fromBufferAttribute(r,D),h.sub(l),u.sub(l),f.sub(d),g.sub(d);const C=1/(f.x*g.y-g.x*f.y);isFinite(C)&&(x.copy(h).multiplyScalar(g.y).addScaledVector(u,-f.y).multiplyScalar(C),m.copy(u).multiplyScalar(f.x).addScaledVector(h,-g.x).multiplyScalar(C),o[_].add(x),o[E].add(x),o[D].add(x),c[_].add(m),c[E].add(m),c[D].add(m))}let w=this.groups;w.length===0&&(w=[{start:0,count:t.count}]);for(let _=0,E=w.length;_<E;++_){const D=w[_],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)p(t.getX(W+0),t.getX(W+1),t.getX(W+2))}const A=new F,M=new F,S=new F,b=new F;function R(_){S.fromBufferAttribute(s,_),b.copy(S);const E=o[_];A.copy(E),A.sub(S.multiplyScalar(S.dot(E))).normalize(),M.crossVectors(b,E);const C=M.dot(c[_])<0?-1:1;a.setXYZW(_,A.x,A.y,A.z,C)}for(let _=0,E=w.length;_<E;++_){const D=w[_],C=D.start,I=D.count;for(let W=C,X=C+I;W<X;W+=3)R(t.getX(W+0)),R(t.getX(W+1)),R(t.getX(W+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 le(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 s=new F,r=new F,a=new F,o=new F,c=new F,l=new F,h=new F,u=new F;if(t)for(let d=0,f=t.count;d<f;d+=3){const g=t.getX(d+0),x=t.getX(d+1),m=t.getX(d+2);s.fromBufferAttribute(e,g),r.fromBufferAttribute(e,x),a.fromBufferAttribute(e,m),h.subVectors(a,r),u.subVectors(s,r),h.cross(u),o.fromBufferAttribute(n,g),c.fromBufferAttribute(n,x),l.fromBufferAttribute(n,m),o.add(h),c.add(h),l.add(h),n.setXYZ(g,o.x,o.y,o.z),n.setXYZ(x,c.x,c.y,c.z),n.setXYZ(m,l.x,l.y,l.z)}else for(let d=0,f=e.count;d<f;d+=3)s.fromBufferAttribute(e,d+0),r.fromBufferAttribute(e,d+1),a.fromBufferAttribute(e,d+2),h.subVectors(a,r),u.subVectors(s,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++)Ne.fromBufferAttribute(t,e),Ne.normalize(),t.setXYZ(e,Ne.x,Ne.y,Ne.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 x=0,m=c.length;x<m;x++){o.isInterleavedBufferAttribute?f=c[x]*o.data.stride+o.offset:f=c[x]*h;for(let p=0;p<h;p++)d[g++]=l[f++]}return new le(d,h,u)}if(this.index===null)return Ot("BufferGeometry.toNonIndexed(): BufferGeometry is already non-indexed."),this;const e=new Ee,n=this.index.array,s=this.attributes;for(const o in s){const c=s[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 s={};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&&(s[c]=h,r=!0)}r&&(t.data.morphAttributes=s,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 s=t.attributes;for(const l in s){const h=s[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 vm{constructor(t,e){this.isInterleavedBuffer=!0,this.array=t,this.stride=e,this.count=t!==void 0?t.length/e:0,this.usage=al,this.updateRanges=[],this.version=0,this.uuid=wi()}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 s=0,r=this.stride;s<r;s++)this.array[t+s]=e.array[n+s];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=wi()),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=wi()),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 Ye=new F;class Ha{constructor(t,e,n,s=!1){this.isInterleavedBufferAttribute=!0,this.name="",this.data=t,this.itemSize=e,this.offset=n,this.normalized=s}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++)Ye.fromBufferAttribute(this,e),Ye.applyMatrix4(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}applyNormalMatrix(t){for(let e=0,n=this.count;e<n;e++)Ye.fromBufferAttribute(this,e),Ye.applyNormalMatrix(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}transformDirection(t){for(let e=0,n=this.count;e<n;e++)Ye.fromBufferAttribute(this,e),Ye.transformDirection(t),this.setXYZ(e,Ye.x,Ye.y,Ye.z);return this}getComponent(t,e){let n=this.array[t*this.data.stride+this.offset+e];return this.normalized&&(n=Hn(n,this.array)),n}setComponent(t,e,n){return this.normalized&&(n=ie(n,this.array)),this.data.array[t*this.data.stride+this.offset+e]=n,this}setX(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset]=e,this}setY(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset+1]=e,this}setZ(t,e){return this.normalized&&(e=ie(e,this.array)),this.data.array[t*this.data.stride+this.offset+2]=e,this}setW(t,e){return this.normalized&&(e=ie(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=Hn(e,this.array)),e}getY(t){let e=this.data.array[t*this.data.stride+this.offset+1];return this.normalized&&(e=Hn(e,this.array)),e}getZ(t){let e=this.data.array[t*this.data.stride+this.offset+2];return this.normalized&&(e=Hn(e,this.array)),e}getW(t){let e=this.data.array[t*this.data.stride+this.offset+3];return this.normalized&&(e=Hn(e,this.array)),e}setXY(t,e,n){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this}setXYZ(t,e,n,s){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this}setXYZW(t,e,n,s,r){return t=t*this.data.stride+this.offset,this.normalized&&(e=ie(e,this.array),n=ie(n,this.array),s=ie(s,this.array),r=ie(r,this.array)),this.data.array[t+0]=e,this.data.array[t+1]=n,this.data.array[t+2]=s,this.data.array[t+3]=r,this}clone(t){if(t===void 0){Ga("InterleavedBufferAttribute.clone(): Cloning an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+r])}return new le(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 Ha(t.interleavedBuffers[this.data.uuid],this.itemSize,this.offset,this.normalized)}toJSON(t){if(t===void 0){Ga("InterleavedBufferAttribute.toJSON(): Serializing an interleaved buffer attribute will de-interleave buffer data.");const e=[];for(let n=0;n<this.count;n++){const s=n*this.data.stride+this.offset;for(let r=0;r<this.itemSize;r++)e.push(this.data.array[s+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 _m=0;class es extends ts{constructor(){super(),this.isMaterial=!0,Object.defineProperty(this,"id",{value:_m++}),this.uuid=wi(),this.name="",this.type="Material",this.blending=Is,this.side=Ti,this.vertexColors=!1,this.opacity=1,this.transparent=!1,this.alphaHash=!1,this.blendSrc=_c,this.blendDst=xc,this.blendEquation=Gi,this.blendSrcAlpha=null,this.blendDstAlpha=null,this.blendEquationAlpha=null,this.blendColor=new Mt(0,0,0),this.blendAlpha=0,this.depthFunc=ks,this.depthTest=!0,this.depthWrite=!0,this.stencilWriteMask=255,this.stencilFunc=Oh,this.stencilRef=0,this.stencilFuncMask=255,this.stencilFail=ss,this.stencilZFail=ss,this.stencilZPass=ss,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){Ot(`Material: parameter '${e}' has value of undefined.`);continue}const s=this[e];if(s===void 0){Ot(`Material: '${e}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(n):s&&s.isVector2&&n&&n.isVector2||s&&s.isEuler&&n&&n.isEuler||s&&s.isVector3&&n&&n.isVector3?s.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!==Is&&(n.blending=this.blending),this.side!==Ti&&(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!==_c&&(n.blendSrc=this.blendSrc),this.blendDst!==xc&&(n.blendDst=this.blendDst),this.blendEquation!==Gi&&(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!==ks&&(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!==Oh&&(n.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(n.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(n.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==ss&&(n.stencilFail=this.stencilFail),this.stencilZFail!==ss&&(n.stencilZFail=this.stencilZFail),this.stencilZPass!==ss&&(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 s(r){const a=[];for(const o in r){const c=r[o];delete c.metadata,a.push(c)}return a}if(e){const r=s(t.textures),a=s(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 Mt().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 Ft().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 Ft().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 s=e.length;n=new Array(s);for(let r=0;r!==s;++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 hr extends es{constructor(t){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Mt(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 ms;const tr=new F,gs=new F,vs=new F,_s=new Ft,er=new Ft,h0=new he,Wr=new F,nr=new F,Xr=new F,Jh=new Ft,Uo=new Ft,Qh=new Ft;class qr extends Re{constructor(t=new hr){if(super(),this.isSprite=!0,this.type="Sprite",ms===void 0){ms=new Ee;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 vm(e,5);ms.setIndex([0,1,2,0,2,3]),ms.setAttribute("position",new Ha(n,3,0,!1)),ms.setAttribute("uv",new Ha(n,2,3,!1))}this.geometry=ms,this.material=t,this.center=new Ft(.5,.5),this.count=1}raycast(t,e){t.camera===null&&Yt('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),gs.setFromMatrixScale(this.matrixWorld),h0.copy(t.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(t.camera.matrixWorldInverse,this.matrixWorld),vs.setFromMatrixPosition(this.modelViewMatrix),t.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&gs.multiplyScalar(-vs.z);const n=this.material.rotation;let s,r;n!==0&&(r=Math.cos(n),s=Math.sin(n));const a=this.center;Yr(Wr.set(-.5,-.5,0),vs,a,gs,s,r),Yr(nr.set(.5,-.5,0),vs,a,gs,s,r),Yr(Xr.set(.5,.5,0),vs,a,gs,s,r),Jh.set(0,0),Uo.set(1,0),Qh.set(1,1);let o=t.ray.intersectTriangle(Wr,nr,Xr,!1,tr);if(o===null&&(Yr(nr.set(-.5,.5,0),vs,a,gs,s,r),Uo.set(0,1),o=t.ray.intersectTriangle(Wr,Xr,nr,!1,tr),o===null))return;const c=t.ray.origin.distanceTo(tr);c<t.near||c>t.far||e.push({distance:c,point:tr.clone(),uv:_n.getInterpolation(tr,Wr,nr,Xr,Jh,Uo,Qh,new Ft),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 Yr(i,t,e,n,s,r){_s.subVectors(i,e).addScalar(.5).multiply(n),s!==void 0?(er.x=r*_s.x-s*_s.y,er.y=s*_s.x+r*_s.y):er.copy(_s),i.copy(t),i.x+=er.x,i.y+=er.y,i.applyMatrix4(h0)}const jn=new F,Fo=new F,Kr=new F,gi=new F,Oo=new F,Zr=new F,zo=new F;class Ql{constructor(t=new F,e=new F(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,jn)),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=jn.subVectors(t,this.origin).dot(this.direction);return e<0?this.origin.distanceToSquared(t):(jn.copy(this.origin).addScaledVector(this.direction,e),jn.distanceToSquared(t))}distanceSqToSegment(t,e,n,s){Fo.copy(t).add(e).multiplyScalar(.5),Kr.copy(e).sub(t).normalize(),gi.copy(this.origin).sub(Fo);const r=t.distanceTo(e)*.5,a=-this.direction.dot(Kr),o=gi.dot(this.direction),c=-gi.dot(Kr),l=gi.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 x=1/h;u*=x,d*=x,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),s&&s.copy(Fo).addScaledVector(Kr,d),f}intersectSphere(t,e){jn.subVectors(t.center,this.origin);const n=jn.dot(this.direction),s=jn.dot(jn)-n*n,r=t.radius*t.radius;if(s>r)return null;const a=Math.sqrt(r-s),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,s,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,s=(t.max.x-d.x)*l):(n=(t.max.x-d.x)*l,s=(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>s||((r>n||isNaN(n))&&(n=r),(a<s||isNaN(s))&&(s=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>s)||((o>n||n!==n)&&(n=o),(c<s||s!==s)&&(s=c),s<0)?null:this.at(n>=0?n:s,e)}intersectsBox(t){return this.intersectBox(t,jn)!==null}intersectTriangle(t,e,n,s,r){Oo.subVectors(e,t),Zr.subVectors(n,t),zo.crossVectors(Oo,Zr);let a=this.direction.dot(zo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;gi.subVectors(this.origin,t);const c=o*this.direction.dot(Zr.crossVectors(gi,Zr));if(c<0)return null;const l=o*this.direction.dot(Oo.cross(gi));if(l<0||c+l>a)return null;const h=-o*gi.dot(zo);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 Ji extends es{constructor(t){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Mt(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 Ci,this.combine=kl,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 jh=new he,Ui=new Ql,$r=new eo,tu=new F,Jr=new F,Qr=new F,jr=new F,Bo=new F,ta=new F,eu=new F,ea=new F;class se extends Re{constructor(t=new Ee,e=new Ji){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 s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}getVertexPosition(t,e){const n=this.geometry,s=n.attributes.position,r=n.morphAttributes.position,a=n.morphTargetsRelative;e.fromBufferAttribute(s,t);const o=this.morphTargetInfluences;if(r&&o){ta.set(0,0,0);for(let c=0,l=r.length;c<l;c++){const h=o[c],u=r[c];h!==0&&(Bo.fromBufferAttribute(u,t),a?ta.addScaledVector(Bo,h):ta.addScaledVector(Bo.sub(e),h))}e.add(ta)}return e}raycast(t,e){const n=this.geometry,s=this.material,r=this.matrixWorld;s!==void 0&&(n.boundingSphere===null&&n.computeBoundingSphere(),$r.copy(n.boundingSphere),$r.applyMatrix4(r),Ui.copy(t.ray).recast(t.near),!($r.containsPoint(Ui.origin)===!1&&(Ui.intersectSphere($r,tu)===null||Ui.origin.distanceToSquared(tu)>(t.far-t.near)**2))&&(jh.copy(r).invert(),Ui.copy(t.ray).applyMatrix4(jh),!(n.boundingBox!==null&&Ui.intersectsBox(n.boundingBox)===!1)&&this._computeIntersections(t,e,Ui)))}_computeIntersections(t,e,n){let s;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,x=d.length;g<x;g++){const m=d[g],p=a[m.materialIndex],w=Math.max(m.start,f.start),A=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let M=w,S=A;M<S;M+=3){const b=o.getX(M),R=o.getX(M+1),_=o.getX(M+2);s=na(this,p,t,n,l,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),x=Math.min(o.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){const w=o.getX(m),A=o.getX(m+1),M=o.getX(m+2);s=na(this,a,t,n,l,h,u,w,A,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}else if(c!==void 0)if(Array.isArray(a))for(let g=0,x=d.length;g<x;g++){const m=d[g],p=a[m.materialIndex],w=Math.max(m.start,f.start),A=Math.min(c.count,Math.min(m.start+m.count,f.start+f.count));for(let M=w,S=A;M<S;M+=3){const b=M,R=M+1,_=M+2;s=na(this,p,t,n,l,h,u,b,R,_),s&&(s.faceIndex=Math.floor(M/3),s.face.materialIndex=m.materialIndex,e.push(s))}}else{const g=Math.max(0,f.start),x=Math.min(c.count,f.start+f.count);for(let m=g,p=x;m<p;m+=3){const w=m,A=m+1,M=m+2;s=na(this,a,t,n,l,h,u,w,A,M),s&&(s.faceIndex=Math.floor(m/3),e.push(s))}}}}function xm(i,t,e,n,s,r,a,o){let c;if(t.side===Ce?c=n.intersectTriangle(a,r,s,!0,o):c=n.intersectTriangle(s,r,a,t.side===Ti,o),c===null)return null;ea.copy(o),ea.applyMatrix4(i.matrixWorld);const l=e.ray.origin.distanceTo(ea);return l<e.near||l>e.far?null:{distance:l,point:ea.clone(),object:i}}function na(i,t,e,n,s,r,a,o,c,l){i.getVertexPosition(o,Jr),i.getVertexPosition(c,Qr),i.getVertexPosition(l,jr);const h=xm(i,t,e,n,Jr,Qr,jr,eu);if(h){const u=new F;_n.getBarycoord(eu,Jr,Qr,jr,u),s&&(h.uv=_n.getInterpolatedAttribute(s,o,c,l,u,new Ft)),r&&(h.uv1=_n.getInterpolatedAttribute(r,o,c,l,u,new Ft)),a&&(h.normal=_n.getInterpolatedAttribute(a,o,c,l,u,new F),h.normal.dot(n.direction)>0&&h.normal.multiplyScalar(-1));const d={a:o,b:c,c:l,normal:new F,materialIndex:0};_n.getNormal(Jr,Qr,jr,d.normal),h.face=d,h.barycoord=u}return h}class jl extends qe{constructor(t=null,e=1,n=1,s,r,a,o,c,l=ke,h=ke,u,d){super(null,a,o,c,l,h,s,r,u,d),this.isDataTexture=!0,this.image={data:t,width:e,height:n},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const ko=new F,Mm=new F,ym=new zt;class ki{constructor(t=new F(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,s){return this.normal.set(t,e,n),this.constant=s,this}setFromNormalAndCoplanarPoint(t,e){return this.normal.copy(t),this.constant=-e.dot(this.normal),this}setFromCoplanarPoints(t,e,n){const s=ko.subVectors(n,e).cross(Mm.subVectors(t,e)).normalize();return this.setFromNormalAndCoplanarPoint(s,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 s=t.delta(ko),r=this.normal.dot(s);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(s,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||ym.getNormalMatrix(t),s=this.coplanarPoint(ko).applyMatrix4(t),r=this.normal.applyMatrix3(n).normalize();return this.constant=-s.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 Fi=new eo,Sm=new Ft(.5,.5),ia=new F;class th{constructor(t=new ki,e=new ki,n=new ki,s=new ki,r=new ki,a=new ki){this.planes=[t,e,n,s,r,a]}set(t,e,n,s,r,a){const o=this.planes;return o[0].copy(t),o[1].copy(e),o[2].copy(n),o[3].copy(s),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=Wn,n=!1){const s=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],x=r[9],m=r[10],p=r[11],w=r[12],A=r[13],M=r[14],S=r[15];if(s[0].setComponents(l-a,f-h,p-g,S-w).normalize(),s[1].setComponents(l+a,f+h,p+g,S+w).normalize(),s[2].setComponents(l+o,f+u,p+x,S+A).normalize(),s[3].setComponents(l-o,f-u,p-x,S-A).normalize(),n)s[4].setComponents(c,d,m,M).normalize(),s[5].setComponents(l-c,f-d,p-m,S-M).normalize();else if(s[4].setComponents(l-c,f-d,p-m,S-M).normalize(),e===Wn)s[5].setComponents(l+c,f+d,p+m,S+M).normalize();else if(e===Er)s[5].setComponents(c,d,m,M).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+e);return this}intersectsObject(t){if(t.boundingSphere!==void 0)t.boundingSphere===null&&t.computeBoundingSphere(),Fi.copy(t.boundingSphere).applyMatrix4(t.matrixWorld);else{const e=t.geometry;e.boundingSphere===null&&e.computeBoundingSphere(),Fi.copy(e.boundingSphere).applyMatrix4(t.matrixWorld)}return this.intersectsSphere(Fi)}intersectsSprite(t){Fi.center.set(0,0,0);const e=Sm.distanceTo(t.center);return Fi.radius=.7071067811865476+e,Fi.applyMatrix4(t.matrixWorld),this.intersectsSphere(Fi)}intersectsSphere(t){const e=this.planes,n=t.center,s=-t.radius;for(let r=0;r<6;r++)if(e[r].distanceToPoint(n)<s)return!1;return!0}intersectsBox(t){const e=this.planes;for(let n=0;n<6;n++){const s=e[n];if(ia.x=s.normal.x>0?t.max.x:t.min.x,ia.y=s.normal.y>0?t.max.y:t.min.y,ia.z=s.normal.z>0?t.max.z:t.min.z,s.distanceToPoint(ia)<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 u0 extends es{constructor(t){super(),this.isPointsMaterial=!0,this.type="PointsMaterial",this.color=new Mt(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 nu=new he,cl=new Ql,sa=new eo,ra=new F;class Pa extends Re{constructor(t=new Ee,e=new u0){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,s=this.matrixWorld,r=t.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),sa.copy(n.boundingSphere),sa.applyMatrix4(s),sa.radius+=r,t.ray.intersectsSphere(sa)===!1)return;nu.copy(s).invert(),cl.copy(t.ray).applyMatrix4(nu);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,x=f;g<x;g++){const m=l.getX(g);ra.fromBufferAttribute(u,m),iu(ra,m,c,s,t,e,this)}}else{const d=Math.max(0,a.start),f=Math.min(u.count,a.start+a.count);for(let g=d,x=f;g<x;g++)ra.fromBufferAttribute(u,g),iu(ra,g,c,s,t,e,this)}}updateMorphTargets(){const e=this.geometry.morphAttributes,n=Object.keys(e);if(n.length>0){const s=e[n[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r<a;r++){const o=s[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[o]=r}}}}}function iu(i,t,e,n,s,r,a){const o=cl.distanceSqToPoint(i);if(o<e){const c=new F;cl.closestPointToPoint(i,c),c.applyMatrix4(n);const l=s.ray.origin.distanceTo(c);if(l<s.near||l>s.far)return;r.push({distance:l,distanceToRay:Math.sqrt(o),point:c,index:t,face:null,faceIndex:null,barycoord:null,object:a})}}class d0 extends qe{constructor(t=[],e=Zi,n,s,r,a,o,c,l,h){super(t,e,n,s,r,a,o,c,l,h),this.isCubeTexture=!0,this.flipY=!1}get images(){return this.image}set images(t){this.image=t}}class oi extends qe{constructor(t,e,n,s,r,a,o,c,l){super(t,e,n,s,r,a,o,c,l),this.isCanvasTexture=!0,this.needsUpdate=!0}}class Hs extends qe{constructor(t,e,n=Kn,s,r,a,o=ke,c=ke,l,h=ai,u=1){if(h!==ai&&h!==qi)throw new Error("THREE.DepthTexture: format must be either THREE.DepthFormat or THREE.DepthStencilFormat");const d={width:t,height:e,depth:u};super(d,s,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 Zl(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 Em extends Hs{constructor(t,e=Kn,n=Zi,s,r,a=ke,o=ke,c,l=ai){const h={width:t,height:t,depth:1},u=[h,h,h,h,h,h];super(t,t,e,n,s,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 f0 extends qe{constructor(t=null){super(),this.sourceTexture=t,this.isExternalTexture=!0}copy(t){return super.copy(t),this.sourceTexture=t.sourceTexture,this}}class Mn extends Ee{constructor(t=1,e=1,n=1,s=1,r=1,a=1){super(),this.type="BoxGeometry",this.parameters={width:t,height:e,depth:n,widthSegments:s,heightSegments:r,depthSegments:a};const o=this;s=Math.floor(s),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,s,a,2),g("x","z","y",1,-1,t,n,-e,s,a,3),g("x","y","z",1,-1,t,e,n,s,r,4),g("x","y","z",-1,-1,t,e,-n,s,r,5),this.setIndex(c),this.setAttribute("position",new De(l,3)),this.setAttribute("normal",new De(h,3)),this.setAttribute("uv",new De(u,2));function g(x,m,p,w,A,M,S,b,R,_,E){const D=M/R,C=S/_,I=M/2,W=S/2,X=b/2,U=R+1,q=_+1;let H=0,$=0;const et=new F;for(let j=0;j<q;j++){const it=j*C-W;for(let ut=0;ut<U;ut++){const kt=ut*D-I;et[x]=kt*w,et[m]=it*A,et[p]=X,l.push(et.x,et.y,et.z),et[x]=0,et[m]=0,et[p]=b>0?1:-1,h.push(et.x,et.y,et.z),u.push(ut/R),u.push(1-j/_),H+=1}}for(let j=0;j<_;j++)for(let it=0;it<R;it++){const ut=d+it+U*j,kt=d+it+U*(j+1),qt=d+(it+1)+U*(j+1),Bt=d+(it+1)+U*j;c.push(ut,kt,Bt),c.push(kt,qt,Bt),$+=6}o.addGroup(f,$,E),f+=$,d+=H}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Mn(t.width,t.height,t.depth,t.widthSegments,t.heightSegments,t.depthSegments)}}class eh extends Ee{constructor(t=1,e=32,n=0,s=Math.PI*2){super(),this.type="CircleGeometry",this.parameters={radius:t,segments:e,thetaStart:n,thetaLength:s},e=Math.max(3,e);const r=[],a=[],o=[],c=[],l=new F,h=new Ft;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*s;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 De(a,3)),this.setAttribute("normal",new De(o,3)),this.setAttribute("uv",new De(c,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new eh(t.radius,t.segments,t.thetaStart,t.thetaLength)}}class Pi extends Ee{constructor(t=1,e=1,n=1,s=32,r=1,a=!1,o=0,c=Math.PI*2){super(),this.type="CylinderGeometry",this.parameters={radiusTop:t,radiusBottom:e,height:n,radialSegments:s,heightSegments:r,openEnded:a,thetaStart:o,thetaLength:c};const l=this;s=Math.floor(s),r=Math.floor(r);const h=[],u=[],d=[],f=[];let g=0;const x=[],m=n/2;let p=0;w(),a===!1&&(t>0&&A(!0),e>0&&A(!1)),this.setIndex(h),this.setAttribute("position",new De(u,3)),this.setAttribute("normal",new De(d,3)),this.setAttribute("uv",new De(f,2));function w(){const M=new F,S=new F;let b=0;const R=(e-t)/n;for(let _=0;_<=r;_++){const E=[],D=_/r,C=D*(e-t)+t;for(let I=0;I<=s;I++){const W=I/s,X=W*c+o,U=Math.sin(X),q=Math.cos(X);S.x=C*U,S.y=-D*n+m,S.z=C*q,u.push(S.x,S.y,S.z),M.set(U,R,q).normalize(),d.push(M.x,M.y,M.z),f.push(W,1-D),E.push(g++)}x.push(E)}for(let _=0;_<s;_++)for(let E=0;E<r;E++){const D=x[E][_],C=x[E+1][_],I=x[E+1][_+1],W=x[E][_+1];(t>0||E!==0)&&(h.push(D,C,W),b+=3),(e>0||E!==r-1)&&(h.push(C,I,W),b+=3)}l.addGroup(p,b,0),p+=b}function A(M){const S=g,b=new Ft,R=new F;let _=0;const E=M===!0?t:e,D=M===!0?1:-1;for(let I=1;I<=s;I++)u.push(0,m*D,0),d.push(0,D,0),f.push(.5,.5),g++;const C=g;for(let I=0;I<=s;I++){const X=I/s*c+o,U=Math.cos(X),q=Math.sin(X);R.x=E*q,R.y=m*D,R.z=E*U,u.push(R.x,R.y,R.z),d.push(0,D,0),b.x=U*.5+.5,b.y=q*.5*D+.5,f.push(b.x,b.y),g++}for(let I=0;I<s;I++){const W=S+I,X=C+I;M===!0?h.push(X,X+1,W):h.push(X+1,X,W),_+=3}l.addGroup(p,_,M===!0?1:2),p+=_}}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Pi(t.radiusTop,t.radiusBottom,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class no extends Pi{constructor(t=1,e=1,n=32,s=1,r=!1,a=0,o=Math.PI*2){super(0,t,e,n,s,r,a,o),this.type="ConeGeometry",this.parameters={radius:t,height:e,radialSegments:n,heightSegments:s,openEnded:r,thetaStart:a,thetaLength:o}}static fromJSON(t){return new no(t.radius,t.height,t.radialSegments,t.heightSegments,t.openEnded,t.thetaStart,t.thetaLength)}}class qs extends Ee{constructor(t=1,e=1,n=1,s=1){super(),this.type="PlaneGeometry",this.parameters={width:t,height:e,widthSegments:n,heightSegments:s};const r=t/2,a=e/2,o=Math.floor(n),c=Math.floor(s),l=o+1,h=c+1,u=t/o,d=e/c,f=[],g=[],x=[],m=[];for(let p=0;p<h;p++){const w=p*d-a;for(let A=0;A<l;A++){const M=A*u-r;g.push(M,-w,0),x.push(0,0,1),m.push(A/o),m.push(1-p/c)}}for(let p=0;p<c;p++)for(let w=0;w<o;w++){const A=w+l*p,M=w+l*(p+1),S=w+1+l*(p+1),b=w+1+l*p;f.push(A,M,b),f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(x,3)),this.setAttribute("uv",new De(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new qs(t.width,t.height,t.widthSegments,t.heightSegments)}}class Cn extends Ee{constructor(t=1,e=32,n=16,s=0,r=Math.PI*2,a=0,o=Math.PI){super(),this.type="SphereGeometry",this.parameters={radius:t,widthSegments:e,heightSegments:n,phiStart:s,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 F,d=new F,f=[],g=[],x=[],m=[];for(let p=0;p<=n;p++){const w=[],A=p/n,M=a+A*o,S=t*Math.cos(M),b=Math.sqrt(t*t-S*S);let R=0;p===0&&a===0?R=.5/e:p===n&&c===Math.PI&&(R=-.5/e);for(let _=0;_<=e;_++){const E=_/e,D=s+E*r;u.x=-b*Math.cos(D),u.y=S,u.z=b*Math.sin(D),g.push(u.x,u.y,u.z),d.copy(u).normalize(),x.push(d.x,d.y,d.z),m.push(E+R,1-A),w.push(l++)}h.push(w)}for(let p=0;p<n;p++)for(let w=0;w<e;w++){const A=h[p][w+1],M=h[p][w],S=h[p+1][w],b=h[p+1][w+1];(p!==0||a>0)&&f.push(A,M,b),(p!==n-1||c<Math.PI)&&f.push(M,S,b)}this.setIndex(f),this.setAttribute("position",new De(g,3)),this.setAttribute("normal",new De(x,3)),this.setAttribute("uv",new De(m,2))}copy(t){return super.copy(t),this.parameters=Object.assign({},t.parameters),this}static fromJSON(t){return new Cn(t.radius,t.widthSegments,t.heightSegments,t.phiStart,t.phiLength,t.thetaStart,t.thetaLength)}}function Vs(i){const t={};for(const e in i){t[e]={};for(const n in i[e]){const s=i[e][n];if(su(s))s.isRenderTargetTexture?(Ot("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),t[e][n]=null):t[e][n]=s.clone();else if(Array.isArray(s))if(su(s[0])){const r=[];for(let a=0,o=s.length;a<o;a++)r[a]=s[a].clone();t[e][n]=r}else t[e][n]=s.slice();else t[e][n]=s}}return t}function Ke(i){const t={};for(let e=0;e<i.length;e++){const n=Vs(i[e]);for(const s in n)t[s]=n[s]}return t}function su(i){return i&&(i.isColor||i.isMatrix3||i.isMatrix4||i.isVector2||i.isVector3||i.isVector4||i.isTexture||i.isQuaternion)}function bm(i){const t=[];for(let e=0;e<i.length;e++)t.push(i[e].clone());return t}function p0(i){const t=i.getRenderTarget();return t===null?i.outputColorSpace:t.isXRRenderTarget===!0?t.texture.colorSpace:Kt.workingColorSpace}const wm={clone:Vs,merge:Ke};var Am=`void main() {
|
|
568
568
|
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
569
|
-
}`,
|
|
569
|
+
}`,Tm=`void main() {
|
|
570
570
|
gl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );
|
|
571
|
-
}`;class Ft extends qi{constructor(e){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=om,this.fragmentShader=lm,this.linewidth=1,this.wireframe=!1,this.wireframeLinewidth=1,this.fog=!1,this.lights=!1,this.clipping=!1,this.forceSinglePass=!0,this.extensions={clipCullDistance:!1,multiDraw:!1},this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv1:[0,0]},this.index0AttributeName=void 0,this.uniformsNeedUpdate=!1,this.glslVersion=null,e!==void 0&&this.setValues(e)}copy(e){return super.copy(e),this.fragmentShader=e.fragmentShader,this.vertexShader=e.vertexShader,this.uniforms=Ls(e.uniforms),this.uniformsGroups=rm(e.uniformsGroups),this.defines=Object.assign({},e.defines),this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.fog=e.fog,this.lights=e.lights,this.clipping=e.clipping,this.extensions=Object.assign({},e.extensions),this.glslVersion=e.glslVersion,this.defaultAttributeValues=Object.assign({},e.defaultAttributeValues),this.index0AttributeName=e.index0AttributeName,this.uniformsNeedUpdate=e.uniformsNeedUpdate,this}toJSON(e){const t=super.toJSON(e);t.glslVersion=this.glslVersion,t.uniforms={};for(const s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?t.uniforms[s]={type:"t",value:a.toJSON(e).uuid}:a&&a.isColor?t.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?t.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?t.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?t.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?t.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?t.uniforms[s]={type:"m4",value:a.toArray()}:t.uniforms[s]={value:a}}Object.keys(this.defines).length>0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const n={};for(const s in this.extensions)this.extensions[s]===!0&&(n[s]=!0);return Object.keys(n).length>0&&(t.extensions=n),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const n in e.uniforms){const s=e.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=t[s.value]||null;break;case"c":this.uniforms[n].value=new xe().setHex(s.value);break;case"v2":this.uniforms[n].value=new Fe().fromArray(s.value);break;case"v3":this.uniforms[n].value=new U().fromArray(s.value);break;case"v4":this.uniforms[n].value=new ft().fromArray(s.value);break;case"m3":this.uniforms[n].value=new ze().fromArray(s.value);break;case"m4":this.uniforms[n].value=new ht().fromArray(s.value);break;default:this.uniforms[n].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const n in e.extensions)this.extensions[n]=e.extensions[n];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class cm extends Ft{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class pr extends qi{constructor(e){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new xe(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new xe(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=ql,this.normalScale=new Fe(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new xi,this.combine=Ac,this.reflectivity=1,this.envMapIntensity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.flatShading=!1,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.emissive.copy(e.emissive),this.emissiveMap=e.emissiveMap,this.emissiveIntensity=e.emissiveIntensity,this.bumpMap=e.bumpMap,this.bumpScale=e.bumpScale,this.normalMap=e.normalMap,this.normalMapType=e.normalMapType,this.normalScale.copy(e.normalScale),this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.envMapIntensity=e.envMapIntensity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.fog=e.fog,this}}class hm extends qi{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Sp,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class um extends qi{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Gc extends wt{constructor(e,t=1){super(),this.isLight=!0,this.type="Light",this.color=new xe(e),this.intensity=t}dispose(){this.dispatchEvent({type:"dispose"})}copy(e,t){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this}toJSON(e){const t=super.toJSON(e);return t.object.color=this.color.getHex(),t.object.intensity=this.intensity,t}}class dm extends Gc{constructor(e,t,n){super(e,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.groundColor=new xe(t)}copy(e,t){return super.copy(e,t),this.groundColor.copy(e.groundColor),this}toJSON(e){const t=super.toJSON(e);return t.object.groundColor=this.groundColor.getHex(),t}}const Ro=new ht,Xh=new U,qh=new U;class Qd{constructor(e){this.camera=e,this.intensity=1,this.bias=0,this.biasNode=null,this.normalBias=0,this.radius=1,this.blurSamples=8,this.mapSize=new Fe(512,512),this.mapType=nn,this.map=null,this.mapPass=null,this.matrix=new ht,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new Bc,this._frameExtents=new Fe(1,1),this._viewportCount=1,this._viewports=[new ft(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(e){const t=this.camera,n=this.matrix;Xh.setFromMatrixPosition(e.matrixWorld),t.position.copy(Xh),qh.setFromMatrixPosition(e.target.matrixWorld),t.lookAt(qh),t.updateMatrixWorld(),Ro.multiplyMatrices(t.projectionMatrix,t.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Ro,t.coordinateSystem,t.reversedDepth),t.coordinateSystem===dr||t.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(Ro)}getViewport(e){return this._viewports[e]}getFrameExtents(){return this._frameExtents}dispose(){this.map&&this.map.dispose(),this.mapPass&&this.mapPass.dispose()}copy(e){return this.camera=e.camera.clone(),this.intensity=e.intensity,this.bias=e.bias,this.radius=e.radius,this.autoUpdate=e.autoUpdate,this.needsUpdate=e.needsUpdate,this.normalBias=e.normalBias,this.blurSamples=e.blurSamples,this.mapSize.copy(e.mapSize),this.biasNode=e.biasNode,this}clone(){return new this.constructor().copy(this)}toJSON(){const e={};return this.intensity!==1&&(e.intensity=this.intensity),this.bias!==0&&(e.bias=this.bias),this.normalBias!==0&&(e.normalBias=this.normalBias),this.radius!==1&&(e.radius=this.radius),(this.mapSize.x!==512||this.mapSize.y!==512)&&(e.mapSize=this.mapSize.toArray()),e.camera=this.camera.toJSON(!1).object,delete e.camera.matrix,e}}const Kr=new U,Zr=new Us,bn=new U;class jd extends wt{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new ht,this.projectionMatrix=new ht,this.projectionMatrixInverse=new ht,this.coordinateSystem=Nn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(Kr,Zr,bn),bn.x===1&&bn.y===1&&bn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Kr,Zr,bn.set(1,1,1)).invert()}updateWorldMatrix(e,t,n=!1){super.updateWorldMatrix(e,t,n),this.matrixWorld.decompose(Kr,Zr,bn),bn.x===1&&bn.y===1&&bn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(Kr,Zr,bn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const li=new U,Yh=new Fe,Kh=new Fe;class tn extends jd{constructor(e=50,t=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=n,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=Kl*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(no*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return Kl*2*Math.atan(Math.tan(no*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,n){li.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(li.x,li.y).multiplyScalar(-e/li.z),li.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(li.x,li.y).multiplyScalar(-e/li.z)}getViewSize(e,t){return this.getViewBounds(e,Yh,Kh),t.subVectors(Kh,Yh)}setViewOffset(e,t,n,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(no*.5*this.fov)/this.zoom,n=2*t,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*n/c,s*=a.width/l,n*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-n,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class fm extends Qd{constructor(){super(new tn(90,1,.5,500)),this.isPointLightShadow=!0}}class pm extends Gc{constructor(e,t,n=0,s=2){super(e,t),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new fm}get power(){return this.intensity*4*Math.PI}set power(e){this.intensity=e/(4*Math.PI)}dispose(){super.dispose(),this.shadow.dispose()}copy(e,t){return super.copy(e,t),this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.distance=this.distance,t.object.decay=this.decay,t.object.shadow=this.shadow.toJSON(),t}}class Wa extends jd{constructor(e=-1,t=1,n=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=n,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,n,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=n,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),n=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=n-e,a=n+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,h=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=h*this.view.offsetY,l=o-h*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}class mm extends Qd{constructor(){super(new Wa(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class gm extends Gc{constructor(e,t){super(e,t),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(wt.DEFAULT_UP),this.updateMatrix(),this.target=new wt,this.shadow=new mm}dispose(){super.dispose(),this.shadow.dispose()}copy(e){return super.copy(e),this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e);return t.object.shadow=this.shadow.toJSON(),t.object.target=this.target.uuid,t}}const hs=-90,us=1;class vm extends wt{constructor(e,t,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new tn(hs,us,e,t);s.layers=this.layers,this.add(s);const r=new tn(hs,us,e,t);r.layers=this.layers,this.add(r);const a=new tn(hs,us,e,t);a.layers=this.layers,this.add(a);const o=new tn(hs,us,e,t);o.layers=this.layers,this.add(o);const l=new tn(hs,us,e,t);l.layers=this.layers,this.add(l);const c=new tn(hs,us,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[n,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Nn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.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),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===dr)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.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),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:n,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,h]=this.children,u=e.getRenderTarget(),d=e.getActiveCubeFace(),p=e.getActiveMipmapLevel(),g=e.xr.enabled;e.xr.enabled=!1;const x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(n,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(n,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(n,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(n,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(n,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),n.texture.generateMipmaps=x,e.setRenderTarget(n,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,h),e.setRenderTarget(u,d,p),e.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class _m extends tn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}const Zh=new ht;class Co{constructor(e,t,n=0,s=1/0){this.ray=new zc(e,t),this.near=n,this.far=s,this.camera=null,this.layers=new Fc,this.params={Mesh:{},Line:{threshold:1},LOD:{},Points:{threshold:1},Sprite:{}}}set(e,t){this.ray.set(e,t)}setFromCamera(e,t){t.isPerspectiveCamera?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):t.isOrthographicCamera?(this.ray.origin.set(e.x,e.y,t.projectionMatrix.elements[14]).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):qe("Raycaster: Unsupported camera type: "+t.type)}setFromXRController(e){return Zh.identity().extractRotation(e.matrixWorld),this.ray.origin.setFromMatrixPosition(e.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(Zh),this}intersectObject(e,t=!0,n=[]){return $l(e,this,n,t),n.sort($h),n}intersectObjects(e,t=!0,n=[]){for(let s=0,r=e.length;s<r;s++)$l(e[s],this,n,t);return n.sort($h),n}}function $h(i,e){return i.distance-e.distance}function $l(i,e,t,n){let s=!0;if(i.layers.test(e.layers)&&i.raycast(e,t)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)$l(r[a],e,t,!0)}}class e0{static{e0.prototype.isMatrix2=!0}constructor(e,t,n,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,n,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let n=0;n<4;n++)this.elements[n]=e[n+t];return this}set(e,t,n,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=n,r[3]=s,this}}function Jh(i,e,t,n){const s=xm(n);switch(t){case zd:return i*e;case kd:return i*e/s.components*s.byteLength;case Dc:return i*e/s.components*s.byteLength;case Gi:return i*e*2/s.components*s.byteLength;case Pc:return i*e*2/s.components*s.byteLength;case Bd:return i*e*3/s.components*s.byteLength;case _n:return i*e*4/s.components*s.byteLength;case Ic:return i*e*4/s.components*s.byteLength;case ma:case ga:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case va:case _a:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case vl:case xl:return Math.max(i,16)*Math.max(e,8)/4;case gl:case _l:return Math.max(i,8)*Math.max(e,8)/2;case Ml:case yl:case El:case bl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*8;case Sl:case ba:case wl:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Al:return Math.floor((i+3)/4)*Math.floor((e+3)/4)*16;case Tl:return Math.floor((i+4)/5)*Math.floor((e+3)/4)*16;case Rl:return Math.floor((i+4)/5)*Math.floor((e+4)/5)*16;case Cl:return Math.floor((i+5)/6)*Math.floor((e+4)/5)*16;case Dl:return Math.floor((i+5)/6)*Math.floor((e+5)/6)*16;case Pl:return Math.floor((i+7)/8)*Math.floor((e+4)/5)*16;case Il:return Math.floor((i+7)/8)*Math.floor((e+5)/6)*16;case Ll:return Math.floor((i+7)/8)*Math.floor((e+7)/8)*16;case Nl:return Math.floor((i+9)/10)*Math.floor((e+4)/5)*16;case Ul:return Math.floor((i+9)/10)*Math.floor((e+5)/6)*16;case Fl:return Math.floor((i+9)/10)*Math.floor((e+7)/8)*16;case Ol:return Math.floor((i+9)/10)*Math.floor((e+9)/10)*16;case zl:return Math.floor((i+11)/12)*Math.floor((e+9)/10)*16;case Bl:return Math.floor((i+11)/12)*Math.floor((e+11)/12)*16;case kl:case Gl:case Hl:return Math.ceil(i/4)*Math.ceil(e/4)*16;case Vl:case Wl:return Math.ceil(i/4)*Math.ceil(e/4)*8;case wa:case Xl:return Math.ceil(i/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function xm(i){switch(i){case nn:case Nd:return{byteLength:1,components:1};case hr:case Ud:case Jn:return{byteLength:2,components:1};case Rc:case Cc:return{byteLength:2,components:4};case zn:case Tc:case Ln:return{byteLength:4,components:1};case Fd:case Od:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:wc}}));typeof window<"u"&&(window.__THREE__?Oe("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=wc);/**
|
|
571
|
+
}`;class Be extends es{constructor(t){super(),this.isShaderMaterial=!0,this.type="ShaderMaterial",this.defines={},this.uniforms={},this.uniformsGroups=[],this.vertexShader=Am,this.fragmentShader=Tm,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=Vs(t.uniforms),this.uniformsGroups=bm(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 s in this.uniforms){const a=this.uniforms[s].value;a&&a.isTexture?e.uniforms[s]={type:"t",value:a.toJSON(t).uuid}:a&&a.isColor?e.uniforms[s]={type:"c",value:a.getHex()}:a&&a.isVector2?e.uniforms[s]={type:"v2",value:a.toArray()}:a&&a.isVector3?e.uniforms[s]={type:"v3",value:a.toArray()}:a&&a.isVector4?e.uniforms[s]={type:"v4",value:a.toArray()}:a&&a.isMatrix3?e.uniforms[s]={type:"m3",value:a.toArray()}:a&&a.isMatrix4?e.uniforms[s]={type:"m4",value:a.toArray()}:e.uniforms[s]={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 s in this.extensions)this.extensions[s]===!0&&(n[s]=!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 s=t.uniforms[n];switch(this.uniforms[n]={},s.type){case"t":this.uniforms[n].value=e[s.value]||null;break;case"c":this.uniforms[n].value=new Mt().setHex(s.value);break;case"v2":this.uniforms[n].value=new Ft().fromArray(s.value);break;case"v3":this.uniforms[n].value=new F().fromArray(s.value);break;case"v4":this.uniforms[n].value=new pe().fromArray(s.value);break;case"m3":this.uniforms[n].value=new zt().fromArray(s.value);break;case"m4":this.uniforms[n].value=new he().fromArray(s.value);break;default:this.uniforms[n].value=s.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 Rm extends Be{constructor(t){super(t),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Ar extends es{constructor(t){super(),this.isMeshLambertMaterial=!0,this.type="MeshLambertMaterial",this.color=new Mt(16777215),this.map=null,this.lightMap=null,this.lightMapIntensity=1,this.aoMap=null,this.aoMapIntensity=1,this.emissive=new Mt(0),this.emissiveIntensity=1,this.emissiveMap=null,this.bumpMap=null,this.bumpScale=1,this.normalMap=null,this.normalMapType=rl,this.normalScale=new Ft(1,1),this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.specularMap=null,this.alphaMap=null,this.envMap=null,this.envMapRotation=new Ci,this.combine=kl,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 Cm extends es{constructor(t){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=Bp,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 Dm extends es{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}}class nh extends Re{constructor(t,e=1){super(),this.isLight=!0,this.type="Light",this.color=new Mt(t),this.intensity=e}dispose(){this.dispatchEvent({type:"dispose"})}copy(t,e){return super.copy(t,e),this.color.copy(t.color),this.intensity=t.intensity,this}toJSON(t){const e=super.toJSON(t);return e.object.color=this.color.getHex(),e.object.intensity=this.intensity,e}}class Pm extends nh{constructor(t,e,n){super(t,n),this.isHemisphereLight=!0,this.type="HemisphereLight",this.position.copy(Re.DEFAULT_UP),this.updateMatrix(),this.groundColor=new Mt(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 Go=new he,ru=new F,au=new F;class m0{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 Ft(512,512),this.mapType=ln,this.map=null,this.mapPass=null,this.matrix=new he,this.autoUpdate=!0,this.needsUpdate=!1,this._frustum=new th,this._frameExtents=new Ft(1,1),this._viewportCount=1,this._viewports=[new pe(0,0,1,1)]}getViewportCount(){return this._viewportCount}getFrustum(){return this._frustum}updateMatrices(t){const e=this.camera,n=this.matrix;ru.setFromMatrixPosition(t.matrixWorld),e.position.copy(ru),au.setFromMatrixPosition(t.target.matrixWorld),e.lookAt(au),e.updateMatrixWorld(),Go.multiplyMatrices(e.projectionMatrix,e.matrixWorldInverse),this._frustum.setFromProjectionMatrix(Go,e.coordinateSystem,e.reversedDepth),e.coordinateSystem===Er||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(Go)}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 aa=new F,oa=new Xs,Ln=new F;class g0 extends Re{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new he,this.projectionMatrix=new he,this.projectionMatrixInverse=new he,this.coordinateSystem=Wn,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(aa,oa,Ln),Ln.x===1&&Ln.y===1&&Ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(aa,oa,Ln.set(1,1,1)).invert()}updateWorldMatrix(t,e,n=!1){super.updateWorldMatrix(t,e,n),this.matrixWorld.decompose(aa,oa,Ln),Ln.x===1&&Ln.y===1&&Ln.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(aa,oa,Ln.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const vi=new F,ou=new Ft,cu=new Ft;class cn extends g0{constructor(t=50,e=1,n=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=t,this.zoom=1,this.near=n,this.far=s,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=ol*2*Math.atan(e),this.updateProjectionMatrix()}getFocalLength(){const t=Math.tan(go*.5*this.fov);return .5*this.getFilmHeight()/t}getEffectiveFOV(){return ol*2*Math.atan(Math.tan(go*.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){vi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),e.set(vi.x,vi.y).multiplyScalar(-t/vi.z),vi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),n.set(vi.x,vi.y).multiplyScalar(-t/vi.z)}getViewSize(t,e){return this.getViewBounds(t,ou,cu),e.subVectors(cu,ou)}setViewOffset(t,e,n,s,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=s,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(go*.5*this.fov)/this.zoom,n=2*e,s=this.aspect*n,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const c=a.fullWidth,l=a.fullHeight;r+=a.offsetX*s/c,e-=a.offsetY*n/l,s*=a.width/c,n*=a.height/l}const o=this.filmOffset;o!==0&&(r+=t*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,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 Im extends m0{constructor(){super(new cn(90,1,.5,500)),this.isPointLightShadow=!0}}class Lm extends nh{constructor(t,e,n=0,s=2){super(t,e),this.isPointLight=!0,this.type="PointLight",this.distance=n,this.decay=s,this.shadow=new Im}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 io extends g0{constructor(t=-1,e=1,n=1,s=-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=s,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,s,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=s,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,s=(this.top+this.bottom)/2;let r=n-t,a=n+t,o=s+e,c=s-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 Nm extends m0{constructor(){super(new io(-5,5,5,-5,.5,500)),this.isDirectionalLightShadow=!0}}class Um extends nh{constructor(t,e){super(t,e),this.isDirectionalLight=!0,this.type="DirectionalLight",this.position.copy(Re.DEFAULT_UP),this.updateMatrix(),this.target=new Re,this.shadow=new Nm}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}}const xs=-90,Ms=1;class Fm extends Re{constructor(t,e,n){super(),this.type="CubeCamera",this.renderTarget=n,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new cn(xs,Ms,t,e);s.layers=this.layers,this.add(s);const r=new cn(xs,Ms,t,e);r.layers=this.layers,this.add(r);const a=new cn(xs,Ms,t,e);a.layers=this.layers,this.add(a);const o=new cn(xs,Ms,t,e);o.layers=this.layers,this.add(o);const c=new cn(xs,Ms,t,e);c.layers=this.layers,this.add(c);const l=new cn(xs,Ms,t,e);l.layers=this.layers,this.add(l)}updateCoordinateSystem(){const t=this.coordinateSystem,e=this.children.concat(),[n,s,r,a,o,c]=e;for(const l of e)this.remove(l);if(t===Wn)n.up.set(0,1,0),n.lookAt(1,0,0),s.up.set(0,1,0),s.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===Er)n.up.set(0,-1,0),n.lookAt(-1,0,0),s.up.set(0,-1,0),s.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:s}=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 x=n.texture.generateMipmaps;n.texture.generateMipmaps=!1;let m=!1;t.isWebGLRenderer===!0?m=t.state.buffers.depth.getReversed():m=t.reversedDepthBuffer,t.setRenderTarget(n,0,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,r),t.setRenderTarget(n,1,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,a),t.setRenderTarget(n,2,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,o),t.setRenderTarget(n,3,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,c),t.setRenderTarget(n,4,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,l),n.texture.generateMipmaps=x,t.setRenderTarget(n,5,s),m&&t.autoClear===!1&&t.clearDepth(),t.render(e,h),t.setRenderTarget(u,d,f),t.xr.enabled=g,n.texture.needsPMREMUpdate=!0}}class Om extends cn{constructor(t=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=t}}const lu=new he;class Ho{constructor(t,e,n=0,s=1/0){this.ray=new Ql(t,e),this.near=n,this.far=s,this.camera=null,this.layers=new $l,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):Yt("Raycaster: Unsupported camera type: "+e.type)}setFromXRController(t){return lu.identity().extractRotation(t.matrixWorld),this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(0,0,-1).applyMatrix4(lu),this}intersectObject(t,e=!0,n=[]){return ll(t,this,n,e),n.sort(hu),n}intersectObjects(t,e=!0,n=[]){for(let s=0,r=t.length;s<r;s++)ll(t[s],this,n,e);return n.sort(hu),n}}function hu(i,t){return i.distance-t.distance}function ll(i,t,e,n){let s=!0;if(i.layers.test(t.layers)&&i.raycast(t,e)===!1&&(s=!1),s===!0&&n===!0){const r=i.children;for(let a=0,o=r.length;a<o;a++)ll(r[a],t,e,!0)}}class v0{static{v0.prototype.isMatrix2=!0}constructor(t,e,n,s){this.elements=[1,0,0,1],t!==void 0&&this.set(t,e,n,s)}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,s){const r=this.elements;return r[0]=t,r[2]=e,r[1]=n,r[3]=s,this}}function uu(i,t,e,n){const s=zm(n);switch(e){case e0:return i*t;case i0:return i*t/s.components*s.byteLength;case Wl:return i*t/s.components*s.byteLength;case $i:return i*t*2/s.components*s.byteLength;case Xl:return i*t*2/s.components*s.byteLength;case n0:return i*t*3/s.components*s.byteLength;case un:return i*t*4/s.components*s.byteLength;case ql:return i*t*4/s.components*s.byteLength;case Ta:case Ra:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Ca:case Da:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Dc:case Ic:return Math.max(i,16)*Math.max(t,8)/4;case Cc:case Pc:return Math.max(i,8)*Math.max(t,8)/2;case Lc:case Nc:case Fc:case Oc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*8;case Uc:case Fa:case zc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case Bc:return Math.floor((i+3)/4)*Math.floor((t+3)/4)*16;case kc:return Math.floor((i+4)/5)*Math.floor((t+3)/4)*16;case Gc:return Math.floor((i+4)/5)*Math.floor((t+4)/5)*16;case Hc:return Math.floor((i+5)/6)*Math.floor((t+4)/5)*16;case Vc:return Math.floor((i+5)/6)*Math.floor((t+5)/6)*16;case Wc:return Math.floor((i+7)/8)*Math.floor((t+4)/5)*16;case Xc:return Math.floor((i+7)/8)*Math.floor((t+5)/6)*16;case qc:return Math.floor((i+7)/8)*Math.floor((t+7)/8)*16;case Yc:return Math.floor((i+9)/10)*Math.floor((t+4)/5)*16;case Kc:return Math.floor((i+9)/10)*Math.floor((t+5)/6)*16;case Zc:return Math.floor((i+9)/10)*Math.floor((t+7)/8)*16;case $c:return Math.floor((i+9)/10)*Math.floor((t+9)/10)*16;case Jc:return Math.floor((i+11)/12)*Math.floor((t+9)/10)*16;case Qc:return Math.floor((i+11)/12)*Math.floor((t+11)/12)*16;case jc:case tl:case el:return Math.ceil(i/4)*Math.ceil(t/4)*16;case nl:case il:return Math.ceil(i/4)*Math.ceil(t/4)*8;case Oa:case sl:return Math.ceil(i/4)*Math.ceil(t/4)*16}throw new Error(`Unable to determine texture byte length for ${e} format.`)}function zm(i){switch(i){case ln:case Jd:return{byteLength:1,components:1};case yr:case Qd:case xn:return{byteLength:2,components:1};case Hl:case Vl:return{byteLength:2,components:4};case Kn:case Gl:case Vn:return{byteLength:4,components:1};case jd:case t0:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${i}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Bl}}));typeof window<"u"&&(window.__THREE__?Ot("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Bl);/**
|
|
572
572
|
* @license
|
|
573
573
|
* Copyright 2010-2026 Three.js Authors
|
|
574
574
|
* SPDX-License-Identifier: MIT
|
|
575
|
-
*/function
|
|
575
|
+
*/function _0(){let i=null,t=!1,e=null,n=null;function s(r,a){e(r,a),n=i.requestAnimationFrame(s)}return{start:function(){t!==!0&&e!==null&&i!==null&&(n=i.requestAnimationFrame(s),t=!0)},stop:function(){i!==null&&i.cancelAnimationFrame(n),t=!1},setAnimationLoop:function(r){e=r},setContext:function(r){i=r}}}function Bm(i){const t=new WeakMap;function e(o,c){const l=o.array,h=o.usage,u=l.byteLength,d=i.createBuffer();i.bindBuffer(c,d),i.bufferData(c,l,h),o.onUploadCallback();let f;if(l instanceof Float32Array)f=i.FLOAT;else if(typeof Float16Array<"u"&&l instanceof Float16Array)f=i.HALF_FLOAT;else if(l instanceof Uint16Array)o.isFloat16BufferAttribute?f=i.HALF_FLOAT:f=i.UNSIGNED_SHORT;else if(l instanceof Int16Array)f=i.SHORT;else if(l instanceof Uint32Array)f=i.UNSIGNED_INT;else if(l instanceof Int32Array)f=i.INT;else if(l instanceof Int8Array)f=i.BYTE;else if(l instanceof Uint8Array)f=i.UNSIGNED_BYTE;else if(l instanceof Uint8ClampedArray)f=i.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(i.bindBuffer(l,o),u.length===0)i.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],x=u[f];x.start<=g.start+g.count+1?g.count=Math.max(g.count,x.start+x.count-g.start):(++d,u[d]=x)}u.length=d+1;for(let f=0,g=u.length;f<g;f++){const x=u[f];i.bufferSubData(l,x.start*h.BYTES_PER_ELEMENT,h,x.start,x.count)}c.clearUpdateRanges()}c.onUploadCallback()}function s(o){return o.isInterleavedBufferAttribute&&(o=o.data),t.get(o)}function r(o){o.isInterleavedBufferAttribute&&(o=o.data);const c=t.get(o);c&&(i.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:s,remove:r,update:a}}var km=`#ifdef USE_ALPHAHASH
|
|
576
576
|
if ( diffuseColor.a < getAlphaHashThreshold( vPosition ) ) discard;
|
|
577
|
-
#endif`,
|
|
577
|
+
#endif`,Gm=`#ifdef USE_ALPHAHASH
|
|
578
578
|
const float ALPHA_HASH_SCALE = 0.05;
|
|
579
579
|
float hash2D( vec2 value ) {
|
|
580
580
|
return fract( 1.0e4 * sin( 17.0 * value.x + 0.1 * value.y ) * ( 0.1 + abs( sin( 13.0 * value.y + value.x ) ) ) );
|
|
@@ -609,20 +609,20 @@ input[type=range] {
|
|
|
609
609
|
: cases.z;
|
|
610
610
|
return clamp( threshold , 1.0e-6, 1.0 );
|
|
611
611
|
}
|
|
612
|
-
#endif`,
|
|
612
|
+
#endif`,Hm=`#ifdef USE_ALPHAMAP
|
|
613
613
|
diffuseColor.a *= texture2D( alphaMap, vAlphaMapUv ).g;
|
|
614
|
-
#endif`,
|
|
614
|
+
#endif`,Vm=`#ifdef USE_ALPHAMAP
|
|
615
615
|
uniform sampler2D alphaMap;
|
|
616
|
-
#endif`,
|
|
616
|
+
#endif`,Wm=`#ifdef USE_ALPHATEST
|
|
617
617
|
#ifdef ALPHA_TO_COVERAGE
|
|
618
618
|
diffuseColor.a = smoothstep( alphaTest, alphaTest + fwidth( diffuseColor.a ), diffuseColor.a );
|
|
619
619
|
if ( diffuseColor.a == 0.0 ) discard;
|
|
620
620
|
#else
|
|
621
621
|
if ( diffuseColor.a < alphaTest ) discard;
|
|
622
622
|
#endif
|
|
623
|
-
#endif`,
|
|
623
|
+
#endif`,Xm=`#ifdef USE_ALPHATEST
|
|
624
624
|
uniform float alphaTest;
|
|
625
|
-
#endif`,
|
|
625
|
+
#endif`,qm=`#ifdef USE_AOMAP
|
|
626
626
|
float ambientOcclusion = ( texture2D( aoMap, vAoMapUv ).r - 1.0 ) * aoMapIntensity + 1.0;
|
|
627
627
|
reflectedLight.indirectDiffuse *= ambientOcclusion;
|
|
628
628
|
#if defined( USE_CLEARCOAT )
|
|
@@ -635,10 +635,10 @@ input[type=range] {
|
|
|
635
635
|
float dotNV = saturate( dot( geometryNormal, geometryViewDir ) );
|
|
636
636
|
reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.roughness );
|
|
637
637
|
#endif
|
|
638
|
-
#endif`,
|
|
638
|
+
#endif`,Ym=`#ifdef USE_AOMAP
|
|
639
639
|
uniform sampler2D aoMap;
|
|
640
640
|
uniform float aoMapIntensity;
|
|
641
|
-
#endif`,
|
|
641
|
+
#endif`,Km=`#ifdef USE_BATCHING
|
|
642
642
|
#if ! defined( GL_ANGLE_multi_draw )
|
|
643
643
|
#define gl_DrawID _gl_DrawID
|
|
644
644
|
uniform int _gl_DrawID;
|
|
@@ -672,15 +672,15 @@ input[type=range] {
|
|
|
672
672
|
int y = j / size;
|
|
673
673
|
return texelFetch( batchingColorTexture, ivec2( x, y ), 0 );
|
|
674
674
|
}
|
|
675
|
-
#endif`,
|
|
675
|
+
#endif`,Zm=`#ifdef USE_BATCHING
|
|
676
676
|
mat4 batchingMatrix = getBatchingMatrix( getIndirectIndex( gl_DrawID ) );
|
|
677
|
-
#endif
|
|
677
|
+
#endif`,$m=`vec3 transformed = vec3( position );
|
|
678
678
|
#ifdef USE_ALPHAHASH
|
|
679
679
|
vPosition = vec3( position );
|
|
680
|
-
#endif`,
|
|
680
|
+
#endif`,Jm=`vec3 objectNormal = vec3( normal );
|
|
681
681
|
#ifdef USE_TANGENT
|
|
682
682
|
vec3 objectTangent = vec3( tangent.xyz );
|
|
683
|
-
#endif`,
|
|
683
|
+
#endif`,Qm=`float G_BlinnPhong_Implicit( ) {
|
|
684
684
|
return 0.25;
|
|
685
685
|
}
|
|
686
686
|
float D_BlinnPhong( const in float shininess, const in float dotNH ) {
|
|
@@ -694,7 +694,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
694
694
|
float G = G_BlinnPhong_Implicit( );
|
|
695
695
|
float D = D_BlinnPhong( shininess, dotNH );
|
|
696
696
|
return F * ( G * D );
|
|
697
|
-
} // validated`,
|
|
697
|
+
} // validated`,jm=`#ifdef USE_IRIDESCENCE
|
|
698
698
|
const mat3 XYZ_TO_REC709 = mat3(
|
|
699
699
|
3.2404542, -0.9692660, 0.0556434,
|
|
700
700
|
-1.5371385, 1.8760108, -0.2040259,
|
|
@@ -757,7 +757,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
757
757
|
}
|
|
758
758
|
return max( I, vec3( 0.0 ) );
|
|
759
759
|
}
|
|
760
|
-
#endif`,
|
|
760
|
+
#endif`,tg=`#ifdef USE_BUMPMAP
|
|
761
761
|
uniform sampler2D bumpMap;
|
|
762
762
|
uniform float bumpScale;
|
|
763
763
|
vec2 dHdxy_fwd() {
|
|
@@ -778,7 +778,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
778
778
|
vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );
|
|
779
779
|
return normalize( abs( fDet ) * surf_norm - vGrad );
|
|
780
780
|
}
|
|
781
|
-
#endif`,
|
|
781
|
+
#endif`,eg=`#if NUM_CLIPPING_PLANES > 0
|
|
782
782
|
vec4 plane;
|
|
783
783
|
#ifdef ALPHA_TO_COVERAGE
|
|
784
784
|
float distanceToPlane, distanceGradient;
|
|
@@ -824,20 +824,20 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
824
824
|
if ( clipped ) discard;
|
|
825
825
|
#endif
|
|
826
826
|
#endif
|
|
827
|
-
#endif`,
|
|
827
|
+
#endif`,ng=`#if NUM_CLIPPING_PLANES > 0
|
|
828
828
|
varying vec3 vClipPosition;
|
|
829
829
|
uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];
|
|
830
|
-
#endif`,
|
|
830
|
+
#endif`,ig=`#if NUM_CLIPPING_PLANES > 0
|
|
831
831
|
varying vec3 vClipPosition;
|
|
832
|
-
#endif`,
|
|
832
|
+
#endif`,sg=`#if NUM_CLIPPING_PLANES > 0
|
|
833
833
|
vClipPosition = - mvPosition.xyz;
|
|
834
|
-
#endif`,
|
|
834
|
+
#endif`,rg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
835
835
|
diffuseColor *= vColor;
|
|
836
|
-
#endif`,
|
|
836
|
+
#endif`,ag=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA )
|
|
837
837
|
varying vec4 vColor;
|
|
838
|
-
#endif`,
|
|
838
|
+
#endif`,og=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
839
839
|
varying vec4 vColor;
|
|
840
|
-
#endif`,
|
|
840
|
+
#endif`,cg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR )
|
|
841
841
|
vColor = vec4( 1.0 );
|
|
842
842
|
#endif
|
|
843
843
|
#ifdef USE_COLOR_ALPHA
|
|
@@ -850,7 +850,7 @@ vec3 BRDF_BlinnPhong( const in vec3 lightDir, const in vec3 viewDir, const in ve
|
|
|
850
850
|
#endif
|
|
851
851
|
#ifdef USE_BATCHING_COLOR
|
|
852
852
|
vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) );
|
|
853
|
-
#endif`,
|
|
853
|
+
#endif`,lg=`#define PI 3.141592653589793
|
|
854
854
|
#define PI2 6.283185307179586
|
|
855
855
|
#define PI_HALF 1.5707963267948966
|
|
856
856
|
#define RECIPROCAL_PI 0.3183098861837907
|
|
@@ -921,7 +921,7 @@ vec3 F_Schlick( const in vec3 f0, const in float f90, const in float dotVH ) {
|
|
|
921
921
|
float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
922
922
|
float fresnel = exp2( ( - 5.55473 * dotVH - 6.98316 ) * dotVH );
|
|
923
923
|
return f0 * ( 1.0 - fresnel ) + ( f90 * fresnel );
|
|
924
|
-
} // validated`,
|
|
924
|
+
} // validated`,hg=`#ifdef ENVMAP_TYPE_CUBE_UV
|
|
925
925
|
#define cubeUV_minMipLevel 4.0
|
|
926
926
|
#define cubeUV_minTileSize 16.0
|
|
927
927
|
float getFace( vec3 direction ) {
|
|
@@ -1014,7 +1014,7 @@ float F_Schlick( const in float f0, const in float f90, const in float dotVH ) {
|
|
|
1014
1014
|
return vec4( mix( color0, color1, mipF ), 1.0 );
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
#endif`,
|
|
1017
|
+
#endif`,ug=`vec3 transformedNormal = objectNormal;
|
|
1018
1018
|
#ifdef USE_TANGENT
|
|
1019
1019
|
vec3 transformedTangent = objectTangent;
|
|
1020
1020
|
#endif
|
|
@@ -1040,21 +1040,21 @@ transformedNormal = normalMatrix * transformedNormal;
|
|
|
1040
1040
|
#endif
|
|
1041
1041
|
#ifdef USE_TANGENT
|
|
1042
1042
|
transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz;
|
|
1043
|
-
#endif`,
|
|
1043
|
+
#endif`,dg=`#ifdef USE_DISPLACEMENTMAP
|
|
1044
1044
|
uniform sampler2D displacementMap;
|
|
1045
1045
|
uniform float displacementScale;
|
|
1046
1046
|
uniform float displacementBias;
|
|
1047
|
-
#endif`,
|
|
1047
|
+
#endif`,fg=`#ifdef USE_DISPLACEMENTMAP
|
|
1048
1048
|
transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias );
|
|
1049
|
-
#endif`,
|
|
1049
|
+
#endif`,pg=`#ifdef USE_EMISSIVEMAP
|
|
1050
1050
|
vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv );
|
|
1051
1051
|
#ifdef DECODE_VIDEO_TEXTURE_EMISSIVE
|
|
1052
1052
|
emissiveColor = sRGBTransferEOTF( emissiveColor );
|
|
1053
1053
|
#endif
|
|
1054
1054
|
totalEmissiveRadiance *= emissiveColor.rgb;
|
|
1055
|
-
#endif
|
|
1055
|
+
#endif`,mg=`#ifdef USE_EMISSIVEMAP
|
|
1056
1056
|
uniform sampler2D emissiveMap;
|
|
1057
|
-
#endif`,
|
|
1057
|
+
#endif`,gg="gl_FragColor = linearToOutputTexel( gl_FragColor );",vg=`vec4 LinearTransferOETF( in vec4 value ) {
|
|
1058
1058
|
return value;
|
|
1059
1059
|
}
|
|
1060
1060
|
vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
@@ -1062,7 +1062,7 @@ vec4 sRGBTransferEOTF( in vec4 value ) {
|
|
|
1062
1062
|
}
|
|
1063
1063
|
vec4 sRGBTransferOETF( in vec4 value ) {
|
|
1064
1064
|
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 );
|
|
1065
|
-
}`,
|
|
1065
|
+
}`,_g=`#ifdef USE_ENVMAP
|
|
1066
1066
|
#ifdef ENV_WORLDPOS
|
|
1067
1067
|
vec3 cameraToFrag;
|
|
1068
1068
|
if ( isOrthographic ) {
|
|
@@ -1089,7 +1089,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1089
1089
|
outgoingLight += envColor.xyz * specularStrength * reflectivity;
|
|
1090
1090
|
#endif
|
|
1091
1091
|
#endif
|
|
1092
|
-
#endif`,
|
|
1092
|
+
#endif`,xg=`#ifdef USE_ENVMAP
|
|
1093
1093
|
uniform float envMapIntensity;
|
|
1094
1094
|
uniform mat3 envMapRotation;
|
|
1095
1095
|
#ifdef ENVMAP_TYPE_CUBE
|
|
@@ -1097,7 +1097,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1097
1097
|
#else
|
|
1098
1098
|
uniform sampler2D envMap;
|
|
1099
1099
|
#endif
|
|
1100
|
-
#endif`,
|
|
1100
|
+
#endif`,Mg=`#ifdef USE_ENVMAP
|
|
1101
1101
|
uniform float reflectivity;
|
|
1102
1102
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
1103
1103
|
#define ENV_WORLDPOS
|
|
@@ -1108,7 +1108,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1108
1108
|
#else
|
|
1109
1109
|
varying vec3 vReflect;
|
|
1110
1110
|
#endif
|
|
1111
|
-
#endif`,
|
|
1111
|
+
#endif`,yg=`#ifdef USE_ENVMAP
|
|
1112
1112
|
#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT )
|
|
1113
1113
|
#define ENV_WORLDPOS
|
|
1114
1114
|
#endif
|
|
@@ -1119,7 +1119,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1119
1119
|
varying vec3 vReflect;
|
|
1120
1120
|
uniform float refractionRatio;
|
|
1121
1121
|
#endif
|
|
1122
|
-
#endif`,
|
|
1122
|
+
#endif`,Sg=`#ifdef USE_ENVMAP
|
|
1123
1123
|
#ifdef ENV_WORLDPOS
|
|
1124
1124
|
vWorldPosition = worldPosition.xyz;
|
|
1125
1125
|
#else
|
|
@@ -1136,18 +1136,18 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1136
1136
|
vReflect = refract( cameraToVertex, worldNormal, refractionRatio );
|
|
1137
1137
|
#endif
|
|
1138
1138
|
#endif
|
|
1139
|
-
#endif`,
|
|
1139
|
+
#endif`,Eg=`#ifdef USE_FOG
|
|
1140
1140
|
vFogDepth = - mvPosition.z;
|
|
1141
|
-
#endif`,
|
|
1141
|
+
#endif`,bg=`#ifdef USE_FOG
|
|
1142
1142
|
varying float vFogDepth;
|
|
1143
|
-
#endif`,
|
|
1143
|
+
#endif`,wg=`#ifdef USE_FOG
|
|
1144
1144
|
#ifdef FOG_EXP2
|
|
1145
1145
|
float fogFactor = 1.0 - exp( - fogDensity * fogDensity * vFogDepth * vFogDepth );
|
|
1146
1146
|
#else
|
|
1147
1147
|
float fogFactor = smoothstep( fogNear, fogFar, vFogDepth );
|
|
1148
1148
|
#endif
|
|
1149
1149
|
gl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );
|
|
1150
|
-
#endif`,
|
|
1150
|
+
#endif`,Ag=`#ifdef USE_FOG
|
|
1151
1151
|
uniform vec3 fogColor;
|
|
1152
1152
|
varying float vFogDepth;
|
|
1153
1153
|
#ifdef FOG_EXP2
|
|
@@ -1156,7 +1156,7 @@ vec4 sRGBTransferOETF( in vec4 value ) {
|
|
|
1156
1156
|
uniform float fogNear;
|
|
1157
1157
|
uniform float fogFar;
|
|
1158
1158
|
#endif
|
|
1159
|
-
#endif`,
|
|
1159
|
+
#endif`,Tg=`#ifdef USE_GRADIENTMAP
|
|
1160
1160
|
uniform sampler2D gradientMap;
|
|
1161
1161
|
#endif
|
|
1162
1162
|
vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
@@ -1168,12 +1168,12 @@ vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {
|
|
|
1168
1168
|
vec2 fw = fwidth( coord ) * 0.5;
|
|
1169
1169
|
return mix( vec3( 0.7 ), vec3( 1.0 ), smoothstep( 0.7 - fw.x, 0.7 + fw.x, coord.x ) );
|
|
1170
1170
|
#endif
|
|
1171
|
-
}`,
|
|
1171
|
+
}`,Rg=`#ifdef USE_LIGHTMAP
|
|
1172
1172
|
uniform sampler2D lightMap;
|
|
1173
1173
|
uniform float lightMapIntensity;
|
|
1174
|
-
#endif`,
|
|
1174
|
+
#endif`,Cg=`LambertMaterial material;
|
|
1175
1175
|
material.diffuseColor = diffuseColor.rgb;
|
|
1176
|
-
material.specularStrength = specularStrength;`,
|
|
1176
|
+
material.specularStrength = specularStrength;`,Dg=`varying vec3 vViewPosition;
|
|
1177
1177
|
struct LambertMaterial {
|
|
1178
1178
|
vec3 diffuseColor;
|
|
1179
1179
|
float specularStrength;
|
|
@@ -1187,7 +1187,7 @@ void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometr
|
|
|
1187
1187
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1188
1188
|
}
|
|
1189
1189
|
#define RE_Direct RE_Direct_Lambert
|
|
1190
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,
|
|
1190
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Pg=`uniform bool receiveShadow;
|
|
1191
1191
|
uniform vec3 ambientLightColor;
|
|
1192
1192
|
#if defined( USE_LIGHT_PROBES )
|
|
1193
1193
|
uniform vec3 lightProbe[ 9 ];
|
|
@@ -1304,7 +1304,7 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1304
1304
|
return irradiance;
|
|
1305
1305
|
}
|
|
1306
1306
|
#endif
|
|
1307
|
-
#include <lightprobes_pars_fragment>`,
|
|
1307
|
+
#include <lightprobes_pars_fragment>`,Ig=`#ifdef USE_ENVMAP
|
|
1308
1308
|
vec3 getIBLIrradiance( const in vec3 normal ) {
|
|
1309
1309
|
#ifdef ENVMAP_TYPE_CUBE_UV
|
|
1310
1310
|
vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix );
|
|
@@ -1337,8 +1337,8 @@ float getSpotAttenuation( const in float coneCosine, const in float penumbraCosi
|
|
|
1337
1337
|
#endif
|
|
1338
1338
|
}
|
|
1339
1339
|
#endif
|
|
1340
|
-
#endif`,
|
|
1341
|
-
material.diffuseColor = diffuseColor.rgb;`,
|
|
1340
|
+
#endif`,Lg=`ToonMaterial material;
|
|
1341
|
+
material.diffuseColor = diffuseColor.rgb;`,Ng=`varying vec3 vViewPosition;
|
|
1342
1342
|
struct ToonMaterial {
|
|
1343
1343
|
vec3 diffuseColor;
|
|
1344
1344
|
};
|
|
@@ -1350,11 +1350,11 @@ void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPo
|
|
|
1350
1350
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1351
1351
|
}
|
|
1352
1352
|
#define RE_Direct RE_Direct_Toon
|
|
1353
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,
|
|
1353
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Ug=`BlinnPhongMaterial material;
|
|
1354
1354
|
material.diffuseColor = diffuseColor.rgb;
|
|
1355
1355
|
material.specularColor = specular;
|
|
1356
1356
|
material.specularShininess = shininess;
|
|
1357
|
-
material.specularStrength = specularStrength;`,
|
|
1357
|
+
material.specularStrength = specularStrength;`,Fg=`varying vec3 vViewPosition;
|
|
1358
1358
|
struct BlinnPhongMaterial {
|
|
1359
1359
|
vec3 diffuseColor;
|
|
1360
1360
|
vec3 specularColor;
|
|
@@ -1371,7 +1371,7 @@ void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geom
|
|
|
1371
1371
|
reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor );
|
|
1372
1372
|
}
|
|
1373
1373
|
#define RE_Direct RE_Direct_BlinnPhong
|
|
1374
|
-
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,
|
|
1374
|
+
#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,Og=`PhysicalMaterial material;
|
|
1375
1375
|
material.diffuseColor = diffuseColor.rgb;
|
|
1376
1376
|
material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor );
|
|
1377
1377
|
material.metalness = metalnessFactor;
|
|
@@ -1461,7 +1461,7 @@ material.roughness = min( material.roughness, 1.0 );
|
|
|
1461
1461
|
material.alphaT = mix( pow2( material.roughness ), 1.0, pow2( material.anisotropy ) );
|
|
1462
1462
|
material.anisotropyT = tbn[ 0 ] * anisotropyV.x + tbn[ 1 ] * anisotropyV.y;
|
|
1463
1463
|
material.anisotropyB = tbn[ 1 ] * anisotropyV.x - tbn[ 0 ] * anisotropyV.y;
|
|
1464
|
-
#endif`,
|
|
1464
|
+
#endif`,zg=`uniform sampler2D dfgLUT;
|
|
1465
1465
|
struct PhysicalMaterial {
|
|
1466
1466
|
vec3 diffuseColor;
|
|
1467
1467
|
vec3 diffuseContribution;
|
|
@@ -1821,7 +1821,7 @@ void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradia
|
|
|
1821
1821
|
#define RE_IndirectSpecular RE_IndirectSpecular_Physical
|
|
1822
1822
|
float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {
|
|
1823
1823
|
return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );
|
|
1824
|
-
}`,
|
|
1824
|
+
}`,Bg=`
|
|
1825
1825
|
vec3 geometryPosition = - vViewPosition;
|
|
1826
1826
|
vec3 geometryNormal = normal;
|
|
1827
1827
|
vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );
|
|
@@ -1943,7 +1943,7 @@ IncidentLight directLight;
|
|
|
1943
1943
|
#if defined( RE_IndirectSpecular )
|
|
1944
1944
|
vec3 radiance = vec3( 0.0 );
|
|
1945
1945
|
vec3 clearcoatRadiance = vec3( 0.0 );
|
|
1946
|
-
#endif`,
|
|
1946
|
+
#endif`,kg=`#if defined( RE_IndirectDiffuse )
|
|
1947
1947
|
#ifdef USE_LIGHTMAP
|
|
1948
1948
|
vec4 lightMapTexel = texture2D( lightMap, vLightMapUv );
|
|
1949
1949
|
vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity;
|
|
@@ -1964,7 +1964,7 @@ IncidentLight directLight;
|
|
|
1964
1964
|
#ifdef USE_CLEARCOAT
|
|
1965
1965
|
clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness );
|
|
1966
1966
|
#endif
|
|
1967
|
-
#endif`,
|
|
1967
|
+
#endif`,Gg=`#if defined( RE_IndirectDiffuse )
|
|
1968
1968
|
#if defined( LAMBERT ) || defined( PHONG )
|
|
1969
1969
|
irradiance += iblIrradiance;
|
|
1970
1970
|
#endif
|
|
@@ -1972,7 +1972,7 @@ IncidentLight directLight;
|
|
|
1972
1972
|
#endif
|
|
1973
1973
|
#if defined( RE_IndirectSpecular )
|
|
1974
1974
|
RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight );
|
|
1975
|
-
#endif`,
|
|
1975
|
+
#endif`,Hg=`#ifdef USE_LIGHT_PROBES_GRID
|
|
1976
1976
|
uniform highp sampler3D probesSH;
|
|
1977
1977
|
uniform vec3 probesMin;
|
|
1978
1978
|
uniform vec3 probesMax;
|
|
@@ -2017,27 +2017,27 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2017
2017
|
result += c8 * 0.429043 * ( x * x - y * y );
|
|
2018
2018
|
return max( result, vec3( 0.0 ) );
|
|
2019
2019
|
}
|
|
2020
|
-
#endif`,
|
|
2020
|
+
#endif`,Vg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
2021
2021
|
gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;
|
|
2022
|
-
#endif`,
|
|
2022
|
+
#endif`,Wg=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER )
|
|
2023
2023
|
uniform float logDepthBufFC;
|
|
2024
2024
|
varying float vFragDepth;
|
|
2025
2025
|
varying float vIsPerspective;
|
|
2026
|
-
#endif`,
|
|
2026
|
+
#endif`,Xg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
2027
2027
|
varying float vFragDepth;
|
|
2028
2028
|
varying float vIsPerspective;
|
|
2029
|
-
#endif`,
|
|
2029
|
+
#endif`,qg=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER
|
|
2030
2030
|
vFragDepth = 1.0 + gl_Position.w;
|
|
2031
2031
|
vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );
|
|
2032
|
-
#endif`,
|
|
2032
|
+
#endif`,Yg=`#ifdef USE_MAP
|
|
2033
2033
|
vec4 sampledDiffuseColor = texture2D( map, vMapUv );
|
|
2034
2034
|
#ifdef DECODE_VIDEO_TEXTURE
|
|
2035
2035
|
sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor );
|
|
2036
2036
|
#endif
|
|
2037
2037
|
diffuseColor *= sampledDiffuseColor;
|
|
2038
|
-
#endif`,
|
|
2038
|
+
#endif`,Kg=`#ifdef USE_MAP
|
|
2039
2039
|
uniform sampler2D map;
|
|
2040
|
-
#endif`,
|
|
2040
|
+
#endif`,Zg=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
2041
2041
|
#if defined( USE_POINTS_UV )
|
|
2042
2042
|
vec2 uv = vUv;
|
|
2043
2043
|
#else
|
|
@@ -2049,7 +2049,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2049
2049
|
#endif
|
|
2050
2050
|
#ifdef USE_ALPHAMAP
|
|
2051
2051
|
diffuseColor.a *= texture2D( alphaMap, uv ).g;
|
|
2052
|
-
#endif
|
|
2052
|
+
#endif`,$g=`#if defined( USE_POINTS_UV )
|
|
2053
2053
|
varying vec2 vUv;
|
|
2054
2054
|
#else
|
|
2055
2055
|
#if defined( USE_MAP ) || defined( USE_ALPHAMAP )
|
|
@@ -2061,19 +2061,19 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2061
2061
|
#endif
|
|
2062
2062
|
#ifdef USE_ALPHAMAP
|
|
2063
2063
|
uniform sampler2D alphaMap;
|
|
2064
|
-
#endif`,
|
|
2064
|
+
#endif`,Jg=`float metalnessFactor = metalness;
|
|
2065
2065
|
#ifdef USE_METALNESSMAP
|
|
2066
2066
|
vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv );
|
|
2067
2067
|
metalnessFactor *= texelMetalness.b;
|
|
2068
|
-
#endif`,
|
|
2068
|
+
#endif`,Qg=`#ifdef USE_METALNESSMAP
|
|
2069
2069
|
uniform sampler2D metalnessMap;
|
|
2070
|
-
#endif`,
|
|
2070
|
+
#endif`,jg=`#ifdef USE_INSTANCING_MORPH
|
|
2071
2071
|
float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
2072
2072
|
float morphTargetBaseInfluence = texelFetch( morphTexture, ivec2( 0, gl_InstanceID ), 0 ).r;
|
|
2073
2073
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2074
2074
|
morphTargetInfluences[i] = texelFetch( morphTexture, ivec2( i + 1, gl_InstanceID ), 0 ).r;
|
|
2075
2075
|
}
|
|
2076
|
-
#endif`,
|
|
2076
|
+
#endif`,t1=`#if defined( USE_MORPHCOLORS )
|
|
2077
2077
|
vColor *= morphTargetBaseInfluence;
|
|
2078
2078
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2079
2079
|
#if defined( USE_COLOR_ALPHA )
|
|
@@ -2082,12 +2082,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2082
2082
|
if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ];
|
|
2083
2083
|
#endif
|
|
2084
2084
|
}
|
|
2085
|
-
#endif`,
|
|
2085
|
+
#endif`,e1=`#ifdef USE_MORPHNORMALS
|
|
2086
2086
|
objectNormal *= morphTargetBaseInfluence;
|
|
2087
2087
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2088
2088
|
if ( morphTargetInfluences[ i ] != 0.0 ) objectNormal += getMorph( gl_VertexID, i, 1 ).xyz * morphTargetInfluences[ i ];
|
|
2089
2089
|
}
|
|
2090
|
-
#endif`,
|
|
2090
|
+
#endif`,n1=`#ifdef USE_MORPHTARGETS
|
|
2091
2091
|
#ifndef USE_INSTANCING_MORPH
|
|
2092
2092
|
uniform float morphTargetBaseInfluence;
|
|
2093
2093
|
uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ];
|
|
@@ -2101,12 +2101,12 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2101
2101
|
ivec3 morphUV = ivec3( x, y, morphTargetIndex );
|
|
2102
2102
|
return texelFetch( morphTargetsTexture, morphUV, 0 );
|
|
2103
2103
|
}
|
|
2104
|
-
#endif`,
|
|
2104
|
+
#endif`,i1=`#ifdef USE_MORPHTARGETS
|
|
2105
2105
|
transformed *= morphTargetBaseInfluence;
|
|
2106
2106
|
for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) {
|
|
2107
2107
|
if ( morphTargetInfluences[ i ] != 0.0 ) transformed += getMorph( gl_VertexID, i, 0 ).xyz * morphTargetInfluences[ i ];
|
|
2108
2108
|
}
|
|
2109
|
-
#endif`,
|
|
2109
|
+
#endif`,s1=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0;
|
|
2110
2110
|
#ifdef FLAT_SHADED
|
|
2111
2111
|
vec3 fdx = dFdx( vViewPosition );
|
|
2112
2112
|
vec3 fdy = dFdy( vViewPosition );
|
|
@@ -2147,7 +2147,7 @@ vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) {
|
|
|
2147
2147
|
tbn2[1] *= faceDirection;
|
|
2148
2148
|
#endif
|
|
2149
2149
|
#endif
|
|
2150
|
-
vec3 nonPerturbedNormal = normal;`,
|
|
2150
|
+
vec3 nonPerturbedNormal = normal;`,r1=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
2151
2151
|
normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2152
2152
|
#ifdef FLIP_SIDED
|
|
2153
2153
|
normal = - normal;
|
|
@@ -2165,19 +2165,19 @@ vec3 nonPerturbedNormal = normal;`,kg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2165
2165
|
normal = normalize( tbn * mapN );
|
|
2166
2166
|
#elif defined( USE_BUMPMAP )
|
|
2167
2167
|
normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection );
|
|
2168
|
-
#endif`,
|
|
2168
|
+
#endif`,a1=`#ifndef FLAT_SHADED
|
|
2169
2169
|
varying vec3 vNormal;
|
|
2170
2170
|
#ifdef USE_TANGENT
|
|
2171
2171
|
varying vec3 vTangent;
|
|
2172
2172
|
varying vec3 vBitangent;
|
|
2173
2173
|
#endif
|
|
2174
|
-
#endif`,
|
|
2174
|
+
#endif`,o1=`#ifndef FLAT_SHADED
|
|
2175
2175
|
varying vec3 vNormal;
|
|
2176
2176
|
#ifdef USE_TANGENT
|
|
2177
2177
|
varying vec3 vTangent;
|
|
2178
2178
|
varying vec3 vBitangent;
|
|
2179
2179
|
#endif
|
|
2180
|
-
#endif`,
|
|
2180
|
+
#endif`,c1=`#ifndef FLAT_SHADED
|
|
2181
2181
|
vNormal = normalize( transformedNormal );
|
|
2182
2182
|
#ifdef USE_TANGENT
|
|
2183
2183
|
vTangent = normalize( transformedTangent );
|
|
@@ -2186,7 +2186,7 @@ vec3 nonPerturbedNormal = normal;`,kg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2186
2186
|
vBitangent = - vBitangent;
|
|
2187
2187
|
#endif
|
|
2188
2188
|
#endif
|
|
2189
|
-
#endif`,
|
|
2189
|
+
#endif`,l1=`#ifdef USE_NORMALMAP
|
|
2190
2190
|
uniform sampler2D normalMap;
|
|
2191
2191
|
uniform vec2 normalScale;
|
|
2192
2192
|
#endif
|
|
@@ -2208,13 +2208,13 @@ vec3 nonPerturbedNormal = normal;`,kg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2208
2208
|
float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det );
|
|
2209
2209
|
return mat3( T * scale, B * scale, N );
|
|
2210
2210
|
}
|
|
2211
|
-
#endif`,
|
|
2211
|
+
#endif`,h1=`#ifdef USE_CLEARCOAT
|
|
2212
2212
|
vec3 clearcoatNormal = nonPerturbedNormal;
|
|
2213
|
-
#endif`,
|
|
2213
|
+
#endif`,u1=`#ifdef USE_CLEARCOAT_NORMALMAP
|
|
2214
2214
|
vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0;
|
|
2215
2215
|
clearcoatMapN.xy *= clearcoatNormalScale;
|
|
2216
2216
|
clearcoatNormal = normalize( tbn2 * clearcoatMapN );
|
|
2217
|
-
#endif`,
|
|
2217
|
+
#endif`,d1=`#ifdef USE_CLEARCOATMAP
|
|
2218
2218
|
uniform sampler2D clearcoatMap;
|
|
2219
2219
|
#endif
|
|
2220
2220
|
#ifdef USE_CLEARCOAT_NORMALMAP
|
|
@@ -2223,18 +2223,18 @@ vec3 nonPerturbedNormal = normal;`,kg=`#ifdef USE_NORMALMAP_OBJECTSPACE
|
|
|
2223
2223
|
#endif
|
|
2224
2224
|
#ifdef USE_CLEARCOAT_ROUGHNESSMAP
|
|
2225
2225
|
uniform sampler2D clearcoatRoughnessMap;
|
|
2226
|
-
#endif`,
|
|
2226
|
+
#endif`,f1=`#ifdef USE_IRIDESCENCEMAP
|
|
2227
2227
|
uniform sampler2D iridescenceMap;
|
|
2228
2228
|
#endif
|
|
2229
2229
|
#ifdef USE_IRIDESCENCE_THICKNESSMAP
|
|
2230
2230
|
uniform sampler2D iridescenceThicknessMap;
|
|
2231
|
-
#endif`,
|
|
2231
|
+
#endif`,p1=`#ifdef OPAQUE
|
|
2232
2232
|
diffuseColor.a = 1.0;
|
|
2233
2233
|
#endif
|
|
2234
2234
|
#ifdef USE_TRANSMISSION
|
|
2235
2235
|
diffuseColor.a *= material.transmissionAlpha;
|
|
2236
2236
|
#endif
|
|
2237
|
-
gl_FragColor = vec4( outgoingLight, diffuseColor.a )
|
|
2237
|
+
gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,m1=`vec3 packNormalToRGB( const in vec3 normal ) {
|
|
2238
2238
|
return normalize( normal ) * 0.5 + 0.5;
|
|
2239
2239
|
}
|
|
2240
2240
|
vec3 unpackRGBToNormal( const in vec3 rgb ) {
|
|
@@ -2313,9 +2313,9 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2313
2313
|
#else
|
|
2314
2314
|
return ( near * far ) / ( ( far - near ) * depth - far );
|
|
2315
2315
|
#endif
|
|
2316
|
-
}`,
|
|
2316
|
+
}`,g1=`#ifdef PREMULTIPLIED_ALPHA
|
|
2317
2317
|
gl_FragColor.rgb *= gl_FragColor.a;
|
|
2318
|
-
#endif`,
|
|
2318
|
+
#endif`,v1=`vec4 mvPosition = vec4( transformed, 1.0 );
|
|
2319
2319
|
#ifdef USE_BATCHING
|
|
2320
2320
|
mvPosition = batchingMatrix * mvPosition;
|
|
2321
2321
|
#endif
|
|
@@ -2323,22 +2323,22 @@ float perspectiveDepthToViewZ( const in float depth, const in float near, const
|
|
|
2323
2323
|
mvPosition = instanceMatrix * mvPosition;
|
|
2324
2324
|
#endif
|
|
2325
2325
|
mvPosition = modelViewMatrix * mvPosition;
|
|
2326
|
-
gl_Position = projectionMatrix * mvPosition;`,
|
|
2326
|
+
gl_Position = projectionMatrix * mvPosition;`,_1=`#ifdef DITHERING
|
|
2327
2327
|
gl_FragColor.rgb = dithering( gl_FragColor.rgb );
|
|
2328
|
-
#endif`,
|
|
2328
|
+
#endif`,x1=`#ifdef DITHERING
|
|
2329
2329
|
vec3 dithering( vec3 color ) {
|
|
2330
2330
|
float grid_position = rand( gl_FragCoord.xy );
|
|
2331
2331
|
vec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );
|
|
2332
2332
|
dither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );
|
|
2333
2333
|
return color + dither_shift_RGB;
|
|
2334
2334
|
}
|
|
2335
|
-
#endif`,
|
|
2335
|
+
#endif`,M1=`float roughnessFactor = roughness;
|
|
2336
2336
|
#ifdef USE_ROUGHNESSMAP
|
|
2337
2337
|
vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv );
|
|
2338
2338
|
roughnessFactor *= texelRoughness.g;
|
|
2339
|
-
#endif`,
|
|
2339
|
+
#endif`,y1=`#ifdef USE_ROUGHNESSMAP
|
|
2340
2340
|
uniform sampler2D roughnessMap;
|
|
2341
|
-
#endif`,
|
|
2341
|
+
#endif`,S1=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2342
2342
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2343
2343
|
#endif
|
|
2344
2344
|
#if NUM_SPOT_LIGHT_MAPS > 0
|
|
@@ -2538,7 +2538,7 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2538
2538
|
}
|
|
2539
2539
|
#endif
|
|
2540
2540
|
#endif
|
|
2541
|
-
#endif`,
|
|
2541
|
+
#endif`,E1=`#if NUM_SPOT_LIGHT_COORDS > 0
|
|
2542
2542
|
uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ];
|
|
2543
2543
|
varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ];
|
|
2544
2544
|
#endif
|
|
@@ -2579,7 +2579,7 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2579
2579
|
};
|
|
2580
2580
|
uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];
|
|
2581
2581
|
#endif
|
|
2582
|
-
#endif`,
|
|
2582
|
+
#endif`,b1=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 )
|
|
2583
2583
|
#ifdef HAS_NORMAL
|
|
2584
2584
|
vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix );
|
|
2585
2585
|
#else
|
|
@@ -2615,7 +2615,7 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2615
2615
|
vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition;
|
|
2616
2616
|
}
|
|
2617
2617
|
#pragma unroll_loop_end
|
|
2618
|
-
#endif`,
|
|
2618
|
+
#endif`,w1=`float getShadowMask() {
|
|
2619
2619
|
float shadow = 1.0;
|
|
2620
2620
|
#ifdef USE_SHADOWMAP
|
|
2621
2621
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
@@ -2647,12 +2647,12 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2647
2647
|
#endif
|
|
2648
2648
|
#endif
|
|
2649
2649
|
return shadow;
|
|
2650
|
-
}`,
|
|
2650
|
+
}`,A1=`#ifdef USE_SKINNING
|
|
2651
2651
|
mat4 boneMatX = getBoneMatrix( skinIndex.x );
|
|
2652
2652
|
mat4 boneMatY = getBoneMatrix( skinIndex.y );
|
|
2653
2653
|
mat4 boneMatZ = getBoneMatrix( skinIndex.z );
|
|
2654
2654
|
mat4 boneMatW = getBoneMatrix( skinIndex.w );
|
|
2655
|
-
#endif`,
|
|
2655
|
+
#endif`,T1=`#ifdef USE_SKINNING
|
|
2656
2656
|
uniform mat4 bindMatrix;
|
|
2657
2657
|
uniform mat4 bindMatrixInverse;
|
|
2658
2658
|
uniform highp sampler2D boneTexture;
|
|
@@ -2667,7 +2667,7 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2667
2667
|
vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 );
|
|
2668
2668
|
return mat4( v1, v2, v3, v4 );
|
|
2669
2669
|
}
|
|
2670
|
-
#endif`,
|
|
2670
|
+
#endif`,R1=`#ifdef USE_SKINNING
|
|
2671
2671
|
vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );
|
|
2672
2672
|
vec4 skinned = vec4( 0.0 );
|
|
2673
2673
|
skinned += boneMatX * skinVertex * skinWeight.x;
|
|
@@ -2675,7 +2675,7 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2675
2675
|
skinned += boneMatZ * skinVertex * skinWeight.z;
|
|
2676
2676
|
skinned += boneMatW * skinVertex * skinWeight.w;
|
|
2677
2677
|
transformed = ( bindMatrixInverse * skinned ).xyz;
|
|
2678
|
-
#endif`,
|
|
2678
|
+
#endif`,C1=`#ifdef USE_SKINNING
|
|
2679
2679
|
mat4 skinMatrix = mat4( 0.0 );
|
|
2680
2680
|
skinMatrix += skinWeight.x * boneMatX;
|
|
2681
2681
|
skinMatrix += skinWeight.y * boneMatY;
|
|
@@ -2686,17 +2686,17 @@ gl_Position = projectionMatrix * mvPosition;`,jg=`#ifdef DITHERING
|
|
|
2686
2686
|
#ifdef USE_TANGENT
|
|
2687
2687
|
objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;
|
|
2688
2688
|
#endif
|
|
2689
|
-
#endif`,
|
|
2689
|
+
#endif`,D1=`float specularStrength;
|
|
2690
2690
|
#ifdef USE_SPECULARMAP
|
|
2691
2691
|
vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv );
|
|
2692
2692
|
specularStrength = texelSpecular.r;
|
|
2693
2693
|
#else
|
|
2694
2694
|
specularStrength = 1.0;
|
|
2695
|
-
#endif`,
|
|
2695
|
+
#endif`,P1=`#ifdef USE_SPECULARMAP
|
|
2696
2696
|
uniform sampler2D specularMap;
|
|
2697
|
-
#endif`,
|
|
2697
|
+
#endif`,I1=`#if defined( TONE_MAPPING )
|
|
2698
2698
|
gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );
|
|
2699
|
-
#endif`,
|
|
2699
|
+
#endif`,L1=`#ifndef saturate
|
|
2700
2700
|
#define saturate( a ) clamp( a, 0.0, 1.0 )
|
|
2701
2701
|
#endif
|
|
2702
2702
|
uniform float toneMappingExposure;
|
|
@@ -2793,7 +2793,7 @@ vec3 NeutralToneMapping( vec3 color ) {
|
|
|
2793
2793
|
float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. );
|
|
2794
2794
|
return mix( color, vec3( newPeak ), g );
|
|
2795
2795
|
}
|
|
2796
|
-
vec3 CustomToneMapping( vec3 color ) { return color; }`,
|
|
2796
|
+
vec3 CustomToneMapping( vec3 color ) { return color; }`,N1=`#ifdef USE_TRANSMISSION
|
|
2797
2797
|
material.transmission = transmission;
|
|
2798
2798
|
material.transmissionAlpha = 1.0;
|
|
2799
2799
|
material.thickness = thickness;
|
|
@@ -2814,7 +2814,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
2814
2814
|
material.attenuationColor, material.attenuationDistance );
|
|
2815
2815
|
material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission );
|
|
2816
2816
|
totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission );
|
|
2817
|
-
#endif`,
|
|
2817
|
+
#endif`,U1=`#ifdef USE_TRANSMISSION
|
|
2818
2818
|
uniform float transmission;
|
|
2819
2819
|
uniform float thickness;
|
|
2820
2820
|
uniform float attenuationDistance;
|
|
@@ -2940,7 +2940,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
2940
2940
|
float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0;
|
|
2941
2941
|
return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor );
|
|
2942
2942
|
}
|
|
2943
|
-
#endif`,
|
|
2943
|
+
#endif`,F1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
2944
2944
|
varying vec2 vUv;
|
|
2945
2945
|
#endif
|
|
2946
2946
|
#ifdef USE_MAP
|
|
@@ -3010,7 +3010,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
3010
3010
|
#ifdef USE_THICKNESSMAP
|
|
3011
3011
|
uniform mat3 thicknessMapTransform;
|
|
3012
3012
|
varying vec2 vThicknessMapUv;
|
|
3013
|
-
#endif`,
|
|
3013
|
+
#endif`,O1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3014
3014
|
varying vec2 vUv;
|
|
3015
3015
|
#endif
|
|
3016
3016
|
#ifdef USE_MAP
|
|
@@ -3104,7 +3104,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
3104
3104
|
#ifdef USE_THICKNESSMAP
|
|
3105
3105
|
uniform mat3 thicknessMapTransform;
|
|
3106
3106
|
varying vec2 vThicknessMapUv;
|
|
3107
|
-
#endif`,
|
|
3107
|
+
#endif`,z1=`#if defined( USE_UV ) || defined( USE_ANISOTROPY )
|
|
3108
3108
|
vUv = vec3( uv, 1 ).xy;
|
|
3109
3109
|
#endif
|
|
3110
3110
|
#ifdef USE_MAP
|
|
@@ -3175,7 +3175,7 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
3175
3175
|
#endif
|
|
3176
3176
|
#ifdef USE_THICKNESSMAP
|
|
3177
3177
|
vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy;
|
|
3178
|
-
#endif`,
|
|
3178
|
+
#endif`,B1=`#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP ) || defined ( USE_TRANSMISSION ) || NUM_SPOT_LIGHT_COORDS > 0
|
|
3179
3179
|
vec4 worldPosition = vec4( transformed, 1.0 );
|
|
3180
3180
|
#ifdef USE_BATCHING
|
|
3181
3181
|
worldPosition = batchingMatrix * worldPosition;
|
|
@@ -3184,12 +3184,12 @@ vec3 CustomToneMapping( vec3 color ) { return color; }`,m1=`#ifdef USE_TRANSMISS
|
|
|
3184
3184
|
worldPosition = instanceMatrix * worldPosition;
|
|
3185
3185
|
#endif
|
|
3186
3186
|
worldPosition = modelMatrix * worldPosition;
|
|
3187
|
-
#endif`;const
|
|
3187
|
+
#endif`;const k1=`varying vec2 vUv;
|
|
3188
3188
|
uniform mat3 uvTransform;
|
|
3189
3189
|
void main() {
|
|
3190
3190
|
vUv = ( uvTransform * vec3( uv, 1 ) ).xy;
|
|
3191
3191
|
gl_Position = vec4( position.xy, 1.0, 1.0 );
|
|
3192
|
-
}`,
|
|
3192
|
+
}`,G1=`uniform sampler2D t2D;
|
|
3193
3193
|
uniform float backgroundIntensity;
|
|
3194
3194
|
varying vec2 vUv;
|
|
3195
3195
|
void main() {
|
|
@@ -3201,14 +3201,14 @@ void main() {
|
|
|
3201
3201
|
gl_FragColor = texColor;
|
|
3202
3202
|
#include <tonemapping_fragment>
|
|
3203
3203
|
#include <colorspace_fragment>
|
|
3204
|
-
}`,
|
|
3204
|
+
}`,H1=`varying vec3 vWorldDirection;
|
|
3205
3205
|
#include <common>
|
|
3206
3206
|
void main() {
|
|
3207
3207
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3208
3208
|
#include <begin_vertex>
|
|
3209
3209
|
#include <project_vertex>
|
|
3210
3210
|
gl_Position.z = gl_Position.w;
|
|
3211
|
-
}`,
|
|
3211
|
+
}`,V1=`#ifdef ENVMAP_TYPE_CUBE
|
|
3212
3212
|
uniform samplerCube envMap;
|
|
3213
3213
|
#elif defined( ENVMAP_TYPE_CUBE_UV )
|
|
3214
3214
|
uniform sampler2D envMap;
|
|
@@ -3230,14 +3230,14 @@ void main() {
|
|
|
3230
3230
|
gl_FragColor = texColor;
|
|
3231
3231
|
#include <tonemapping_fragment>
|
|
3232
3232
|
#include <colorspace_fragment>
|
|
3233
|
-
}`,
|
|
3233
|
+
}`,W1=`varying vec3 vWorldDirection;
|
|
3234
3234
|
#include <common>
|
|
3235
3235
|
void main() {
|
|
3236
3236
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3237
3237
|
#include <begin_vertex>
|
|
3238
3238
|
#include <project_vertex>
|
|
3239
3239
|
gl_Position.z = gl_Position.w;
|
|
3240
|
-
}`,
|
|
3240
|
+
}`,X1=`uniform samplerCube tCube;
|
|
3241
3241
|
uniform float tFlip;
|
|
3242
3242
|
uniform float opacity;
|
|
3243
3243
|
varying vec3 vWorldDirection;
|
|
@@ -3247,7 +3247,7 @@ void main() {
|
|
|
3247
3247
|
gl_FragColor.a *= opacity;
|
|
3248
3248
|
#include <tonemapping_fragment>
|
|
3249
3249
|
#include <colorspace_fragment>
|
|
3250
|
-
}`,
|
|
3250
|
+
}`,q1=`#include <common>
|
|
3251
3251
|
#include <batching_pars_vertex>
|
|
3252
3252
|
#include <uv_pars_vertex>
|
|
3253
3253
|
#include <displacementmap_pars_vertex>
|
|
@@ -3274,7 +3274,7 @@ void main() {
|
|
|
3274
3274
|
#include <logdepthbuf_vertex>
|
|
3275
3275
|
#include <clipping_planes_vertex>
|
|
3276
3276
|
vHighPrecisionZW = gl_Position.zw;
|
|
3277
|
-
}`,
|
|
3277
|
+
}`,Y1=`#if DEPTH_PACKING == 3200
|
|
3278
3278
|
uniform float opacity;
|
|
3279
3279
|
#endif
|
|
3280
3280
|
#include <common>
|
|
@@ -3312,7 +3312,7 @@ void main() {
|
|
|
3312
3312
|
#elif DEPTH_PACKING == 3203
|
|
3313
3313
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
3314
3314
|
#endif
|
|
3315
|
-
}`,
|
|
3315
|
+
}`,K1=`#define DISTANCE
|
|
3316
3316
|
varying vec3 vWorldPosition;
|
|
3317
3317
|
#include <common>
|
|
3318
3318
|
#include <batching_pars_vertex>
|
|
@@ -3339,7 +3339,7 @@ void main() {
|
|
|
3339
3339
|
#include <worldpos_vertex>
|
|
3340
3340
|
#include <clipping_planes_vertex>
|
|
3341
3341
|
vWorldPosition = worldPosition.xyz;
|
|
3342
|
-
}`,
|
|
3342
|
+
}`,Z1=`#define DISTANCE
|
|
3343
3343
|
uniform vec3 referencePosition;
|
|
3344
3344
|
uniform float nearDistance;
|
|
3345
3345
|
uniform float farDistance;
|
|
@@ -3362,13 +3362,13 @@ void main() {
|
|
|
3362
3362
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
3363
3363
|
dist = saturate( dist );
|
|
3364
3364
|
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
3365
|
-
}
|
|
3365
|
+
}`,$1=`varying vec3 vWorldDirection;
|
|
3366
3366
|
#include <common>
|
|
3367
3367
|
void main() {
|
|
3368
3368
|
vWorldDirection = transformDirection( position, modelMatrix );
|
|
3369
3369
|
#include <begin_vertex>
|
|
3370
3370
|
#include <project_vertex>
|
|
3371
|
-
}`,
|
|
3371
|
+
}`,J1=`uniform sampler2D tEquirect;
|
|
3372
3372
|
varying vec3 vWorldDirection;
|
|
3373
3373
|
#include <common>
|
|
3374
3374
|
void main() {
|
|
@@ -3377,7 +3377,7 @@ void main() {
|
|
|
3377
3377
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
3378
3378
|
#include <tonemapping_fragment>
|
|
3379
3379
|
#include <colorspace_fragment>
|
|
3380
|
-
}`,
|
|
3380
|
+
}`,Q1=`uniform float scale;
|
|
3381
3381
|
attribute float lineDistance;
|
|
3382
3382
|
varying float vLineDistance;
|
|
3383
3383
|
#include <common>
|
|
@@ -3399,7 +3399,7 @@ void main() {
|
|
|
3399
3399
|
#include <logdepthbuf_vertex>
|
|
3400
3400
|
#include <clipping_planes_vertex>
|
|
3401
3401
|
#include <fog_vertex>
|
|
3402
|
-
}`,
|
|
3402
|
+
}`,j1=`uniform vec3 diffuse;
|
|
3403
3403
|
uniform float opacity;
|
|
3404
3404
|
uniform float dashSize;
|
|
3405
3405
|
uniform float totalSize;
|
|
@@ -3427,7 +3427,7 @@ void main() {
|
|
|
3427
3427
|
#include <colorspace_fragment>
|
|
3428
3428
|
#include <fog_fragment>
|
|
3429
3429
|
#include <premultiplied_alpha_fragment>
|
|
3430
|
-
}`,
|
|
3430
|
+
}`,tv=`#include <common>
|
|
3431
3431
|
#include <batching_pars_vertex>
|
|
3432
3432
|
#include <uv_pars_vertex>
|
|
3433
3433
|
#include <envmap_pars_vertex>
|
|
@@ -3459,7 +3459,7 @@ void main() {
|
|
|
3459
3459
|
#include <worldpos_vertex>
|
|
3460
3460
|
#include <envmap_vertex>
|
|
3461
3461
|
#include <fog_vertex>
|
|
3462
|
-
}`,
|
|
3462
|
+
}`,ev=`uniform vec3 diffuse;
|
|
3463
3463
|
uniform float opacity;
|
|
3464
3464
|
#ifndef FLAT_SHADED
|
|
3465
3465
|
varying vec3 vNormal;
|
|
@@ -3507,7 +3507,7 @@ void main() {
|
|
|
3507
3507
|
#include <fog_fragment>
|
|
3508
3508
|
#include <premultiplied_alpha_fragment>
|
|
3509
3509
|
#include <dithering_fragment>
|
|
3510
|
-
}`,
|
|
3510
|
+
}`,nv=`#define LAMBERT
|
|
3511
3511
|
varying vec3 vViewPosition;
|
|
3512
3512
|
#include <common>
|
|
3513
3513
|
#include <batching_pars_vertex>
|
|
@@ -3546,7 +3546,7 @@ void main() {
|
|
|
3546
3546
|
#include <envmap_vertex>
|
|
3547
3547
|
#include <shadowmap_vertex>
|
|
3548
3548
|
#include <fog_vertex>
|
|
3549
|
-
}`,
|
|
3549
|
+
}`,iv=`#define LAMBERT
|
|
3550
3550
|
uniform vec3 diffuse;
|
|
3551
3551
|
uniform vec3 emissive;
|
|
3552
3552
|
uniform float opacity;
|
|
@@ -3604,7 +3604,7 @@ void main() {
|
|
|
3604
3604
|
#include <fog_fragment>
|
|
3605
3605
|
#include <premultiplied_alpha_fragment>
|
|
3606
3606
|
#include <dithering_fragment>
|
|
3607
|
-
}`,
|
|
3607
|
+
}`,sv=`#define MATCAP
|
|
3608
3608
|
varying vec3 vViewPosition;
|
|
3609
3609
|
#include <common>
|
|
3610
3610
|
#include <batching_pars_vertex>
|
|
@@ -3638,7 +3638,7 @@ void main() {
|
|
|
3638
3638
|
#include <clipping_planes_vertex>
|
|
3639
3639
|
#include <fog_vertex>
|
|
3640
3640
|
vViewPosition = - mvPosition.xyz;
|
|
3641
|
-
}`,
|
|
3641
|
+
}`,rv=`#define MATCAP
|
|
3642
3642
|
uniform vec3 diffuse;
|
|
3643
3643
|
uniform float opacity;
|
|
3644
3644
|
uniform sampler2D matcap;
|
|
@@ -3684,7 +3684,7 @@ void main() {
|
|
|
3684
3684
|
#include <fog_fragment>
|
|
3685
3685
|
#include <premultiplied_alpha_fragment>
|
|
3686
3686
|
#include <dithering_fragment>
|
|
3687
|
-
}`,
|
|
3687
|
+
}`,av=`#define NORMAL
|
|
3688
3688
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3689
3689
|
varying vec3 vViewPosition;
|
|
3690
3690
|
#endif
|
|
@@ -3717,7 +3717,7 @@ void main() {
|
|
|
3717
3717
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3718
3718
|
vViewPosition = - mvPosition.xyz;
|
|
3719
3719
|
#endif
|
|
3720
|
-
}`,
|
|
3720
|
+
}`,ov=`#define NORMAL
|
|
3721
3721
|
uniform float opacity;
|
|
3722
3722
|
#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE )
|
|
3723
3723
|
varying vec3 vViewPosition;
|
|
@@ -3738,7 +3738,7 @@ void main() {
|
|
|
3738
3738
|
#ifdef OPAQUE
|
|
3739
3739
|
gl_FragColor.a = 1.0;
|
|
3740
3740
|
#endif
|
|
3741
|
-
}`,
|
|
3741
|
+
}`,cv=`#define PHONG
|
|
3742
3742
|
varying vec3 vViewPosition;
|
|
3743
3743
|
#include <common>
|
|
3744
3744
|
#include <batching_pars_vertex>
|
|
@@ -3777,7 +3777,7 @@ void main() {
|
|
|
3777
3777
|
#include <envmap_vertex>
|
|
3778
3778
|
#include <shadowmap_vertex>
|
|
3779
3779
|
#include <fog_vertex>
|
|
3780
|
-
}`,
|
|
3780
|
+
}`,lv=`#define PHONG
|
|
3781
3781
|
uniform vec3 diffuse;
|
|
3782
3782
|
uniform vec3 emissive;
|
|
3783
3783
|
uniform vec3 specular;
|
|
@@ -3837,7 +3837,7 @@ void main() {
|
|
|
3837
3837
|
#include <fog_fragment>
|
|
3838
3838
|
#include <premultiplied_alpha_fragment>
|
|
3839
3839
|
#include <dithering_fragment>
|
|
3840
|
-
}`,
|
|
3840
|
+
}`,hv=`#define STANDARD
|
|
3841
3841
|
varying vec3 vViewPosition;
|
|
3842
3842
|
#ifdef USE_TRANSMISSION
|
|
3843
3843
|
varying vec3 vWorldPosition;
|
|
@@ -3880,7 +3880,7 @@ void main() {
|
|
|
3880
3880
|
#ifdef USE_TRANSMISSION
|
|
3881
3881
|
vWorldPosition = worldPosition.xyz;
|
|
3882
3882
|
#endif
|
|
3883
|
-
}`,
|
|
3883
|
+
}`,uv=`#define STANDARD
|
|
3884
3884
|
#ifdef PHYSICAL
|
|
3885
3885
|
#define IOR
|
|
3886
3886
|
#define USE_SPECULAR
|
|
@@ -4005,7 +4005,7 @@ void main() {
|
|
|
4005
4005
|
#include <fog_fragment>
|
|
4006
4006
|
#include <premultiplied_alpha_fragment>
|
|
4007
4007
|
#include <dithering_fragment>
|
|
4008
|
-
}`,
|
|
4008
|
+
}`,dv=`#define TOON
|
|
4009
4009
|
varying vec3 vViewPosition;
|
|
4010
4010
|
#include <common>
|
|
4011
4011
|
#include <batching_pars_vertex>
|
|
@@ -4042,7 +4042,7 @@ void main() {
|
|
|
4042
4042
|
#include <worldpos_vertex>
|
|
4043
4043
|
#include <shadowmap_vertex>
|
|
4044
4044
|
#include <fog_vertex>
|
|
4045
|
-
}`,
|
|
4045
|
+
}`,fv=`#define TOON
|
|
4046
4046
|
uniform vec3 diffuse;
|
|
4047
4047
|
uniform vec3 emissive;
|
|
4048
4048
|
uniform float opacity;
|
|
@@ -4094,7 +4094,7 @@ void main() {
|
|
|
4094
4094
|
#include <fog_fragment>
|
|
4095
4095
|
#include <premultiplied_alpha_fragment>
|
|
4096
4096
|
#include <dithering_fragment>
|
|
4097
|
-
}`,
|
|
4097
|
+
}`,pv=`uniform float size;
|
|
4098
4098
|
uniform float scale;
|
|
4099
4099
|
#include <common>
|
|
4100
4100
|
#include <color_pars_vertex>
|
|
@@ -4125,7 +4125,7 @@ void main() {
|
|
|
4125
4125
|
#include <clipping_planes_vertex>
|
|
4126
4126
|
#include <worldpos_vertex>
|
|
4127
4127
|
#include <fog_vertex>
|
|
4128
|
-
}
|
|
4128
|
+
}`,mv=`uniform vec3 diffuse;
|
|
4129
4129
|
uniform float opacity;
|
|
4130
4130
|
#include <common>
|
|
4131
4131
|
#include <color_pars_fragment>
|
|
@@ -4150,7 +4150,7 @@ void main() {
|
|
|
4150
4150
|
#include <colorspace_fragment>
|
|
4151
4151
|
#include <fog_fragment>
|
|
4152
4152
|
#include <premultiplied_alpha_fragment>
|
|
4153
|
-
}`,
|
|
4153
|
+
}`,gv=`#include <common>
|
|
4154
4154
|
#include <batching_pars_vertex>
|
|
4155
4155
|
#include <fog_pars_vertex>
|
|
4156
4156
|
#include <morphtarget_pars_vertex>
|
|
@@ -4173,7 +4173,7 @@ void main() {
|
|
|
4173
4173
|
#include <worldpos_vertex>
|
|
4174
4174
|
#include <shadowmap_vertex>
|
|
4175
4175
|
#include <fog_vertex>
|
|
4176
|
-
}`,
|
|
4176
|
+
}`,vv=`uniform vec3 color;
|
|
4177
4177
|
uniform float opacity;
|
|
4178
4178
|
#include <common>
|
|
4179
4179
|
#include <fog_pars_fragment>
|
|
@@ -4189,7 +4189,7 @@ void main() {
|
|
|
4189
4189
|
#include <colorspace_fragment>
|
|
4190
4190
|
#include <fog_fragment>
|
|
4191
4191
|
#include <premultiplied_alpha_fragment>
|
|
4192
|
-
}`,
|
|
4192
|
+
}`,_v=`uniform float rotation;
|
|
4193
4193
|
uniform vec2 center;
|
|
4194
4194
|
#include <common>
|
|
4195
4195
|
#include <uv_pars_vertex>
|
|
@@ -4213,7 +4213,7 @@ void main() {
|
|
|
4213
4213
|
#include <logdepthbuf_vertex>
|
|
4214
4214
|
#include <clipping_planes_vertex>
|
|
4215
4215
|
#include <fog_vertex>
|
|
4216
|
-
}`,
|
|
4216
|
+
}`,xv=`uniform vec3 diffuse;
|
|
4217
4217
|
uniform float opacity;
|
|
4218
4218
|
#include <common>
|
|
4219
4219
|
#include <uv_pars_fragment>
|
|
@@ -4238,7 +4238,7 @@ void main() {
|
|
|
4238
4238
|
#include <tonemapping_fragment>
|
|
4239
4239
|
#include <colorspace_fragment>
|
|
4240
4240
|
#include <fog_fragment>
|
|
4241
|
-
}`,Ge={alphahash_fragment:ym,alphahash_pars_fragment:Sm,alphamap_fragment:Em,alphamap_pars_fragment:bm,alphatest_fragment:wm,alphatest_pars_fragment:Am,aomap_fragment:Tm,aomap_pars_fragment:Rm,batching_pars_vertex:Cm,batching_vertex:Dm,begin_vertex:Pm,beginnormal_vertex:Im,bsdfs:Lm,iridescence_fragment:Nm,bumpmap_pars_fragment:Um,clipping_planes_fragment:Fm,clipping_planes_pars_fragment:Om,clipping_planes_pars_vertex:zm,clipping_planes_vertex:Bm,color_fragment:km,color_pars_fragment:Gm,color_pars_vertex:Hm,color_vertex:Vm,common:Wm,cube_uv_reflection_fragment:Xm,defaultnormal_vertex:qm,displacementmap_pars_vertex:Ym,displacementmap_vertex:Km,emissivemap_fragment:Zm,emissivemap_pars_fragment:$m,colorspace_fragment:Jm,colorspace_pars_fragment:Qm,envmap_fragment:jm,envmap_common_pars_fragment:eg,envmap_pars_fragment:tg,envmap_pars_vertex:ng,envmap_physical_pars_fragment:fg,envmap_vertex:ig,fog_vertex:sg,fog_pars_vertex:rg,fog_fragment:ag,fog_pars_fragment:og,gradientmap_pars_fragment:lg,lightmap_pars_fragment:cg,lights_lambert_fragment:hg,lights_lambert_pars_fragment:ug,lights_pars_begin:dg,lights_toon_fragment:pg,lights_toon_pars_fragment:mg,lights_phong_fragment:gg,lights_phong_pars_fragment:vg,lights_physical_fragment:_g,lights_physical_pars_fragment:xg,lights_fragment_begin:Mg,lights_fragment_maps:yg,lights_fragment_end:Sg,lightprobes_pars_fragment:Eg,logdepthbuf_fragment:bg,logdepthbuf_pars_fragment:wg,logdepthbuf_pars_vertex:Ag,logdepthbuf_vertex:Tg,map_fragment:Rg,map_pars_fragment:Cg,map_particle_fragment:Dg,map_particle_pars_fragment:Pg,metalnessmap_fragment:Ig,metalnessmap_pars_fragment:Lg,morphinstance_vertex:Ng,morphcolor_vertex:Ug,morphnormal_vertex:Fg,morphtarget_pars_vertex:Og,morphtarget_vertex:zg,normal_fragment_begin:Bg,normal_fragment_maps:kg,normal_pars_fragment:Gg,normal_pars_vertex:Hg,normal_vertex:Vg,normalmap_pars_fragment:Wg,clearcoat_normal_fragment_begin:Xg,clearcoat_normal_fragment_maps:qg,clearcoat_pars_fragment:Yg,iridescence_pars_fragment:Kg,opaque_fragment:Zg,packing:$g,premultiplied_alpha_fragment:Jg,project_vertex:Qg,dithering_fragment:jg,dithering_pars_fragment:e1,roughnessmap_fragment:t1,roughnessmap_pars_fragment:n1,shadowmap_pars_fragment:i1,shadowmap_pars_vertex:s1,shadowmap_vertex:r1,shadowmask_pars_fragment:a1,skinbase_vertex:o1,skinning_pars_vertex:l1,skinning_vertex:c1,skinnormal_vertex:h1,specularmap_fragment:u1,specularmap_pars_fragment:d1,tonemapping_fragment:f1,tonemapping_pars_fragment:p1,transmission_fragment:m1,transmission_pars_fragment:g1,uv_pars_fragment:v1,uv_pars_vertex:_1,uv_vertex:x1,worldpos_vertex:M1,background_vert:y1,background_frag:S1,backgroundCube_vert:E1,backgroundCube_frag:b1,cube_vert:w1,cube_frag:A1,depth_vert:T1,depth_frag:R1,distance_vert:C1,distance_frag:D1,equirect_vert:P1,equirect_frag:I1,linedashed_vert:L1,linedashed_frag:N1,meshbasic_vert:U1,meshbasic_frag:F1,meshlambert_vert:O1,meshlambert_frag:z1,meshmatcap_vert:B1,meshmatcap_frag:k1,meshnormal_vert:G1,meshnormal_frag:H1,meshphong_vert:V1,meshphong_frag:W1,meshphysical_vert:X1,meshphysical_frag:q1,meshtoon_vert:Y1,meshtoon_frag:K1,points_vert:Z1,points_frag:$1,shadow_vert:J1,shadow_frag:Q1,sprite_vert:j1,sprite_frag:ev},de={common:{diffuse:{value:new xe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new ze}},envmap:{envMap:{value:null},envMapRotation:{value:new ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new ze},normalScale:{value:new Fe(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new xe(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 U},probesMax:{value:new U},probesResolution:{value:new U}},points:{diffuse:{value:new xe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0},uvTransform:{value:new ze}},sprite:{diffuse:{value:new xe(16777215)},opacity:{value:1},center:{value:new Fe(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new ze},alphaMap:{value:null},alphaMapTransform:{value:new ze},alphaTest:{value:0}}},Tn={basic:{uniforms:Xt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.fog]),vertexShader:Ge.meshbasic_vert,fragmentShader:Ge.meshbasic_frag},lambert:{uniforms:Xt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new xe(0)},envMapIntensity:{value:1}}]),vertexShader:Ge.meshlambert_vert,fragmentShader:Ge.meshlambert_frag},phong:{uniforms:Xt([de.common,de.specularmap,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.fog,de.lights,{emissive:{value:new xe(0)},specular:{value:new xe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphong_vert,fragmentShader:Ge.meshphong_frag},standard:{uniforms:Xt([de.common,de.envmap,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.roughnessmap,de.metalnessmap,de.fog,de.lights,{emissive:{value:new xe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag},toon:{uniforms:Xt([de.common,de.aomap,de.lightmap,de.emissivemap,de.bumpmap,de.normalmap,de.displacementmap,de.gradientmap,de.fog,de.lights,{emissive:{value:new xe(0)}}]),vertexShader:Ge.meshtoon_vert,fragmentShader:Ge.meshtoon_frag},matcap:{uniforms:Xt([de.common,de.bumpmap,de.normalmap,de.displacementmap,de.fog,{matcap:{value:null}}]),vertexShader:Ge.meshmatcap_vert,fragmentShader:Ge.meshmatcap_frag},points:{uniforms:Xt([de.points,de.fog]),vertexShader:Ge.points_vert,fragmentShader:Ge.points_frag},dashed:{uniforms:Xt([de.common,de.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Ge.linedashed_vert,fragmentShader:Ge.linedashed_frag},depth:{uniforms:Xt([de.common,de.displacementmap]),vertexShader:Ge.depth_vert,fragmentShader:Ge.depth_frag},normal:{uniforms:Xt([de.common,de.bumpmap,de.normalmap,de.displacementmap,{opacity:{value:1}}]),vertexShader:Ge.meshnormal_vert,fragmentShader:Ge.meshnormal_frag},sprite:{uniforms:Xt([de.sprite,de.fog]),vertexShader:Ge.sprite_vert,fragmentShader:Ge.sprite_frag},background:{uniforms:{uvTransform:{value:new ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Ge.background_vert,fragmentShader:Ge.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new ze}},vertexShader:Ge.backgroundCube_vert,fragmentShader:Ge.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Ge.cube_vert,fragmentShader:Ge.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Ge.equirect_vert,fragmentShader:Ge.equirect_frag},distance:{uniforms:Xt([de.common,de.displacementmap,{referencePosition:{value:new U},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Ge.distance_vert,fragmentShader:Ge.distance_frag},shadow:{uniforms:Xt([de.lights,de.fog,{color:{value:new xe(0)},opacity:{value:1}}]),vertexShader:Ge.shadow_vert,fragmentShader:Ge.shadow_frag}};Tn.physical={uniforms:Xt([Tn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new ze},clearcoatNormalScale:{value:new Fe(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new ze},sheen:{value:0},sheenColor:{value:new xe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new ze},transmissionSamplerSize:{value:new Fe},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new ze},attenuationDistance:{value:0},attenuationColor:{value:new xe(0)},specularColor:{value:new xe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new ze},anisotropyVector:{value:new Fe},anisotropyMap:{value:null},anisotropyMapTransform:{value:new ze}}]),vertexShader:Ge.meshphysical_vert,fragmentShader:Ge.meshphysical_frag};const $r={r:0,b:0,g:0},tv=new ht,n0=new ze;n0.set(-1,0,0,0,1,0,0,0,1);function nv(i,e,t,n,s,r){const a=new xe(0);let o=s===!0?0:1,l,c,h=null,u=0,d=null;function p(w){let T=w.isScene===!0?w.background:null;if(T&&T.isTexture){const M=w.backgroundBlurriness>0;T=e.get(T,M)}return T}function g(w){let T=!1;const M=p(w);M===null?m(a,o):M&&M.isColor&&(m(M,1),T=!0);const S=i.xr.getEnvironmentBlendMode();S==="additive"?t.buffers.color.setClear(0,0,0,1,r):S==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(i.autoClear||T)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(w,T){const M=p(T);M&&(M.isCubeTexture||M.mapping===Ga)?(c===void 0&&(c=new rt(new dn(1,1,1),new Ft({name:"BackgroundCubeMaterial",uniforms:Ls(Tn.backgroundCube.uniforms),vertexShader:Tn.backgroundCube.vertexShader,fragmentShader:Tn.backgroundCube.fragmentShader,side:Nt,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(S,b,R){this.matrixWorld.copyPosition(R.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),n.update(c)),c.material.uniforms.envMap.value=M,c.material.uniforms.backgroundBlurriness.value=T.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(tv.makeRotationFromEuler(T.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(n0),c.material.toneMapped=Ye.getTransfer(M.colorSpace)!==je,(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null)):M&&M.isTexture&&(l===void 0&&(l=new rt(new Fs(2,2),new Ft({name:"BackgroundMaterial",uniforms:Ls(Tn.background.uniforms),vertexShader:Tn.background.vertexShader,fragmentShader:Tn.background.fragmentShader,side:_i,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),n.update(l)),l.material.uniforms.t2D.value=M,l.material.uniforms.backgroundIntensity.value=T.backgroundIntensity,l.material.toneMapped=Ye.getTransfer(M.colorSpace)!==je,M.matrixAutoUpdate===!0&&M.updateMatrix(),l.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null))}function m(w,T){w.getRGB($r,Jd(i)),t.buffers.color.setClear($r.r,$r.g,$r.b,T,r)}function f(){c!==void 0&&(c.geometry.dispose(),c.material.dispose(),c=void 0),l!==void 0&&(l.geometry.dispose(),l.material.dispose(),l=void 0)}return{getClearColor:function(){return a},setClearColor:function(w,T=1){a.set(w),o=T,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,m(a,o)},render:g,addToRenderList:x,dispose:f}}function iv(i,e){const t=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,L,X,q,F){let W=!1;const V=u(C,q,X,L);r!==V&&(r=V,c(r.object)),W=p(C,q,X,F),W&&g(C,q,X,F),F!==null&&e.update(F,i.ELEMENT_ARRAY_BUFFER),(W||a)&&(a=!1,M(C,L,X,q),F!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,e.get(F).buffer))}function l(){return i.createVertexArray()}function c(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,L,X,q){const F=q.wireframe===!0;let W=n[L.id];W===void 0&&(W={},n[L.id]=W);const V=C.isInstancedMesh===!0?C.id:0;let Q=W[V];Q===void 0&&(Q={},W[V]=Q);let te=Q[X.id];te===void 0&&(te={},Q[X.id]=te);let ee=te[F];return ee===void 0&&(ee=d(l()),te[F]=ee),ee}function d(C){const L=[],X=[],q=[];for(let F=0;F<t;F++)L[F]=0,X[F]=0,q[F]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:L,enabledAttributes:X,attributeDivisors:q,object:C,attributes:{},index:null}}function p(C,L,X,q){const F=r.attributes,W=L.attributes;let V=0;const Q=X.getAttributes();for(const te in Q)if(Q[te].location>=0){const se=F[te];let ge=W[te];if(ge===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(ge=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(ge=C.instanceColor)),se===void 0||se.attribute!==ge||ge&&se.data!==ge.data)return!0;V++}return r.attributesNum!==V||r.index!==q}function g(C,L,X,q){const F={},W=L.attributes;let V=0;const Q=X.getAttributes();for(const te in Q)if(Q[te].location>=0){let se=W[te];se===void 0&&(te==="instanceMatrix"&&C.instanceMatrix&&(se=C.instanceMatrix),te==="instanceColor"&&C.instanceColor&&(se=C.instanceColor));const ge={};ge.attribute=se,se&&se.data&&(ge.data=se.data),F[te]=ge,V++}r.attributes=F,r.attributesNum=V,r.index=q}function x(){const C=r.newAttributes;for(let L=0,X=C.length;L<X;L++)C[L]=0}function m(C){f(C,0)}function f(C,L){const X=r.newAttributes,q=r.enabledAttributes,F=r.attributeDivisors;X[C]=1,q[C]===0&&(i.enableVertexAttribArray(C),q[C]=1),F[C]!==L&&(i.vertexAttribDivisor(C,L),F[C]=L)}function w(){const C=r.newAttributes,L=r.enabledAttributes;for(let X=0,q=L.length;X<q;X++)L[X]!==C[X]&&(i.disableVertexAttribArray(X),L[X]=0)}function T(C,L,X,q,F,W,V){V===!0?i.vertexAttribIPointer(C,L,X,F,W):i.vertexAttribPointer(C,L,X,q,F,W)}function M(C,L,X,q){x();const F=q.attributes,W=X.getAttributes(),V=L.defaultAttributeValues;for(const Q in W){const te=W[Q];if(te.location>=0){let ee=F[Q];if(ee===void 0&&(Q==="instanceMatrix"&&C.instanceMatrix&&(ee=C.instanceMatrix),Q==="instanceColor"&&C.instanceColor&&(ee=C.instanceColor)),ee!==void 0){const se=ee.normalized,ge=ee.itemSize,Ve=e.get(ee);if(Ve===void 0)continue;const at=Ve.buffer,We=Ve.type,Z=Ve.bytesPerElement,re=We===i.INT||We===i.UNSIGNED_INT||ee.gpuType===Tc;if(ee.isInterleavedBufferAttribute){const ne=ee.data,k=ne.stride,De=ee.offset;if(ne.isInstancedInterleavedBuffer){for(let Pe=0;Pe<te.locationSize;Pe++)f(te.location+Pe,ne.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ne.meshPerAttribute*ne.count)}else for(let Pe=0;Pe<te.locationSize;Pe++)m(te.location+Pe);i.bindBuffer(i.ARRAY_BUFFER,at);for(let Pe=0;Pe<te.locationSize;Pe++)T(te.location+Pe,ge/te.locationSize,We,se,k*Z,(De+ge/te.locationSize*Pe)*Z,re)}else{if(ee.isInstancedBufferAttribute){for(let ne=0;ne<te.locationSize;ne++)f(te.location+ne,ee.meshPerAttribute);C.isInstancedMesh!==!0&&q._maxInstanceCount===void 0&&(q._maxInstanceCount=ee.meshPerAttribute*ee.count)}else for(let ne=0;ne<te.locationSize;ne++)m(te.location+ne);i.bindBuffer(i.ARRAY_BUFFER,at);for(let ne=0;ne<te.locationSize;ne++)T(te.location+ne,ge/te.locationSize,We,se,ge*Z,ge/te.locationSize*ne*Z,re)}}else if(V!==void 0){const se=V[Q];if(se!==void 0)switch(se.length){case 2:i.vertexAttrib2fv(te.location,se);break;case 3:i.vertexAttrib3fv(te.location,se);break;case 4:i.vertexAttrib4fv(te.location,se);break;default:i.vertexAttrib1fv(te.location,se)}}}}w()}function S(){E();for(const C in n){const L=n[C];for(const X in L){const q=L[X];for(const F in q){const W=q[F];for(const V in W)h(W[V].object),delete W[V];delete q[F]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const L=n[C.id];for(const X in L){const q=L[X];for(const F in q){const W=q[F];for(const V in W)h(W[V].object),delete W[V];delete q[F]}}delete n[C.id]}function R(C){for(const L in n){const X=n[L];for(const q in X){const F=X[q];if(F[C.id]===void 0)continue;const W=F[C.id];for(const V in W)h(W[V].object),delete W[V];delete F[C.id]}}}function _(C){for(const L in n){const X=n[L],q=C.isInstancedMesh===!0?C.id:0,F=X[q];if(F!==void 0){for(const W in F){const V=F[W];for(const Q in V)h(V[Q].object),delete V[Q];delete F[W]}delete X[q],Object.keys(X).length===0&&delete n[L]}}}function E(){D(),a=!0,r!==s&&(r=s,c(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:D,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:w}}function sv(i,e,t){let n;function s(l){n=l}function r(l,c){i.drawArrays(n,l,c),t.update(c,n,1)}function a(l,c,h){h!==0&&(i.drawArraysInstanced(n,l,c,h),t.update(c,n,h))}function o(l,c,h){if(h===0)return;e.get("WEBGL_multi_draw").multiDrawArraysWEBGL(n,l,0,c,0,h);let d=0;for(let p=0;p<h;p++)d+=c[p];t.update(d,n,1)}this.setMode=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function rv(i,e,t,n){let s;function r(){if(s!==void 0)return s;if(e.has("EXT_texture_filter_anisotropic")===!0){const R=e.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==_n&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===Jn&&(e.has("EXT_color_buffer_half_float")||e.has("EXT_color_buffer_float"));return!(R!==nn&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Ln&&!_)}function l(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const h=l(c);h!==c&&(Oe("WebGLRenderer:",c,"not supported, using",h,"instead."),c=h);const u=t.logarithmicDepthBuffer===!0,d=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&d===!1&&Oe("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const p=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),f=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),T=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:p,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:f,maxVertexUniforms:w,maxVaryings:T,maxFragmentUniforms:M,maxSamples:S,samples:b}}function av(i){const e=this;let t=null,n=0,s=!1,r=!1;const a=new Di,o=new ze,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(u,d){const p=u.length!==0||d||n!==0||s;return s=d,n=u.length,p},this.beginShadows=function(){r=!0,h(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(u,d){t=h(u,d,0)},this.setState=function(u,d,p){const g=u.clippingPlanes,x=u.clipIntersection,m=u.clipShadows,f=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):c();else{const w=r?0:n,T=w*4;let M=f.clippingState||null;l.value=M,M=h(g,d,T,p);for(let S=0;S!==T;++S)M[S]=t[S];f.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=n>0),e.numPlanes=n,e.numIntersection=0}function h(u,d,p,g){const x=u!==null?u.length:0;let m=null;if(x!==0){if(m=l.value,g!==!0||m===null){const f=p+x*4,w=d.matrixWorldInverse;o.getNormalMatrix(w),(m===null||m.length<f)&&(m=new Float32Array(f));for(let T=0,M=p;T!==x;++T,M+=4)a.copy(u[T]).applyMatrix4(w,o),a.normal.toArray(m,M),m[M+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=x,e.numIntersection=0,m}}const pi=4,Qh=[.125,.215,.35,.446,.526,.582],Ii=20,ov=256,Ys=new Wa,jh=new xe;let Do=null,Po=0,Io=0,Lo=!1;const lv=new U;class eu{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,n=.1,s=100,r={}){const{size:a=256,position:o=lv}=r;Do=this._renderer.getRenderTarget(),Po=this._renderer.getActiveCubeFace(),Io=this._renderer.getActiveMipmapLevel(),Lo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,n,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=iu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=nu(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e<this._lodMeshes.length;e++)this._lodMeshes[e].geometry.dispose()}_cleanup(e){this._renderer.setRenderTarget(Do,Po,Io),this._renderer.xr.enabled=Lo,e.scissorTest=!1,ds(e,0,0,e.width,e.height)}_fromTexture(e,t){e.mapping===ki||e.mapping===Ps?this._setSize(e.image.length===0?16:e.image[0].width||e.image[0].image.width):this._setSize(e.image.width/4),Do=this._renderer.getRenderTarget(),Po=this._renderer.getActiveCubeFace(),Io=this._renderer.getActiveMipmapLevel(),Lo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1;const n=t||this._allocateTargets();return this._textureToCubeUV(e,n),this._applyPMREM(n),this._cleanup(n),n}_allocateTargets(){const e=3*Math.max(this._cubeSize,112),t=4*this._cubeSize,n={magFilter:Gt,minFilter:Gt,generateMipmaps:!1,type:Jn,format:_n,colorSpace:Aa,depthBuffer:!1},s=tu(e,t,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==e||this._pingPongRenderTarget.height!==t){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=tu(e,t,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=cv(r)),this._blurMaterial=uv(r,e,t),this._ggxMaterial=hv(r,e,t)}return s}_compileMaterial(e){const t=new rt(new yt,e);this._renderer.compile(t,Ys)}_sceneToCubeUV(e,t,n,s,r){const l=new tn(90,1,t,n),c=[1,-1,1,1,1,1],h=[1,1,1,-1,-1,-1],u=this._renderer,d=u.autoClear,p=u.toneMapping;u.getClearColor(jh),u.toneMapping=Fn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new rt(new dn,new Hi({name:"PMREM.Background",side:Nt,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let f=!1;const w=e.background;w?w.isColor&&(m.color.copy(w),e.background=null,f=!0):(m.color.copy(jh),f=!0);for(let T=0;T<6;T++){const M=T%3;M===0?(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x+h[T],r.y,r.z)):M===1?(l.up.set(0,0,c[T]),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y+h[T],r.z)):(l.up.set(0,c[T],0),l.position.set(r.x,r.y,r.z),l.lookAt(r.x,r.y,r.z+h[T]));const S=this._cubeSize;ds(s,M*S,T>2?S:0,S,S),u.setRenderTarget(s),f&&u.render(x,l),u.render(e,l)}u.toneMapping=p,u.autoClear=d,e.background=w}_textureToCubeUV(e,t){const n=this._renderer,s=e.mapping===ki||e.mapping===Ps;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=iu()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=nu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;ds(t,0,0,3*l,2*l),n.setRenderTarget(t),n.render(a,Ys)}_applyPMREM(e){const t=this._renderer,n=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(e,r-1,r);t.autoClear=n}_applyGGXFilter(e,t,n){const s=this._renderer,r=this._pingPongRenderTarget,a=this._ggxMaterial,o=this._lodMeshes[n];o.material=a;const l=a.uniforms,c=n/(this._lodMeshes.length-1),h=t/(this._lodMeshes.length-1),u=Math.sqrt(c*c-h*h),d=0+c*1.25,p=u*d,{_lodMax:g}=this,x=this._sizeLods[n],m=3*x*(n>g-pi?n-g+pi:0),f=4*(this._cubeSize-x);l.envMap.value=e.texture,l.roughness.value=p,l.mipInt.value=g-t,ds(r,m,f,3*x,2*x),s.setRenderTarget(r),s.render(o,Ys),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=g-n,ds(e,m,f,3*x,2*x),s.setRenderTarget(e),s.render(o,Ys)}_blur(e,t,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,n,s,"latitudinal",r),this._halfBlur(a,e,n,n,s,"longitudinal",r)}_halfBlur(e,t,n,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&qe("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=c;const d=c.uniforms,p=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*p):2*Math.PI/(2*Ii-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Ii;m>Ii&&Oe(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ii}`);const f=[];let w=0;for(let R=0;R<Ii;++R){const _=R/x,E=Math.exp(-_*_/2);f.push(E),R===0?w+=E:R<m&&(w+=2*E)}for(let R=0;R<f.length;R++)f[R]=f[R]/w;d.envMap.value=e.texture,d.samples.value=m,d.weights.value=f,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:T}=this;d.dTheta.value=g,d.mipInt.value=T-n;const M=this._sizeLods[s],S=3*M*(s>T-pi?s-T+pi:0),b=4*(this._cubeSize-M);ds(t,S,b,3*M,2*M),l.setRenderTarget(t),l.render(u,Ys)}}function cv(i){const e=[],t=[],n=[];let s=i;const r=i-pi+1+Qh.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);e.push(o);let l=1/o;a>i-pi?l=Qh[a-i+pi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),h=-c,u=1+c,d=[h,h,u,h,u,u,h,h,u,u,h,u],p=6,g=6,x=3,m=2,f=1,w=new Float32Array(x*g*p),T=new Float32Array(m*g*p),M=new Float32Array(f*g*p);for(let b=0;b<p;b++){const R=b%3*2/3-1,_=b>2?0:-1,E=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];w.set(E,x*g*b),T.set(d,m*g*b);const D=[b,b,b,b,b,b];M.set(D,f*g*b)}const S=new yt;S.setAttribute("position",new ct(w,x)),S.setAttribute("uv",new ct(T,m)),S.setAttribute("faceIndex",new ct(M,f)),n.push(new rt(S,null)),s>pi&&s--}return{lodMeshes:n,sizeLods:e,sigmas:t}}function tu(i,e,t){const n=new Mn(i,e,t);return n.texture.mapping=Ga,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ds(i,e,t,n,s){i.viewport.set(e,t,n,s),i.scissor.set(e,t,n,s)}function hv(i,e,t){return new Ft({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:ov,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:Xa(),fragmentShader:`
|
|
4241
|
+
}`,Vt={alphahash_fragment:km,alphahash_pars_fragment:Gm,alphamap_fragment:Hm,alphamap_pars_fragment:Vm,alphatest_fragment:Wm,alphatest_pars_fragment:Xm,aomap_fragment:qm,aomap_pars_fragment:Ym,batching_pars_vertex:Km,batching_vertex:Zm,begin_vertex:$m,beginnormal_vertex:Jm,bsdfs:Qm,iridescence_fragment:jm,bumpmap_pars_fragment:tg,clipping_planes_fragment:eg,clipping_planes_pars_fragment:ng,clipping_planes_pars_vertex:ig,clipping_planes_vertex:sg,color_fragment:rg,color_pars_fragment:ag,color_pars_vertex:og,color_vertex:cg,common:lg,cube_uv_reflection_fragment:hg,defaultnormal_vertex:ug,displacementmap_pars_vertex:dg,displacementmap_vertex:fg,emissivemap_fragment:pg,emissivemap_pars_fragment:mg,colorspace_fragment:gg,colorspace_pars_fragment:vg,envmap_fragment:_g,envmap_common_pars_fragment:xg,envmap_pars_fragment:Mg,envmap_pars_vertex:yg,envmap_physical_pars_fragment:Ig,envmap_vertex:Sg,fog_vertex:Eg,fog_pars_vertex:bg,fog_fragment:wg,fog_pars_fragment:Ag,gradientmap_pars_fragment:Tg,lightmap_pars_fragment:Rg,lights_lambert_fragment:Cg,lights_lambert_pars_fragment:Dg,lights_pars_begin:Pg,lights_toon_fragment:Lg,lights_toon_pars_fragment:Ng,lights_phong_fragment:Ug,lights_phong_pars_fragment:Fg,lights_physical_fragment:Og,lights_physical_pars_fragment:zg,lights_fragment_begin:Bg,lights_fragment_maps:kg,lights_fragment_end:Gg,lightprobes_pars_fragment:Hg,logdepthbuf_fragment:Vg,logdepthbuf_pars_fragment:Wg,logdepthbuf_pars_vertex:Xg,logdepthbuf_vertex:qg,map_fragment:Yg,map_pars_fragment:Kg,map_particle_fragment:Zg,map_particle_pars_fragment:$g,metalnessmap_fragment:Jg,metalnessmap_pars_fragment:Qg,morphinstance_vertex:jg,morphcolor_vertex:t1,morphnormal_vertex:e1,morphtarget_pars_vertex:n1,morphtarget_vertex:i1,normal_fragment_begin:s1,normal_fragment_maps:r1,normal_pars_fragment:a1,normal_pars_vertex:o1,normal_vertex:c1,normalmap_pars_fragment:l1,clearcoat_normal_fragment_begin:h1,clearcoat_normal_fragment_maps:u1,clearcoat_pars_fragment:d1,iridescence_pars_fragment:f1,opaque_fragment:p1,packing:m1,premultiplied_alpha_fragment:g1,project_vertex:v1,dithering_fragment:_1,dithering_pars_fragment:x1,roughnessmap_fragment:M1,roughnessmap_pars_fragment:y1,shadowmap_pars_fragment:S1,shadowmap_pars_vertex:E1,shadowmap_vertex:b1,shadowmask_pars_fragment:w1,skinbase_vertex:A1,skinning_pars_vertex:T1,skinning_vertex:R1,skinnormal_vertex:C1,specularmap_fragment:D1,specularmap_pars_fragment:P1,tonemapping_fragment:I1,tonemapping_pars_fragment:L1,transmission_fragment:N1,transmission_pars_fragment:U1,uv_pars_fragment:F1,uv_pars_vertex:O1,uv_vertex:z1,worldpos_vertex:B1,background_vert:k1,background_frag:G1,backgroundCube_vert:H1,backgroundCube_frag:V1,cube_vert:W1,cube_frag:X1,depth_vert:q1,depth_frag:Y1,distance_vert:K1,distance_frag:Z1,equirect_vert:$1,equirect_frag:J1,linedashed_vert:Q1,linedashed_frag:j1,meshbasic_vert:tv,meshbasic_frag:ev,meshlambert_vert:nv,meshlambert_frag:iv,meshmatcap_vert:sv,meshmatcap_frag:rv,meshnormal_vert:av,meshnormal_frag:ov,meshphong_vert:cv,meshphong_frag:lv,meshphysical_vert:hv,meshphysical_frag:uv,meshtoon_vert:dv,meshtoon_frag:fv,points_vert:pv,points_frag:mv,shadow_vert:gv,shadow_frag:vv,sprite_vert:_v,sprite_frag:xv},ft={common:{diffuse:{value:new Mt(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new zt}},envmap:{envMap:{value:null},envMapRotation:{value:new zt},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new zt}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new zt}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new zt},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new zt},normalScale:{value:new Ft(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new zt},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new zt}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new zt}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new zt}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Mt(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 F},probesMax:{value:new F},probesResolution:{value:new F}},points:{diffuse:{value:new Mt(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0},uvTransform:{value:new zt}},sprite:{diffuse:{value:new Mt(16777215)},opacity:{value:1},center:{value:new Ft(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new zt},alphaMap:{value:null},alphaMapTransform:{value:new zt},alphaTest:{value:0}}},On={basic:{uniforms:Ke([ft.common,ft.specularmap,ft.envmap,ft.aomap,ft.lightmap,ft.fog]),vertexShader:Vt.meshbasic_vert,fragmentShader:Vt.meshbasic_frag},lambert:{uniforms:Ke([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 Mt(0)},envMapIntensity:{value:1}}]),vertexShader:Vt.meshlambert_vert,fragmentShader:Vt.meshlambert_frag},phong:{uniforms:Ke([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 Mt(0)},specular:{value:new Mt(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphong_vert,fragmentShader:Vt.meshphong_frag},standard:{uniforms:Ke([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 Mt(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag},toon:{uniforms:Ke([ft.common,ft.aomap,ft.lightmap,ft.emissivemap,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.gradientmap,ft.fog,ft.lights,{emissive:{value:new Mt(0)}}]),vertexShader:Vt.meshtoon_vert,fragmentShader:Vt.meshtoon_frag},matcap:{uniforms:Ke([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,ft.fog,{matcap:{value:null}}]),vertexShader:Vt.meshmatcap_vert,fragmentShader:Vt.meshmatcap_frag},points:{uniforms:Ke([ft.points,ft.fog]),vertexShader:Vt.points_vert,fragmentShader:Vt.points_frag},dashed:{uniforms:Ke([ft.common,ft.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Vt.linedashed_vert,fragmentShader:Vt.linedashed_frag},depth:{uniforms:Ke([ft.common,ft.displacementmap]),vertexShader:Vt.depth_vert,fragmentShader:Vt.depth_frag},normal:{uniforms:Ke([ft.common,ft.bumpmap,ft.normalmap,ft.displacementmap,{opacity:{value:1}}]),vertexShader:Vt.meshnormal_vert,fragmentShader:Vt.meshnormal_frag},sprite:{uniforms:Ke([ft.sprite,ft.fog]),vertexShader:Vt.sprite_vert,fragmentShader:Vt.sprite_frag},background:{uniforms:{uvTransform:{value:new zt},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Vt.background_vert,fragmentShader:Vt.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new zt}},vertexShader:Vt.backgroundCube_vert,fragmentShader:Vt.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Vt.cube_vert,fragmentShader:Vt.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Vt.equirect_vert,fragmentShader:Vt.equirect_frag},distance:{uniforms:Ke([ft.common,ft.displacementmap,{referencePosition:{value:new F},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Vt.distance_vert,fragmentShader:Vt.distance_frag},shadow:{uniforms:Ke([ft.lights,ft.fog,{color:{value:new Mt(0)},opacity:{value:1}}]),vertexShader:Vt.shadow_vert,fragmentShader:Vt.shadow_frag}};On.physical={uniforms:Ke([On.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new zt},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new zt},clearcoatNormalScale:{value:new Ft(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new zt},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new zt},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new zt},sheen:{value:0},sheenColor:{value:new Mt(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new zt},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new zt},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new zt},transmissionSamplerSize:{value:new Ft},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new zt},attenuationDistance:{value:0},attenuationColor:{value:new Mt(0)},specularColor:{value:new Mt(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new zt},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new zt},anisotropyVector:{value:new Ft},anisotropyMap:{value:null},anisotropyMapTransform:{value:new zt}}]),vertexShader:Vt.meshphysical_vert,fragmentShader:Vt.meshphysical_frag};const ca={r:0,b:0,g:0},Mv=new he,x0=new zt;x0.set(-1,0,0,0,1,0,0,0,1);function yv(i,t,e,n,s,r){const a=new Mt(0);let o=s===!0?0:1,c,l,h=null,u=0,d=null;function f(w){let A=w.isScene===!0?w.background:null;if(A&&A.isTexture){const M=w.backgroundBlurriness>0;A=t.get(A,M)}return A}function g(w){let A=!1;const M=f(w);M===null?m(a,o):M&&M.isColor&&(m(M,1),A=!0);const S=i.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),(i.autoClear||A)&&(e.buffers.depth.setTest(!0),e.buffers.depth.setMask(!0),e.buffers.color.setMask(!0),i.clear(i.autoClearColor,i.autoClearDepth,i.autoClearStencil))}function x(w,A){const M=f(A);M&&(M.isCubeTexture||M.mapping===to)?(l===void 0&&(l=new se(new Mn(1,1,1),new Be({name:"BackgroundCubeMaterial",uniforms:Vs(On.backgroundCube.uniforms),vertexShader:On.backgroundCube.vertexShader,fragmentShader:On.backgroundCube.fragmentShader,side:Ce,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),l.geometry.deleteAttribute("uv"),l.onBeforeRender=function(S,b,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=A.backgroundBlurriness,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.uniforms.backgroundRotation.value.setFromMatrix4(Mv.makeRotationFromEuler(A.backgroundRotation)).transpose(),M.isCubeTexture&&M.isRenderTargetTexture===!1&&l.material.uniforms.backgroundRotation.value.premultiply(x0),l.material.toneMapped=Kt.getTransfer(M.colorSpace)!==te,(h!==M||u!==M.version||d!==i.toneMapping)&&(l.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),l.layers.enableAll(),w.unshift(l,l.geometry,l.material,0,0,null)):M&&M.isTexture&&(c===void 0&&(c=new se(new qs(2,2),new Be({name:"BackgroundMaterial",uniforms:Vs(On.background.uniforms),vertexShader:On.background.vertexShader,fragmentShader:On.background.fragmentShader,side:Ti,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=A.backgroundIntensity,c.material.toneMapped=Kt.getTransfer(M.colorSpace)!==te,M.matrixAutoUpdate===!0&&M.updateMatrix(),c.material.uniforms.uvTransform.value.copy(M.matrix),(h!==M||u!==M.version||d!==i.toneMapping)&&(c.material.needsUpdate=!0,h=M,u=M.version,d=i.toneMapping),c.layers.enableAll(),w.unshift(c,c.geometry,c.material,0,0,null))}function m(w,A){w.getRGB(ca,p0(i)),e.buffers.color.setClear(ca.r,ca.g,ca.b,A,r)}function p(){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(w,A=1){a.set(w),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(w){o=w,m(a,o)},render:g,addToRenderList:x,dispose:p}}function Sv(i,t){const e=i.getParameter(i.MAX_VERTEX_ATTRIBS),n={},s=d(null);let r=s,a=!1;function o(C,I,W,X,U){let q=!1;const H=u(C,X,W,I);r!==H&&(r=H,l(r.object)),q=f(C,X,W,U),q&&g(C,X,W,U),U!==null&&t.update(U,i.ELEMENT_ARRAY_BUFFER),(q||a)&&(a=!1,M(C,I,W,X),U!==null&&i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,t.get(U).buffer))}function c(){return i.createVertexArray()}function l(C){return i.bindVertexArray(C)}function h(C){return i.deleteVertexArray(C)}function u(C,I,W,X){const U=X.wireframe===!0;let q=n[I.id];q===void 0&&(q={},n[I.id]=q);const H=C.isInstancedMesh===!0?C.id:0;let $=q[H];$===void 0&&($={},q[H]=$);let et=$[W.id];et===void 0&&(et={},$[W.id]=et);let j=et[U];return j===void 0&&(j=d(c()),et[U]=j),j}function d(C){const I=[],W=[],X=[];for(let U=0;U<e;U++)I[U]=0,W[U]=0,X[U]=0;return{geometry:null,program:null,wireframe:!1,newAttributes:I,enabledAttributes:W,attributeDivisors:X,object:C,attributes:{},index:null}}function f(C,I,W,X){const U=r.attributes,q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){const it=U[et];let ut=q[et];if(ut===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(ut=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(ut=C.instanceColor)),it===void 0||it.attribute!==ut||ut&&it.data!==ut.data)return!0;H++}return r.attributesNum!==H||r.index!==X}function g(C,I,W,X){const U={},q=I.attributes;let H=0;const $=W.getAttributes();for(const et in $)if($[et].location>=0){let it=q[et];it===void 0&&(et==="instanceMatrix"&&C.instanceMatrix&&(it=C.instanceMatrix),et==="instanceColor"&&C.instanceColor&&(it=C.instanceColor));const ut={};ut.attribute=it,it&&it.data&&(ut.data=it.data),U[et]=ut,H++}r.attributes=U,r.attributesNum=H,r.index=X}function x(){const C=r.newAttributes;for(let I=0,W=C.length;I<W;I++)C[I]=0}function m(C){p(C,0)}function p(C,I){const W=r.newAttributes,X=r.enabledAttributes,U=r.attributeDivisors;W[C]=1,X[C]===0&&(i.enableVertexAttribArray(C),X[C]=1),U[C]!==I&&(i.vertexAttribDivisor(C,I),U[C]=I)}function w(){const C=r.newAttributes,I=r.enabledAttributes;for(let W=0,X=I.length;W<X;W++)I[W]!==C[W]&&(i.disableVertexAttribArray(W),I[W]=0)}function A(C,I,W,X,U,q,H){H===!0?i.vertexAttribIPointer(C,I,W,U,q):i.vertexAttribPointer(C,I,W,X,U,q)}function M(C,I,W,X){x();const U=X.attributes,q=W.getAttributes(),H=I.defaultAttributeValues;for(const $ in q){const et=q[$];if(et.location>=0){let j=U[$];if(j===void 0&&($==="instanceMatrix"&&C.instanceMatrix&&(j=C.instanceMatrix),$==="instanceColor"&&C.instanceColor&&(j=C.instanceColor)),j!==void 0){const it=j.normalized,ut=j.itemSize,kt=t.get(j);if(kt===void 0)continue;const qt=kt.buffer,Bt=kt.type,Y=kt.bytesPerElement,rt=Bt===i.INT||Bt===i.UNSIGNED_INT||j.gpuType===Gl;if(j.isInterleavedBufferAttribute){const nt=j.data,z=nt.stride,bt=j.offset;if(nt.isInstancedInterleavedBuffer){for(let Dt=0;Dt<et.locationSize;Dt++)p(et.location+Dt,nt.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=nt.meshPerAttribute*nt.count)}else for(let Dt=0;Dt<et.locationSize;Dt++)m(et.location+Dt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let Dt=0;Dt<et.locationSize;Dt++)A(et.location+Dt,ut/et.locationSize,Bt,it,z*Y,(bt+ut/et.locationSize*Dt)*Y,rt)}else{if(j.isInstancedBufferAttribute){for(let nt=0;nt<et.locationSize;nt++)p(et.location+nt,j.meshPerAttribute);C.isInstancedMesh!==!0&&X._maxInstanceCount===void 0&&(X._maxInstanceCount=j.meshPerAttribute*j.count)}else for(let nt=0;nt<et.locationSize;nt++)m(et.location+nt);i.bindBuffer(i.ARRAY_BUFFER,qt);for(let nt=0;nt<et.locationSize;nt++)A(et.location+nt,ut/et.locationSize,Bt,it,ut*Y,ut/et.locationSize*nt*Y,rt)}}else if(H!==void 0){const it=H[$];if(it!==void 0)switch(it.length){case 2:i.vertexAttrib2fv(et.location,it);break;case 3:i.vertexAttrib3fv(et.location,it);break;case 4:i.vertexAttrib4fv(et.location,it);break;default:i.vertexAttrib1fv(et.location,it)}}}}w()}function S(){E();for(const C in n){const I=n[C];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C]}}function b(C){if(n[C.id]===void 0)return;const I=n[C.id];for(const W in I){const X=I[W];for(const U in X){const q=X[U];for(const H in q)h(q[H].object),delete q[H];delete X[U]}}delete n[C.id]}function R(C){for(const I in n){const W=n[I];for(const X in W){const U=W[X];if(U[C.id]===void 0)continue;const q=U[C.id];for(const H in q)h(q[H].object),delete q[H];delete U[C.id]}}}function _(C){for(const I in n){const W=n[I],X=C.isInstancedMesh===!0?C.id:0,U=W[X];if(U!==void 0){for(const q in U){const H=U[q];for(const $ in H)h(H[$].object),delete H[$];delete U[q]}delete W[X],Object.keys(W).length===0&&delete n[I]}}}function E(){D(),a=!0,r!==s&&(r=s,l(r.object))}function D(){s.geometry=null,s.program=null,s.wireframe=!1}return{setup:o,reset:E,resetDefaultState:D,dispose:S,releaseStatesOfGeometry:b,releaseStatesOfObject:_,releaseStatesOfProgram:R,initAttributes:x,enableAttribute:m,disableUnusedAttributes:w}}function Ev(i,t,e){let n;function s(c){n=c}function r(c,l){i.drawArrays(n,c,l),e.update(l,n,1)}function a(c,l,h){h!==0&&(i.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=s,this.render=r,this.renderInstances=a,this.renderMultiDraw=o}function bv(i,t,e,n){let s;function r(){if(s!==void 0)return s;if(t.has("EXT_texture_filter_anisotropic")===!0){const R=t.get("EXT_texture_filter_anisotropic");s=i.getParameter(R.MAX_TEXTURE_MAX_ANISOTROPY_EXT)}else s=0;return s}function a(R){return!(R!==un&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_FORMAT))}function o(R){const _=R===xn&&(t.has("EXT_color_buffer_half_float")||t.has("EXT_color_buffer_float"));return!(R!==ln&&n.convert(R)!==i.getParameter(i.IMPLEMENTATION_COLOR_READ_TYPE)&&R!==Vn&&!_)}function c(R){if(R==="highp"){if(i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.HIGH_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.HIGH_FLOAT).precision>0)return"highp";R="mediump"}return R==="mediump"&&i.getShaderPrecisionFormat(i.VERTEX_SHADER,i.MEDIUM_FLOAT).precision>0&&i.getShaderPrecisionFormat(i.FRAGMENT_SHADER,i.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let l=e.precision!==void 0?e.precision:"highp";const h=c(l);h!==l&&(Ot("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&&Ot("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS),g=i.getParameter(i.MAX_VERTEX_TEXTURE_IMAGE_UNITS),x=i.getParameter(i.MAX_TEXTURE_SIZE),m=i.getParameter(i.MAX_CUBE_MAP_TEXTURE_SIZE),p=i.getParameter(i.MAX_VERTEX_ATTRIBS),w=i.getParameter(i.MAX_VERTEX_UNIFORM_VECTORS),A=i.getParameter(i.MAX_VARYING_VECTORS),M=i.getParameter(i.MAX_FRAGMENT_UNIFORM_VECTORS),S=i.getParameter(i.MAX_SAMPLES),b=i.getParameter(i.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:c,textureFormatReadable:a,textureTypeReadable:o,precision:l,logarithmicDepthBuffer:u,reversedDepthBuffer:d,maxTextures:f,maxVertexTextures:g,maxTextureSize:x,maxCubemapSize:m,maxAttributes:p,maxVertexUniforms:w,maxVaryings:A,maxFragmentUniforms:M,maxSamples:S,samples:b}}function wv(i){const t=this;let e=null,n=0,s=!1,r=!1;const a=new ki,o=new zt,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||s;return s=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,x=u.clipIntersection,m=u.clipShadows,p=i.get(u);if(!s||g===null||g.length===0||r&&!m)r?h(null):l();else{const w=r?0:n,A=w*4;let M=p.clippingState||null;c.value=M,M=h(g,d,A,f);for(let S=0;S!==A;++S)M[S]=e[S];p.clippingState=M,this.numIntersection=x?this.numPlanes:0,this.numPlanes+=w}};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 x=u!==null?u.length:0;let m=null;if(x!==0){if(m=c.value,g!==!0||m===null){const p=f+x*4,w=d.matrixWorldInverse;o.getNormalMatrix(w),(m===null||m.length<p)&&(m=new Float32Array(p));for(let A=0,M=f;A!==x;++A,M+=4)a.copy(u[A]).applyMatrix4(w,o),a.normal.toArray(m,M),m[M+3]=a.constant}c.value=m,c.needsUpdate=!0}return t.numPlanes=x,t.numIntersection=0,m}}const Ei=4,du=[.125,.215,.35,.446,.526,.582],Hi=20,Av=256,ir=new io,fu=new Mt;let Vo=null,Wo=0,Xo=0,qo=!1;const Tv=new F;class pu{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,s=100,r={}){const{size:a=256,position:o=Tv}=r;Vo=this._renderer.getRenderTarget(),Wo=this._renderer.getActiveCubeFace(),Xo=this._renderer.getActiveMipmapLevel(),qo=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const c=this._allocateTargets();return c.depthBuffer=!0,this._sceneToCubeUV(t,n,s,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=vu(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=gu(),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(Vo,Wo,Xo),this._renderer.xr.enabled=qo,t.scissorTest=!1,ys(t,0,0,t.width,t.height)}_fromTexture(t,e){t.mapping===Zi||t.mapping===Gs?this._setSize(t.image.length===0?16:t.image[0].width||t.image[0].image.width):this._setSize(t.image.width/4),Vo=this._renderer.getRenderTarget(),Wo=this._renderer.getActiveCubeFace(),Xo=this._renderer.getActiveMipmapLevel(),qo=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:Te,minFilter:Te,generateMipmaps:!1,type:xn,format:un,colorSpace:za,depthBuffer:!1},s=mu(t,e,n);if(this._pingPongRenderTarget===null||this._pingPongRenderTarget.width!==t||this._pingPongRenderTarget.height!==e){this._pingPongRenderTarget!==null&&this._dispose(),this._pingPongRenderTarget=mu(t,e,n);const{_lodMax:r}=this;({lodMeshes:this._lodMeshes,sizeLods:this._sizeLods,sigmas:this._sigmas}=Rv(r)),this._blurMaterial=Dv(r,t,e),this._ggxMaterial=Cv(r,t,e)}return s}_compileMaterial(t){const e=new se(new Ee,t);this._renderer.compile(e,ir)}_sceneToCubeUV(t,e,n,s,r){const c=new cn(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(fu),u.toneMapping=qn,u.autoClear=!1,u.state.buffers.depth.getReversed()&&(u.setRenderTarget(s),u.clearDepth(),u.setRenderTarget(null)),this._backgroundBox===null&&(this._backgroundBox=new se(new Mn,new Ji({name:"PMREM.Background",side:Ce,depthWrite:!1,depthTest:!1})));const x=this._backgroundBox,m=x.material;let p=!1;const w=t.background;w?w.isColor&&(m.color.copy(w),t.background=null,p=!0):(m.color.copy(fu),p=!0);for(let A=0;A<6;A++){const M=A%3;M===0?(c.up.set(0,l[A],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x+h[A],r.y,r.z)):M===1?(c.up.set(0,0,l[A]),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y+h[A],r.z)):(c.up.set(0,l[A],0),c.position.set(r.x,r.y,r.z),c.lookAt(r.x,r.y,r.z+h[A]));const S=this._cubeSize;ys(s,M*S,A>2?S:0,S,S),u.setRenderTarget(s),p&&u.render(x,c),u.render(t,c)}u.toneMapping=f,u.autoClear=d,t.background=w}_textureToCubeUV(t,e){const n=this._renderer,s=t.mapping===Zi||t.mapping===Gs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=vu()),this._cubemapMaterial.uniforms.flipEnvMap.value=t.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=gu());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=t;const c=this._cubeSize;ys(e,0,0,3*c,2*c),n.setRenderTarget(e),n.render(a,ir)}_applyPMREM(t){const e=this._renderer,n=e.autoClear;e.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;r<s;r++)this._applyGGXFilter(t,r-1,r);e.autoClear=n}_applyGGXFilter(t,e,n){const s=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,x=this._sizeLods[n],m=3*x*(n>g-Ei?n-g+Ei:0),p=4*(this._cubeSize-x);c.envMap.value=t.texture,c.roughness.value=f,c.mipInt.value=g-e,ys(r,m,p,3*x,2*x),s.setRenderTarget(r),s.render(o,ir),c.envMap.value=r.texture,c.roughness.value=0,c.mipInt.value=g-n,ys(t,m,p,3*x,2*x),s.setRenderTarget(t),s.render(o,ir)}_blur(t,e,n,s,r){const a=this._pingPongRenderTarget;this._halfBlur(t,a,e,n,s,"latitudinal",r),this._halfBlur(a,t,n,n,s,"longitudinal",r)}_halfBlur(t,e,n,s,r,a,o){const c=this._renderer,l=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&Yt("blur direction must be either latitudinal or longitudinal!");const h=3,u=this._lodMeshes[s];u.material=l;const d=l.uniforms,f=this._sizeLods[n]-1,g=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Hi-1),x=r/g,m=isFinite(r)?1+Math.floor(h*x):Hi;m>Hi&&Ot(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Hi}`);const p=[];let w=0;for(let R=0;R<Hi;++R){const _=R/x,E=Math.exp(-_*_/2);p.push(E),R===0?w+=E:R<m&&(w+=2*E)}for(let R=0;R<p.length;R++)p[R]=p[R]/w;d.envMap.value=t.texture,d.samples.value=m,d.weights.value=p,d.latitudinal.value=a==="latitudinal",o&&(d.poleAxis.value=o);const{_lodMax:A}=this;d.dTheta.value=g,d.mipInt.value=A-n;const M=this._sizeLods[s],S=3*M*(s>A-Ei?s-A+Ei:0),b=4*(this._cubeSize-M);ys(e,S,b,3*M,2*M),c.setRenderTarget(e),c.render(u,ir)}}function Rv(i){const t=[],e=[],n=[];let s=i;const r=i-Ei+1+du.length;for(let a=0;a<r;a++){const o=Math.pow(2,s);t.push(o);let c=1/o;a>i-Ei?c=du[a-i+Ei-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,x=3,m=2,p=1,w=new Float32Array(x*g*f),A=new Float32Array(m*g*f),M=new Float32Array(p*g*f);for(let b=0;b<f;b++){const R=b%3*2/3-1,_=b>2?0:-1,E=[R,_,0,R+2/3,_,0,R+2/3,_+1,0,R,_,0,R+2/3,_+1,0,R,_+1,0];w.set(E,x*g*b),A.set(d,m*g*b);const D=[b,b,b,b,b,b];M.set(D,p*g*b)}const S=new Ee;S.setAttribute("position",new le(w,x)),S.setAttribute("uv",new le(A,m)),S.setAttribute("faceIndex",new le(M,p)),n.push(new se(S,null)),s>Ei&&s--}return{lodMeshes:n,sizeLods:t,sigmas:e}}function mu(i,t,e){const n=new Rn(i,t,e);return n.texture.mapping=to,n.texture.name="PMREM.cubeUv",n.scissorTest=!0,n}function ys(i,t,e,n,s){i.viewport.set(t,e,n,s),i.scissor.set(t,e,n,s)}function Cv(i,t,e){return new Be({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Av,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:so(),fragmentShader:`
|
|
4242
4242
|
|
|
4243
4243
|
precision highp float;
|
|
4244
4244
|
precision highp int;
|
|
@@ -4342,7 +4342,7 @@ void main() {
|
|
|
4342
4342
|
|
|
4343
4343
|
gl_FragColor = vec4(prefilteredColor, 1.0);
|
|
4344
4344
|
}
|
|
4345
|
-
`,blending:
|
|
4345
|
+
`,blending:si,depthTest:!1,depthWrite:!1})}function Dv(i,t,e){const n=new Float32Array(Hi),s=new F(0,1,0);return new Be({name:"SphericalGaussianBlur",defines:{n:Hi,CUBEUV_TEXEL_WIDTH:1/t,CUBEUV_TEXEL_HEIGHT:1/e,CUBEUV_MAX_MIP:`${i}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:n},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:so(),fragmentShader:`
|
|
4346
4346
|
|
|
4347
4347
|
precision mediump float;
|
|
4348
4348
|
precision mediump int;
|
|
@@ -4402,7 +4402,7 @@ void main() {
|
|
|
4402
4402
|
}
|
|
4403
4403
|
|
|
4404
4404
|
}
|
|
4405
|
-
`,blending:
|
|
4405
|
+
`,blending:si,depthTest:!1,depthWrite:!1})}function gu(){return new Be({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:so(),fragmentShader:`
|
|
4406
4406
|
|
|
4407
4407
|
precision mediump float;
|
|
4408
4408
|
precision mediump int;
|
|
@@ -4421,7 +4421,7 @@ void main() {
|
|
|
4421
4421
|
gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 );
|
|
4422
4422
|
|
|
4423
4423
|
}
|
|
4424
|
-
`,blending:
|
|
4424
|
+
`,blending:si,depthTest:!1,depthWrite:!1})}function vu(){return new Be({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:so(),fragmentShader:`
|
|
4425
4425
|
|
|
4426
4426
|
precision mediump float;
|
|
4427
4427
|
precision mediump int;
|
|
@@ -4437,7 +4437,7 @@ void main() {
|
|
|
4437
4437
|
gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) );
|
|
4438
4438
|
|
|
4439
4439
|
}
|
|
4440
|
-
`,blending:
|
|
4440
|
+
`,blending:si,depthTest:!1,depthWrite:!1})}function so(){return`
|
|
4441
4441
|
|
|
4442
4442
|
precision mediump float;
|
|
4443
4443
|
precision mediump int;
|
|
@@ -4492,7 +4492,7 @@ void main() {
|
|
|
4492
4492
|
gl_Position = vec4( position, 1.0 );
|
|
4493
4493
|
|
|
4494
4494
|
}
|
|
4495
|
-
`}class
|
|
4495
|
+
`}class M0 extends Rn{constructor(t=1,e={}){super(t,t,e),this.isWebGLCubeRenderTarget=!0;const n={width:t,height:t,depth:1},s=[n,n,n,n,n,n];this.texture=new d0(s),this._setTextureOptions(e),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(t,e){this.texture.type=e.type,this.texture.colorSpace=e.colorSpace,this.texture.generateMipmaps=e.generateMipmaps,this.texture.minFilter=e.minFilter,this.texture.magFilter=e.magFilter;const n={uniforms:{tEquirect:{value:null}},vertexShader:`
|
|
4496
4496
|
|
|
4497
4497
|
varying vec3 vWorldDirection;
|
|
4498
4498
|
|
|
@@ -4527,7 +4527,7 @@ void main() {
|
|
|
4527
4527
|
gl_FragColor = texture2D( tEquirect, sampleUV );
|
|
4528
4528
|
|
|
4529
4529
|
}
|
|
4530
|
-
`},s=new
|
|
4530
|
+
`},s=new Mn(5,5,5),r=new Be({name:"CubemapFromEquirect",uniforms:Vs(n.uniforms),vertexShader:n.vertexShader,fragmentShader:n.fragmentShader,side:Ce,blending:si});r.uniforms.tEquirect.value=e;const a=new se(s,r),o=e.minFilter;return e.minFilter===Xi&&(e.minFilter=Te),new Fm(1,10,this).update(t,a),e.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(t,e=!0,n=!0,s=!0){const r=t.getRenderTarget();for(let a=0;a<6;a++)t.setRenderTarget(this,a),t.clear(e,n,s);t.setRenderTarget(r)}}function Pv(i){let t=new WeakMap,e=new WeakMap,n=null;function s(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===fo||f===po)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 x=new M0(g.height);return x.fromEquirectangularTexture(i,d),t.set(d,x),d.addEventListener("dispose",l),o(x.texture,d.mapping)}else return null}}return d}function a(d){if(d&&d.isTexture){const f=d.mapping,g=f===fo||f===po,x=f===Zi||f===Gs;if(g||x){let m=e.get(d);const p=m!==void 0?m.texture.pmremVersion:0;if(d.isRenderTargetTexture&&d.pmremVersion!==p)return n===null&&(n=new pu(i)),m=g?n.fromEquirectangular(d,m):n.fromCubemap(d,m),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),m.texture;if(m!==void 0)return m.texture;{const w=d.image;return g&&w&&w.height>0||x&&w&&c(w)?(n===null&&(n=new pu(i)),m=g?n.fromEquirectangular(d):n.fromCubemap(d),m.texture.pmremVersion=d.pmremVersion,e.set(d,m),d.addEventListener("dispose",h),m.texture):null}}}return d}function o(d,f){return f===fo?d.mapping=Zi:f===po&&(d.mapping=Gs),d}function c(d){let f=0;const g=6;for(let x=0;x<g;x++)d[x]!==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:s,dispose:u}}function Iv(i){const t={};function e(n){if(t[n]!==void 0)return t[n];const s=i.getExtension(n);return t[n]=s,s}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 s=e(n);return s===null&&Ls("WebGLRenderer: "+n+" extension not supported."),s}}}function Lv(i,t,e,n){const s={},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 s[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 s[d.id]===!0||(d.addEventListener("dispose",a),s[d.id]=!0,e.memory.geometries++),d}function c(u){const d=u.attributes;for(const f in d)t.update(d[f],i.ARRAY_BUFFER)}function l(u){const d=[],f=u.index,g=u.attributes.position;let x=0;if(g===void 0)return;if(f!==null){const w=f.array;x=f.version;for(let A=0,M=w.length;A<M;A+=3){const S=w[A+0],b=w[A+1],R=w[A+2];d.push(S,b,b,R,R,S)}}else{const w=g.array;x=g.version;for(let A=0,M=w.length/3-1;A<M;A+=3){const S=A+0,b=A+1,R=A+2;d.push(S,b,b,R,R,S)}}const m=new(g.count>=65535?l0:c0)(d,1);m.version=x;const p=r.get(u);p&&t.remove(p),r.set(u,m)}function h(u){const d=r.get(u);if(d){const f=u.index;f!==null&&d.version<f.version&&l(u)}else l(u);return r.get(u)}return{get:o,update:c,getWireframeAttribute:h}}function Nv(i,t,e){let n;function s(u){n=u}let r,a;function o(u){r=u.type,a=u.bytesPerElement}function c(u,d){i.drawElements(n,d,r,u*a),e.update(d,n,1)}function l(u,d,f){f!==0&&(i.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 x=0;for(let m=0;m<f;m++)x+=d[m];e.update(x,n,1)}this.setMode=s,this.setIndex=o,this.render=c,this.renderInstances=l,this.renderMultiDraw=h}function Uv(i){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 i.TRIANGLES:e.triangles+=o*(r/3);break;case i.LINES:e.lines+=o*(r/2);break;case i.LINE_STRIP:e.lines+=o*(r-1);break;case i.LINE_LOOP:e.lines+=o*r;break;case i.POINTS:e.points+=o*r;break;default:Yt("WebGLInfo: Unknown draw mode:",a);break}}function s(){e.calls=0,e.triangles=0,e.points=0,e.lines=0}return{memory:t,render:e,programs:null,autoReset:!0,reset:s,update:n}}function Fv(i,t,e){const n=new WeakMap,s=new pe;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 E=function(){R.dispose(),n.delete(o),o.removeEventListener("dispose",E)};d!==void 0&&d.texture.dispose();const f=o.morphAttributes.position!==void 0,g=o.morphAttributes.normal!==void 0,x=o.morphAttributes.color!==void 0,m=o.morphAttributes.position||[],p=o.morphAttributes.normal||[],w=o.morphAttributes.color||[];let A=0;f===!0&&(A=1),g===!0&&(A=2),x===!0&&(A=3);let M=o.attributes.position.count*A,S=1;M>t.maxTextureSize&&(S=Math.ceil(M/t.maxTextureSize),M=t.maxTextureSize);const b=new Float32Array(M*S*4*u),R=new r0(b,M,S,u);R.type=Vn,R.needsUpdate=!0;const _=A*4;for(let D=0;D<u;D++){const C=m[D],I=p[D],W=w[D],X=M*S*4*D;for(let U=0;U<C.count;U++){const q=U*_;f===!0&&(s.fromBufferAttribute(C,U),b[X+q+0]=s.x,b[X+q+1]=s.y,b[X+q+2]=s.z,b[X+q+3]=0),g===!0&&(s.fromBufferAttribute(I,U),b[X+q+4]=s.x,b[X+q+5]=s.y,b[X+q+6]=s.z,b[X+q+7]=0),x===!0&&(s.fromBufferAttribute(W,U),b[X+q+8]=s.x,b[X+q+9]=s.y,b[X+q+10]=s.z,b[X+q+11]=W.itemSize===4?s.w:1)}}d={count:u,texture:R,size:new Ft(M,S)},n.set(o,d),o.addEventListener("dispose",E)}if(a.isInstancedMesh===!0&&a.morphTexture!==null)c.getUniforms().setValue(i,"morphTexture",a.morphTexture,e);else{let f=0;for(let x=0;x<l.length;x++)f+=l[x];const g=o.morphTargetsRelative?1:1-f;c.getUniforms().setValue(i,"morphTargetBaseInfluence",g),c.getUniforms().setValue(i,"morphTargetInfluences",l)}c.getUniforms().setValue(i,"morphTargetsTexture",d.texture,e),c.getUniforms().setValue(i,"morphTargetsTextureSize",d.size)}return{update:r}}function Ov(i,t,e,n,s){let r=new WeakMap;function a(l){const h=s.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,i.ARRAY_BUFFER),l.instanceColor!==null&&e.update(l.instanceColor,i.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 zv={[Vd]:"LINEAR_TONE_MAPPING",[Wd]:"REINHARD_TONE_MAPPING",[Xd]:"CINEON_TONE_MAPPING",[qd]:"ACES_FILMIC_TONE_MAPPING",[Kd]:"AGX_TONE_MAPPING",[Zd]:"NEUTRAL_TONE_MAPPING",[Yd]:"CUSTOM_TONE_MAPPING"};function Bv(i,t,e,n,s,r){const a=new Rn(t,e,{type:i,depthBuffer:s,stencilBuffer:r,samples:n?4:0,depthTexture:s?new Hs(t,e):void 0}),o=new Rn(t,e,{type:xn,depthBuffer:!1,stencilBuffer:!1}),c=new Ee;c.setAttribute("position",new De([-1,3,0,-1,-1,0,3,-1,0],3)),c.setAttribute("uv",new De([0,2,0,0,2,0],2));const l=new Rm({uniforms:{tDiffuse:{value:null}},vertexShader:`
|
|
4531
4531
|
precision highp float;
|
|
4532
4532
|
|
|
4533
4533
|
uniform mat4 modelViewMatrix;
|
|
@@ -4573,17 +4573,17 @@ void main() {
|
|
|
4573
4573
|
#ifdef SRGB_TRANSFER
|
|
4574
4574
|
gl_FragColor = sRGBTransferOETF( gl_FragColor );
|
|
4575
4575
|
#endif
|
|
4576
|
-
}`,depthTest:!1,depthWrite:!1}),h=new
|
|
4577
|
-
`),n=[],s=Math.max(
|
|
4578
|
-
`)}const
|
|
4576
|
+
}`,depthTest:!1,depthWrite:!1}),h=new se(c,l),u=new io(-1,1,1,-1,0,1);let d=null,f=null,g=!1,x,m=null,p=[],w=!1;this.setSize=function(A,M){a.setSize(A,M),o.setSize(A,M);for(let S=0;S<p.length;S++){const b=p[S];b.setSize&&b.setSize(A,M)}},this.setEffects=function(A){p=A,w=p.length>0&&p[0].isRenderPass===!0;const M=a.width,S=a.height;for(let b=0;b<p.length;b++){const R=p[b];R.setSize&&R.setSize(M,S)}},this.begin=function(A,M){if(g||A.toneMapping===qn&&p.length===0)return!1;if(m=M,M!==null){const S=M.width,b=M.height;(a.width!==S||a.height!==b)&&this.setSize(S,b)}return w===!1&&A.setRenderTarget(a),x=A.toneMapping,A.toneMapping=qn,!0},this.hasRenderPass=function(){return w},this.end=function(A,M){A.toneMapping=x,g=!0;let S=a,b=o;for(let R=0;R<p.length;R++){const _=p[R];if(_.enabled!==!1&&(_.render(A,b,S,M),_.needsSwap!==!1)){const E=S;S=b,b=E}}if(d!==A.outputColorSpace||f!==A.toneMapping){d=A.outputColorSpace,f=A.toneMapping,l.defines={},Kt.getTransfer(d)===te&&(l.defines.SRGB_TRANSFER="");const R=zv[f];R&&(l.defines[R]=""),l.needsUpdate=!0}l.uniforms.tDiffuse.value=S.texture,A.setRenderTarget(m),A.render(h,u),m=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 y0=new qe,hl=new Hs(1,1),S0=new r0,E0=new im,b0=new d0,_u=[],xu=[],Mu=new Float32Array(16),yu=new Float32Array(9),Su=new Float32Array(4);function Ys(i,t,e){const n=i[0];if(n<=0||n>0)return i;const s=t*e;let r=_u[s];if(r===void 0&&(r=new Float32Array(s),_u[s]=r),t!==0){n.toArray(r,0);for(let a=1,o=0;a!==t;++a)o+=e,i[a].toArray(r,o)}return r}function Pe(i,t){if(i.length!==t.length)return!1;for(let e=0,n=i.length;e<n;e++)if(i[e]!==t[e])return!1;return!0}function Ie(i,t){for(let e=0,n=t.length;e<n;e++)i[e]=t[e]}function ro(i,t){let e=xu[t];e===void 0&&(e=new Int32Array(t),xu[t]=e);for(let n=0;n!==t;++n)e[n]=i.allocateTextureUnit();return e}function kv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1f(this.addr,t),e[0]=t)}function Gv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2f(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Pe(e,t))return;i.uniform2fv(this.addr,t),Ie(e,t)}}function Hv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.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)&&(i.uniform3f(this.addr,t.r,t.g,t.b),e[0]=t.r,e[1]=t.g,e[2]=t.b);else{if(Pe(e,t))return;i.uniform3fv(this.addr,t),Ie(e,t)}}function Vv(i,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)&&(i.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(Pe(e,t))return;i.uniform4fv(this.addr,t),Ie(e,t)}}function Wv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix2fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;Su.set(n),i.uniformMatrix2fv(this.addr,!1,Su),Ie(e,n)}}function Xv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix3fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;yu.set(n),i.uniformMatrix3fv(this.addr,!1,yu),Ie(e,n)}}function qv(i,t){const e=this.cache,n=t.elements;if(n===void 0){if(Pe(e,t))return;i.uniformMatrix4fv(this.addr,!1,t),Ie(e,t)}else{if(Pe(e,n))return;Mu.set(n),i.uniformMatrix4fv(this.addr,!1,Mu),Ie(e,n)}}function Yv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1i(this.addr,t),e[0]=t)}function Kv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2i(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Pe(e,t))return;i.uniform2iv(this.addr,t),Ie(e,t)}}function Zv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3i(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Pe(e,t))return;i.uniform3iv(this.addr,t),Ie(e,t)}}function $v(i,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)&&(i.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(Pe(e,t))return;i.uniform4iv(this.addr,t),Ie(e,t)}}function Jv(i,t){const e=this.cache;e[0]!==t&&(i.uniform1ui(this.addr,t),e[0]=t)}function Qv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y)&&(i.uniform2ui(this.addr,t.x,t.y),e[0]=t.x,e[1]=t.y);else{if(Pe(e,t))return;i.uniform2uiv(this.addr,t),Ie(e,t)}}function jv(i,t){const e=this.cache;if(t.x!==void 0)(e[0]!==t.x||e[1]!==t.y||e[2]!==t.z)&&(i.uniform3ui(this.addr,t.x,t.y,t.z),e[0]=t.x,e[1]=t.y,e[2]=t.z);else{if(Pe(e,t))return;i.uniform3uiv(this.addr,t),Ie(e,t)}}function t2(i,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)&&(i.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(Pe(e,t))return;i.uniform4uiv(this.addr,t),Ie(e,t)}}function e2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s);let r;this.type===i.SAMPLER_2D_SHADOW?(hl.compareFunction=e.isReversedDepthBuffer()?Kl:Yl,r=hl):r=y0,e.setTexture2D(t||r,s)}function n2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture3D(t||E0,s)}function i2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTextureCube(t||b0,s)}function s2(i,t,e){const n=this.cache,s=e.allocateTextureUnit();n[0]!==s&&(i.uniform1i(this.addr,s),n[0]=s),e.setTexture2DArray(t||S0,s)}function r2(i){switch(i){case 5126:return kv;case 35664:return Gv;case 35665:return Hv;case 35666:return Vv;case 35674:return Wv;case 35675:return Xv;case 35676:return qv;case 5124:case 35670:return Yv;case 35667:case 35671:return Kv;case 35668:case 35672:return Zv;case 35669:case 35673:return $v;case 5125:return Jv;case 36294:return Qv;case 36295:return jv;case 36296:return t2;case 35678:case 36198:case 36298:case 36306:case 35682:return e2;case 35679:case 36299:case 36307:return n2;case 35680:case 36300:case 36308:case 36293:return i2;case 36289:case 36303:case 36311:case 36292:return s2}}function a2(i,t){i.uniform1fv(this.addr,t)}function o2(i,t){const e=Ys(t,this.size,2);i.uniform2fv(this.addr,e)}function c2(i,t){const e=Ys(t,this.size,3);i.uniform3fv(this.addr,e)}function l2(i,t){const e=Ys(t,this.size,4);i.uniform4fv(this.addr,e)}function h2(i,t){const e=Ys(t,this.size,4);i.uniformMatrix2fv(this.addr,!1,e)}function u2(i,t){const e=Ys(t,this.size,9);i.uniformMatrix3fv(this.addr,!1,e)}function d2(i,t){const e=Ys(t,this.size,16);i.uniformMatrix4fv(this.addr,!1,e)}function f2(i,t){i.uniform1iv(this.addr,t)}function p2(i,t){i.uniform2iv(this.addr,t)}function m2(i,t){i.uniform3iv(this.addr,t)}function g2(i,t){i.uniform4iv(this.addr,t)}function v2(i,t){i.uniform1uiv(this.addr,t)}function _2(i,t){i.uniform2uiv(this.addr,t)}function x2(i,t){i.uniform3uiv(this.addr,t)}function M2(i,t){i.uniform4uiv(this.addr,t)}function y2(i,t,e){const n=this.cache,s=t.length,r=ro(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));let a;this.type===i.SAMPLER_2D_SHADOW?a=hl:a=y0;for(let o=0;o!==s;++o)e.setTexture2D(t[o]||a,r[o])}function S2(i,t,e){const n=this.cache,s=t.length,r=ro(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture3D(t[a]||E0,r[a])}function E2(i,t,e){const n=this.cache,s=t.length,r=ro(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTextureCube(t[a]||b0,r[a])}function b2(i,t,e){const n=this.cache,s=t.length,r=ro(e,s);Pe(n,r)||(i.uniform1iv(this.addr,r),Ie(n,r));for(let a=0;a!==s;++a)e.setTexture2DArray(t[a]||S0,r[a])}function w2(i){switch(i){case 5126:return a2;case 35664:return o2;case 35665:return c2;case 35666:return l2;case 35674:return h2;case 35675:return u2;case 35676:return d2;case 5124:case 35670:return f2;case 35667:case 35671:return p2;case 35668:case 35672:return m2;case 35669:case 35673:return g2;case 5125:return v2;case 36294:return _2;case 36295:return x2;case 36296:return M2;case 35678:case 36198:case 36298:case 36306:case 35682:return y2;case 35679:case 36299:case 36307:return S2;case 35680:case 36300:case 36308:case 36293:return E2;case 36289:case 36303:case 36311:case 36292:return b2}}class A2{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.setValue=r2(e.type)}}class T2{constructor(t,e,n){this.id=t,this.addr=n,this.cache=[],this.type=e.type,this.size=e.size,this.setValue=w2(e.type)}}class R2{constructor(t){this.id=t,this.seq=[],this.map={}}setValue(t,e,n){const s=this.seq;for(let r=0,a=s.length;r!==a;++r){const o=s[r];o.setValue(t,e[o.id],n)}}}const Yo=/(\w+)(\])?(\[|\.)?/g;function Eu(i,t){i.seq.push(t),i.map[t.id]=t}function C2(i,t,e){const n=i.name,s=n.length;for(Yo.lastIndex=0;;){const r=Yo.exec(n),a=Yo.lastIndex;let o=r[1];const c=r[2]==="]",l=r[3];if(c&&(o=o|0),l===void 0||l==="["&&a+2===s){Eu(e,l===void 0?new A2(o,i,t):new T2(o,i,t));break}else{let u=e.map[o];u===void 0&&(u=new R2(o),Eu(e,u)),e=u}}}class Ia{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);C2(o,c,this)}const s=[],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?s.push(a):r.push(a);s.length>0&&(this.seq=s.concat(r))}setValue(t,e,n,s){const r=this.map[e];r!==void 0&&r.setValue(t,n,s)}setOptional(t,e,n){const s=e[n];s!==void 0&&this.setValue(t,n,s)}static upload(t,e,n,s){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,s)}}static seqWithValue(t,e){const n=[];for(let s=0,r=t.length;s!==r;++s){const a=t[s];a.id in e&&n.push(a)}return n}}function bu(i,t,e){const n=i.createShader(t);return i.shaderSource(n,e),i.compileShader(n),n}const D2=37297;let P2=0;function I2(i,t){const e=i.split(`
|
|
4577
|
+
`),n=[],s=Math.max(t-6,0),r=Math.min(t+6,e.length);for(let a=s;a<r;a++){const o=a+1;n.push(`${o===t?">":" "} ${o}: ${e[a]}`)}return n.join(`
|
|
4578
|
+
`)}const wu=new zt;function L2(i){Kt._getMatrix(wu,Kt.workingColorSpace,i);const t=`mat3( ${wu.elements.map(e=>e.toFixed(4))} )`;switch(Kt.getTransfer(i)){case Ba:return[t,"LinearTransferOETF"];case te:return[t,"sRGBTransferOETF"];default:return Ot("WebGLProgram: Unsupported color space: ",i),[t,"LinearTransferOETF"]}}function Au(i,t,e){const n=i.getShaderParameter(t,i.COMPILE_STATUS),r=(i.getShaderInfoLog(t)||"").trim();if(n&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return e.toUpperCase()+`
|
|
4579
4579
|
|
|
4580
4580
|
`+r+`
|
|
4581
4581
|
|
|
4582
|
-
`+
|
|
4583
|
-
`)}const
|
|
4584
|
-
`)}function
|
|
4585
|
-
`)}function
|
|
4586
|
-
`)}function
|
|
4582
|
+
`+I2(i.getShaderSource(t),o)}else return r}function N2(i,t){const e=L2(t);return[`vec4 ${i}( vec4 value ) {`,` return ${e[1]}( vec4( value.rgb * ${e[0]}, value.a ) );`,"}"].join(`
|
|
4583
|
+
`)}const U2={[Vd]:"Linear",[Wd]:"Reinhard",[Xd]:"Cineon",[qd]:"ACESFilmic",[Kd]:"AgX",[Zd]:"Neutral",[Yd]:"Custom"};function F2(i,t){const e=U2[t];return e===void 0?(Ot("WebGLProgram: Unsupported toneMapping:",t),"vec3 "+i+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+i+"( vec3 color ) { return "+e+"ToneMapping( color ); }"}const la=new F;function O2(){Kt.getLuminanceCoefficients(la);const i=la.x.toFixed(4),t=la.y.toFixed(4),e=la.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${i}, ${t}, ${e} );`," return dot( weights, rgb );","}"].join(`
|
|
4584
|
+
`)}function z2(i){return[i.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",i.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(ur).join(`
|
|
4585
|
+
`)}function B2(i){const t=[];for(const e in i){const n=i[e];n!==!1&&t.push("#define "+e+" "+n)}return t.join(`
|
|
4586
|
+
`)}function k2(i,t){const e={},n=i.getProgramParameter(t,i.ACTIVE_ATTRIBUTES);for(let s=0;s<n;s++){const r=i.getActiveAttrib(t,s),a=r.name;let o=1;r.type===i.FLOAT_MAT2&&(o=2),r.type===i.FLOAT_MAT3&&(o=3),r.type===i.FLOAT_MAT4&&(o=4),e[a]={type:r.type,location:i.getAttribLocation(t,a),locationSize:o}}return e}function ur(i){return i!==""}function Tu(i,t){const e=t.numSpotLightShadows+t.numSpotLightMaps-t.numSpotLightShadowsWithMaps;return i.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 Ru(i,t){return i.replace(/NUM_CLIPPING_PLANES/g,t.numClippingPlanes).replace(/UNION_CLIPPING_PLANES/g,t.numClippingPlanes-t.numClipIntersection)}const G2=/^[ \t]*#include +<([\w\d./]+)>/gm;function ul(i){return i.replace(G2,V2)}const H2=new Map;function V2(i,t){let e=Vt[t];if(e===void 0){const n=H2.get(t);if(n!==void 0)e=Vt[n],Ot('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',t,n);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+t+">")}return ul(e)}const W2=/#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 Cu(i){return i.replace(W2,X2)}function X2(i,t,e,n){let s="";for(let r=parseInt(t);r<parseInt(e);r++)s+=n.replace(/\[\s*i\s*\]/g,"[ "+r+" ]").replace(/UNROLLED_LOOP_INDEX/g,r);return s}function Du(i){let t=`precision ${i.precision} float;
|
|
4587
4587
|
precision ${i.precision} int;
|
|
4588
4588
|
precision ${i.precision} sampler2D;
|
|
4589
4589
|
precision ${i.precision} samplerCube;
|
|
@@ -4600,33 +4600,33 @@ void main() {
|
|
|
4600
4600
|
precision ${i.precision} usampler3D;
|
|
4601
4601
|
precision ${i.precision} usamplerCube;
|
|
4602
4602
|
precision ${i.precision} usampler2DArray;
|
|
4603
|
-
`;return i.precision==="highp"?
|
|
4604
|
-
#define HIGH_PRECISION`:i.precision==="mediump"?
|
|
4605
|
-
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(
|
|
4606
|
-
#define LOW_PRECISION`),
|
|
4607
|
-
`:"";
|
|
4603
|
+
`;return i.precision==="highp"?t+=`
|
|
4604
|
+
#define HIGH_PRECISION`:i.precision==="mediump"?t+=`
|
|
4605
|
+
#define MEDIUM_PRECISION`:i.precision==="lowp"&&(t+=`
|
|
4606
|
+
#define LOW_PRECISION`),t}const q2={[gr]:"SHADOWMAP_TYPE_PCF",[lr]:"SHADOWMAP_TYPE_VSM"};function Y2(i){return q2[i.shadowMapType]||"SHADOWMAP_TYPE_BASIC"}const K2={[Zi]:"ENVMAP_TYPE_CUBE",[Gs]:"ENVMAP_TYPE_CUBE",[to]:"ENVMAP_TYPE_CUBE_UV"};function Z2(i){return i.envMap===!1?"ENVMAP_TYPE_CUBE":K2[i.envMapMode]||"ENVMAP_TYPE_CUBE"}const $2={[Gs]:"ENVMAP_MODE_REFRACTION"};function J2(i){return i.envMap===!1?"ENVMAP_MODE_REFLECTION":$2[i.envMapMode]||"ENVMAP_MODE_REFLECTION"}const Q2={[kl]:"ENVMAP_BLENDING_MULTIPLY",[Fp]:"ENVMAP_BLENDING_MIX",[Op]:"ENVMAP_BLENDING_ADD"};function j2(i){return i.envMap===!1?"ENVMAP_BLENDING_NONE":Q2[i.combine]||"ENVMAP_BLENDING_NONE"}function t_(i){const t=i.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 e_(i,t,e,n){const s=i.getContext(),r=e.defines;let a=e.vertexShader,o=e.fragmentShader;const c=Y2(e),l=Z2(e),h=J2(e),u=j2(e),d=t_(e),f=z2(e),g=B2(r),x=s.createProgram();let m,p,w=e.glslVersion?"#version "+e.glslVersion+`
|
|
4607
|
+
`:"";e.isRawShaderMaterial?(m=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ur).join(`
|
|
4608
4608
|
`),m.length>0&&(m+=`
|
|
4609
|
-
`),
|
|
4610
|
-
`),
|
|
4611
|
-
`)):(m=[
|
|
4612
|
-
`].filter(
|
|
4613
|
-
`),
|
|
4614
|
-
`].filter(
|
|
4615
|
-
`)),a=
|
|
4616
|
-
`,m=[
|
|
4609
|
+
`),p=["#define SHADER_TYPE "+e.shaderType,"#define SHADER_NAME "+e.shaderName,g].filter(ur).join(`
|
|
4610
|
+
`),p.length>0&&(p+=`
|
|
4611
|
+
`)):(m=[Du(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",`
|
|
4612
|
+
`].filter(ur).join(`
|
|
4613
|
+
`),p=[Du(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!==qn?"#define TONE_MAPPING":"",e.toneMapping!==qn?Vt.tonemapping_pars_fragment:"",e.toneMapping!==qn?F2("toneMapping",e.toneMapping):"",e.dithering?"#define DITHERING":"",e.opaque?"#define OPAQUE":"",Vt.colorspace_pars_fragment,N2("linearToOutputTexel",e.outputColorSpace),O2(),e.useDepthPacking?"#define DEPTH_PACKING "+e.depthPacking:"",`
|
|
4614
|
+
`].filter(ur).join(`
|
|
4615
|
+
`)),a=ul(a),a=Tu(a,e),a=Ru(a,e),o=ul(o),o=Tu(o,e),o=Ru(o,e),a=Cu(a),o=Cu(o),e.isRawShaderMaterial!==!0&&(w=`#version 300 es
|
|
4616
|
+
`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(`
|
|
4617
4617
|
`)+`
|
|
4618
|
-
`+m,
|
|
4618
|
+
`+m,p=["#define varying in",e.glslVersion===zh?"":"layout(location = 0) out highp vec4 pc_fragColor;",e.glslVersion===zh?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(`
|
|
4619
4619
|
`)+`
|
|
4620
|
-
`+
|
|
4620
|
+
`+p);const A=w+m+a,M=w+p+o,S=bu(s,s.VERTEX_SHADER,A),b=bu(s,s.FRAGMENT_SHADER,M);s.attachShader(x,S),s.attachShader(x,b),e.index0AttributeName!==void 0?s.bindAttribLocation(x,0,e.index0AttributeName):e.hasPositionAttribute===!0&&s.bindAttribLocation(x,0,"position"),s.linkProgram(x);function R(C){if(i.debug.checkShaderErrors){const I=s.getProgramInfoLog(x)||"",W=s.getShaderInfoLog(S)||"",X=s.getShaderInfoLog(b)||"",U=I.trim(),q=W.trim(),H=X.trim();let $=!0,et=!0;if(s.getProgramParameter(x,s.LINK_STATUS)===!1)if($=!1,typeof i.debug.onShaderError=="function")i.debug.onShaderError(s,x,S,b);else{const j=Au(s,S,"vertex"),it=Au(s,b,"fragment");Yt("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(x,s.VALIDATE_STATUS)+`
|
|
4621
4621
|
|
|
4622
4622
|
Material Name: `+C.name+`
|
|
4623
4623
|
Material Type: `+C.type+`
|
|
4624
4624
|
|
|
4625
|
-
Program Info Log: `+
|
|
4626
|
-
`+
|
|
4627
|
-
`+se)}else F!==""?Oe("WebGLProgram: Program Info Log:",F):(W===""||V==="")&&(te=!1);te&&(C.diagnostics={runnable:Q,programLog:F,vertexShader:{log:W,prefix:m},fragmentShader:{log:V,prefix:f}})}s.deleteShader(S),s.deleteShader(b),_=new Ma(s,x),E=y_(s,x)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let D=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(x,u_)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=d_++,this.cacheKey=e,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=b,this}let O_=0;class z_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,n){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(n)===!1&&(s.add(n),n.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const n of t)n.usedTimes--,n.usedTimes===0&&this.shaderCache.delete(n.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let n=t.get(e);return n===void 0&&(n=new Set,t.set(e,n)),n}_getShaderStage(e){const t=this.shaderCache;let n=t.get(e);return n===void 0&&(n=new B_(e),t.set(e,n)),n}}class B_{constructor(e){this.id=O_++,this.code=e,this.usedTimes=0}}function k_(i){return i===Gi||i===ba||i===wa}function G_(i,e,t,n,s,r){const a=new Fc,o=new z_,l=new Set,c=[],h=new Map,u=n.logarithmicDepthBuffer;let d=n.precision;const p={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 l.add(_),_===0?"uv":`uv${_}`}function x(_,E,D,C,L,X){const q=C.fog,F=L.geometry,W=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,V=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,Q=e.get(_.envMap||W,V),te=Q&&Q.mapping===Ga?Q.image.height:null,ee=p[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&Oe("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const se=F.morphAttributes.position||F.morphAttributes.normal||F.morphAttributes.color,ge=se!==void 0?se.length:0;let Ve=0;F.morphAttributes.position!==void 0&&(Ve=1),F.morphAttributes.normal!==void 0&&(Ve=2),F.morphAttributes.color!==void 0&&(Ve=3);let at,We,Z,re;if(ee){const ye=Tn[ee];at=ye.vertexShader,We=ye.fragmentShader}else{at=_.vertexShader,We=_.fragmentShader;const ye=o.getVertexShaderStage(_),gt=o.getFragmentShaderStage(_);o.update(_,ye,gt),Z=ye.id,re=gt.id}const ne=i.getRenderTarget(),k=i.state.buffers.depth.getReversed(),De=L.isInstancedMesh===!0,Pe=L.isBatchedMesh===!0,Re=!!_.map,Me=!!_.matcap,Ue=!!Q,Ie=!!_.aoMap,Le=!!_.lightMap,$e=!!_.bumpMap&&_.wireframe===!1,Je=!!_.normalMap,pt=!!_.displacementMap,dt=!!_.emissiveMap,mt=!!_.metalnessMap,St=!!_.roughnessMap,I=_.anisotropy>0,Kt=_.clearcoat>0,Qe=_.dispersion>0,A=_.iridescence>0,v=_.sheen>0,O=_.transmission>0,G=I&&!!_.anisotropyMap,Y=Kt&&!!_.clearcoatMap,ie=Kt&&!!_.clearcoatNormalMap,oe=Kt&&!!_.clearcoatRoughnessMap,K=A&&!!_.iridescenceMap,J=A&&!!_.iridescenceThicknessMap,le=v&&!!_.sheenColorMap,we=v&&!!_.sheenRoughnessMap,ue=!!_.specularMap,ce=!!_.specularColorMap,Ce=!!_.specularIntensityMap,Ne=O&&!!_.transmissionMap,Be=O&&!!_.thicknessMap,P=!!_.gradientMap,ae=!!_.alphaMap,$=_.alphaTest>0,he=!!_.alphaHash,me=!!_.extensions;let j=Fn;_.toneMapped&&(ne===null||ne.isXRRenderTarget===!0)&&(j=i.toneMapping);const be={shaderID:ee,shaderType:_.type,shaderName:_.name,vertexShader:at,fragmentShader:We,defines:_.defines,customVertexShaderID:Z,customFragmentShaderID:re,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:Pe,batchingColor:Pe&&L._colorsTexture!==null,instancing:De,instancingColor:De&&L.instanceColor!==null,instancingMorph:De&&L.morphTexture!==null,outputColorSpace:ne===null?i.outputColorSpace:ne.isXRRenderTarget===!0?ne.texture.colorSpace:Ye.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:Re,matcap:Me,envMap:Ue,envMapMode:Ue&&Q.mapping,envMapCubeUVHeight:te,aoMap:Ie,lightMap:Le,bumpMap:$e,normalMap:Je,displacementMap:pt,emissiveMap:dt,normalMapObjectSpace:Je&&_.normalMapType===Ep,normalMapTangentSpace:Je&&_.normalMapType===ql,packedNormalMap:Je&&_.normalMapType===ql&&k_(_.normalMap.format),metalnessMap:mt,roughnessMap:St,anisotropy:I,anisotropyMap:G,clearcoat:Kt,clearcoatMap:Y,clearcoatNormalMap:ie,clearcoatRoughnessMap:oe,dispersion:Qe,iridescence:A,iridescenceMap:K,iridescenceThicknessMap:J,sheen:v,sheenColorMap:le,sheenRoughnessMap:we,specularMap:ue,specularColorMap:ce,specularIntensityMap:Ce,transmission:O,transmissionMap:Ne,thicknessMap:Be,gradientMap:P,opaque:_.transparent===!1&&_.blending===bs&&_.alphaToCoverage===!1,alphaMap:ae,alphaTest:$,alphaHash:he,combine:_.combine,mapUv:Re&&g(_.map.channel),aoMapUv:Ie&&g(_.aoMap.channel),lightMapUv:Le&&g(_.lightMap.channel),bumpMapUv:$e&&g(_.bumpMap.channel),normalMapUv:Je&&g(_.normalMap.channel),displacementMapUv:pt&&g(_.displacementMap.channel),emissiveMapUv:dt&&g(_.emissiveMap.channel),metalnessMapUv:mt&&g(_.metalnessMap.channel),roughnessMapUv:St&&g(_.roughnessMap.channel),anisotropyMapUv:G&&g(_.anisotropyMap.channel),clearcoatMapUv:Y&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:ie&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:oe&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:K&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:J&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:le&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:we&&g(_.sheenRoughnessMap.channel),specularMapUv:ue&&g(_.specularMap.channel),specularColorMapUv:ce&&g(_.specularColorMap.channel),specularIntensityMapUv:Ce&&g(_.specularIntensityMap.channel),transmissionMapUv:Ne&&g(_.transmissionMap.channel),thicknessMapUv:Be&&g(_.thicknessMap.channel),alphaMapUv:ae&&g(_.alphaMap.channel),vertexTangents:!!F.attributes.tangent&&(Je||I),vertexNormals:!!F.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!F.attributes.color&&F.attributes.color.itemSize===4,pointsUvs:L.isPoints===!0&&!!F.attributes.uv&&(Re||ae),fog:!!q,useFog:_.fog===!0,fogExp2:!!q&&q.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||F.attributes.normal===void 0&&Je===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:k,skinning:L.isSkinnedMesh===!0,hasPositionAttribute:F.attributes.position!==void 0,morphTargets:F.morphAttributes.position!==void 0,morphNormals:F.morphAttributes.normal!==void 0,morphColors:F.morphAttributes.color!==void 0,morphTargetsCount:ge,morphTextureStride:Ve,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:X.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:j,decodeVideoTexture:Re&&_.map.isVideoTexture===!0&&Ye.getTransfer(_.map.colorSpace)===je,decodeVideoTextureEmissive:dt&&_.emissiveMap.isVideoTexture===!0&&Ye.getTransfer(_.emissiveMap.colorSpace)===je,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===vn,flipSided:_.side===Nt,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:me&&_.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(me&&_.extensions.multiDraw===!0||Pe)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return be.vertexUv1s=l.has(1),be.vertexUv2s=l.has(2),be.vertexUv3s=l.has(3),l.clear(),be}function m(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const D in _.defines)E.push(D),E.push(_.defines[D]);return _.isRawShaderMaterial===!1&&(f(E,_),w(E,_),E.push(i.outputColorSpace)),E.push(_.customProgramCacheKey),E.join()}function f(_,E){_.push(E.precision),_.push(E.outputColorSpace),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.mapUv),_.push(E.alphaMapUv),_.push(E.lightMapUv),_.push(E.aoMapUv),_.push(E.bumpMapUv),_.push(E.normalMapUv),_.push(E.displacementMapUv),_.push(E.emissiveMapUv),_.push(E.metalnessMapUv),_.push(E.roughnessMapUv),_.push(E.anisotropyMapUv),_.push(E.clearcoatMapUv),_.push(E.clearcoatNormalMapUv),_.push(E.clearcoatRoughnessMapUv),_.push(E.iridescenceMapUv),_.push(E.iridescenceThicknessMapUv),_.push(E.sheenColorMapUv),_.push(E.sheenRoughnessMapUv),_.push(E.specularMapUv),_.push(E.specularColorMapUv),_.push(E.specularIntensityMapUv),_.push(E.transmissionMapUv),_.push(E.thicknessMapUv),_.push(E.combine),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numSpotLightMaps),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.numSpotLightShadowsWithMaps),_.push(E.numLightProbes),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function w(_,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),E.packedNormalMap&&a.enable(22),E.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),E.numLightProbeGrids>0&&a.enable(22),E.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function T(_){const E=p[_.type];let D;if(E){const C=Tn[E];D=am.clone(C.uniforms)}else D=_.uniforms;return D}function M(_,E){let D=h.get(E);return D!==void 0?++D.usedTimes:(D=new F_(i,E,_,s),c.push(D),h.set(E,D)),D}function S(_){if(--_.usedTimes===0){const E=c.indexOf(_);c[E]=c[c.length-1],c.pop(),h.delete(_.cacheKey),_.destroy()}}function b(_){o.remove(_)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:T,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:c,dispose:R}}function H_(){let i=new WeakMap;function e(a){return i.has(a)}function t(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,l){i.get(a)[o]=l}function r(){i=new WeakMap}return{has:e,get:t,remove:n,update:s,dispose:r}}function V_(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.material.id!==e.material.id?i.material.id-e.material.id:i.materialVariant!==e.materialVariant?i.materialVariant-e.materialVariant:i.z!==e.z?i.z-e.z:i.id-e.id}function vu(i,e){return i.groupOrder!==e.groupOrder?i.groupOrder-e.groupOrder:i.renderOrder!==e.renderOrder?i.renderOrder-e.renderOrder:i.z!==e.z?e.z-i.z:i.id-e.id}function _u(){const i=[];let e=0;const t=[],n=[],s=[];function r(){e=0,t.length=0,n.length=0,s.length=0}function a(d){let p=0;return d.isInstancedMesh&&(p+=2),d.isSkinnedMesh&&(p+=1),p}function o(d,p,g,x,m,f){let w=i[e];return w===void 0?(w={id:d.id,object:d,geometry:p,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:f},i[e]=w):(w.id=d.id,w.object=d,w.geometry=p,w.material=g,w.materialVariant=a(d),w.groupOrder=x,w.renderOrder=d.renderOrder,w.z=m,w.group=f),e++,w}function l(d,p,g,x,m,f){const w=o(d,p,g,x,m,f);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):t.push(w)}function c(d,p,g,x,m,f){const w=o(d,p,g,x,m,f);g.transmission>0?n.unshift(w):g.transparent===!0?s.unshift(w):t.unshift(w)}function h(d,p,g){t.length>1&&t.sort(d||V_),n.length>1&&n.sort(p||vu),s.length>1&&s.sort(p||vu),g&&(t.reverse(),n.reverse(),s.reverse())}function u(){for(let d=e,p=i.length;d<p;d++){const g=i[d];if(g.id===null)break;g.id=null,g.object=null,g.geometry=null,g.material=null,g.group=null}}return{opaque:t,transmissive:n,transparent:s,init:r,push:l,unshift:c,finish:u,sort:h}}function W_(){let i=new WeakMap;function e(n,s){const r=i.get(n);let a;return r===void 0?(a=new _u,i.set(n,[a])):s>=r.length?(a=new _u,r.push(a)):a=r[s],a}function t(){i=new WeakMap}return{get:e,dispose:t}}function X_(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new U,color:new xe};break;case"SpotLight":t={position:new U,direction:new U,color:new xe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new U,color:new xe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new U,skyColor:new xe,groundColor:new xe};break;case"RectAreaLight":t={color:new xe,position:new U,halfWidth:new U,halfHeight:new U};break}return i[e.id]=t,t}}}function q_(){const i={};return{get:function(e){if(i[e.id]!==void 0)return i[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Fe,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[e.id]=t,t}}}let Y_=0;function K_(i,e){return(e.castShadow?2:0)-(i.castShadow?2:0)+(e.map?1:0)-(i.map?1:0)}function Z_(i){const e=new X_,t=q_(),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 c=0;c<9;c++)n.probe.push(new U);const s=new U,r=new ht,a=new ht;function o(c){let h=0,u=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let p=0,g=0,x=0,m=0,f=0,w=0,T=0,M=0,S=0,b=0,R=0;c.sort(K_);for(let E=0,D=c.length;E<D;E++){const C=c[E],L=C.color,X=C.intensity,q=C.distance;let F=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===Gi?F=C.shadow.map.texture:F=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=L.r*X,u+=L.g*X,d+=L.b*X;else if(C.isLightProbe){for(let W=0;W<9;W++)n.probe[W].addScaledVector(C.sh.coefficients[W],X);R++}else if(C.isDirectionalLight){const W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const V=C.shadow,Q=t.get(C);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,n.directionalShadow[p]=Q,n.directionalShadowMap[p]=F,n.directionalShadowMatrix[p]=C.shadow.matrix,w++}n.directional[p]=W,p++}else if(C.isSpotLight){const W=e.get(C);W.position.setFromMatrixPosition(C.matrixWorld),W.color.copy(L).multiplyScalar(X),W.distance=q,W.coneCos=Math.cos(C.angle),W.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),W.decay=C.decay,n.spot[x]=W;const V=C.shadow;if(C.map&&(n.spotLightMap[S]=C.map,S++,V.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[x]=V.matrix,C.castShadow){const Q=t.get(C);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,n.spotShadow[x]=Q,n.spotShadowMap[x]=F,M++}x++}else if(C.isRectAreaLight){const W=e.get(C);W.color.copy(L).multiplyScalar(X),W.halfWidth.set(C.width*.5,0,0),W.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=W,m++}else if(C.isPointLight){const W=e.get(C);if(W.color.copy(C.color).multiplyScalar(C.intensity),W.distance=C.distance,W.decay=C.decay,C.castShadow){const V=C.shadow,Q=t.get(C);Q.shadowIntensity=V.intensity,Q.shadowBias=V.bias,Q.shadowNormalBias=V.normalBias,Q.shadowRadius=V.radius,Q.shadowMapSize=V.mapSize,Q.shadowCameraNear=V.camera.near,Q.shadowCameraFar=V.camera.far,n.pointShadow[g]=Q,n.pointShadowMap[g]=F,n.pointShadowMatrix[g]=C.shadow.matrix,T++}n.point[g]=W,g++}else if(C.isHemisphereLight){const W=e.get(C);W.skyColor.copy(C.color).multiplyScalar(X),W.groundColor.copy(C.groundColor).multiplyScalar(X),n.hemi[f]=W,f++}}m>0&&(i.has("OES_texture_float_linear")===!0?(n.rectAreaLTC1=de.LTC_FLOAT_1,n.rectAreaLTC2=de.LTC_FLOAT_2):(n.rectAreaLTC1=de.LTC_HALF_1,n.rectAreaLTC2=de.LTC_HALF_2)),n.ambient[0]=h,n.ambient[1]=u,n.ambient[2]=d;const _=n.hash;(_.directionalLength!==p||_.pointLength!==g||_.spotLength!==x||_.rectAreaLength!==m||_.hemiLength!==f||_.numDirectionalShadows!==w||_.numPointShadows!==T||_.numSpotShadows!==M||_.numSpotMaps!==S||_.numLightProbes!==R)&&(n.directional.length=p,n.spot.length=x,n.rectArea.length=m,n.point.length=g,n.hemi.length=f,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=T,n.pointShadowMap.length=T,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=T,n.spotLightMatrix.length=M+S-b,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,_.directionalLength=p,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=f,_.numDirectionalShadows=w,_.numPointShadows=T,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=Y_++)}function l(c,h){let u=0,d=0,p=0,g=0,x=0;const m=h.matrixWorldInverse;for(let f=0,w=c.length;f<w;f++){const T=c[f];if(T.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(T.isSpotLight){const M=n.spot[p];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(T.matrixWorld),s.setFromMatrixPosition(T.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),p++}else if(T.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(T.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(T.width*.5,0,0),M.halfHeight.set(0,T.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(T.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(T.matrixWorld),M.position.applyMatrix4(m),d++}else if(T.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(T.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:l,state:n}}function xu(i){const e=new Z_(i),t=[],n=[],s=[];function r(d){u.camera=d,t.length=0,n.length=0,s.length=0}function a(d){t.push(d)}function o(d){n.push(d)}function l(d){s.push(d)}function c(){e.setup(t)}function h(d){e.setupView(t,d)}const u={lightsArray:t,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:e,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:c,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:l}}function $_(i){let e=new WeakMap;function t(s,r=0){const a=e.get(s);let o;return a===void 0?(o=new xu(i),e.set(s,[o])):r>=a.length?(o=new xu(i),a.push(o)):o=a[r],o}function n(){e=new WeakMap}return{get:t,dispose:n}}const J_=`void main() {
|
|
4625
|
+
Program Info Log: `+U+`
|
|
4626
|
+
`+j+`
|
|
4627
|
+
`+it)}else U!==""?Ot("WebGLProgram: Program Info Log:",U):(q===""||H==="")&&(et=!1);et&&(C.diagnostics={runnable:$,programLog:U,vertexShader:{log:q,prefix:m},fragmentShader:{log:H,prefix:p}})}s.deleteShader(S),s.deleteShader(b),_=new Ia(s,x),E=k2(s,x)}let _;this.getUniforms=function(){return _===void 0&&R(this),_};let E;this.getAttributes=function(){return E===void 0&&R(this),E};let D=e.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return D===!1&&(D=s.getProgramParameter(x,D2)),D},this.destroy=function(){n.releaseStatesOfProgram(this),s.deleteProgram(x),this.program=void 0},this.type=e.shaderType,this.name=e.shaderName,this.id=P2++,this.cacheKey=t,this.usedTimes=1,this.program=x,this.vertexShader=S,this.fragmentShader=b,this}let n_=0;class i_{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(t,e,n){const s=this._getShaderCacheForMaterial(t);return s.has(e)===!1&&(s.add(e),e.usedTimes++),s.has(n)===!1&&(s.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 s_(t),e.set(t,n)),n}}class s_{constructor(t){this.id=n_++,this.code=t,this.usedTimes=0}}function r_(i){return i===$i||i===Fa||i===Oa}function a_(i,t,e,n,s,r){const a=new $l,o=new i_,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 x(_,E,D,C,I,W){const X=C.fog,U=I.geometry,q=_.isMeshStandardMaterial||_.isMeshLambertMaterial||_.isMeshPhongMaterial?C.environment:null,H=_.isMeshStandardMaterial||_.isMeshLambertMaterial&&!_.envMap||_.isMeshPhongMaterial&&!_.envMap,$=t.get(_.envMap||q,H),et=$&&$.mapping===to?$.image.height:null,j=f[_.type];_.precision!==null&&(d=n.getMaxPrecision(_.precision),d!==_.precision&&Ot("WebGLProgram.getParameters:",_.precision,"not supported, using",d,"instead."));const it=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,ut=it!==void 0?it.length:0;let kt=0;U.morphAttributes.position!==void 0&&(kt=1),U.morphAttributes.normal!==void 0&&(kt=2),U.morphAttributes.color!==void 0&&(kt=3);let qt,Bt,Y,rt;if(j){const yt=On[j];qt=yt.vertexShader,Bt=yt.fragmentShader}else{qt=_.vertexShader,Bt=_.fragmentShader;const yt=o.getVertexShaderStage(_),ve=o.getFragmentShaderStage(_);o.update(_,yt,ve),Y=yt.id,rt=ve.id}const nt=i.getRenderTarget(),z=i.state.buffers.depth.getReversed(),bt=I.isInstancedMesh===!0,Dt=I.isBatchedMesh===!0,At=!!_.map,_t=!!_.matcap,It=!!$,Lt=!!_.aoMap,Nt=!!_.lightMap,Jt=!!_.bumpMap&&_.wireframe===!1,Qt=!!_.normalMap,me=!!_.displacementMap,de=!!_.emissiveMap,ge=!!_.metalnessMap,be=!!_.roughnessMap,L=_.anisotropy>0,Je=_.clearcoat>0,jt=_.dispersion>0,T=_.iridescence>0,v=_.sheen>0,O=_.transmission>0,G=L&&!!_.anisotropyMap,K=Je&&!!_.clearcoatMap,st=Je&&!!_.clearcoatNormalMap,ot=Je&&!!_.clearcoatRoughnessMap,Z=T&&!!_.iridescenceMap,Q=T&&!!_.iridescenceThicknessMap,ct=v&&!!_.sheenColorMap,Tt=v&&!!_.sheenRoughnessMap,dt=!!_.specularMap,lt=!!_.specularColorMap,Pt=!!_.specularIntensityMap,Ut=O&&!!_.transmissionMap,Gt=O&&!!_.thicknessMap,P=!!_.gradientMap,at=!!_.alphaMap,J=_.alphaTest>0,ht=!!_.alphaHash,gt=!!_.extensions;let tt=qn;_.toneMapped&&(nt===null||nt.isXRRenderTarget===!0)&&(tt=i.toneMapping);const wt={shaderID:j,shaderType:_.type,shaderName:_.name,vertexShader:qt,fragmentShader:Bt,defines:_.defines,customVertexShaderID:Y,customFragmentShaderID:rt,isRawShaderMaterial:_.isRawShaderMaterial===!0,glslVersion:_.glslVersion,precision:d,batching:Dt,batchingColor:Dt&&I._colorsTexture!==null,instancing:bt,instancingColor:bt&&I.instanceColor!==null,instancingMorph:bt&&I.morphTexture!==null,outputColorSpace:nt===null?i.outputColorSpace:nt.isXRRenderTarget===!0?nt.texture.colorSpace:Kt.workingColorSpace,alphaToCoverage:!!_.alphaToCoverage,map:At,matcap:_t,envMap:It,envMapMode:It&&$.mapping,envMapCubeUVHeight:et,aoMap:Lt,lightMap:Nt,bumpMap:Jt,normalMap:Qt,displacementMap:me,emissiveMap:de,normalMapObjectSpace:Qt&&_.normalMapType===kp,normalMapTangentSpace:Qt&&_.normalMapType===rl,packedNormalMap:Qt&&_.normalMapType===rl&&r_(_.normalMap.format),metalnessMap:ge,roughnessMap:be,anisotropy:L,anisotropyMap:G,clearcoat:Je,clearcoatMap:K,clearcoatNormalMap:st,clearcoatRoughnessMap:ot,dispersion:jt,iridescence:T,iridescenceMap:Z,iridescenceThicknessMap:Q,sheen:v,sheenColorMap:ct,sheenRoughnessMap:Tt,specularMap:dt,specularColorMap:lt,specularIntensityMap:Pt,transmission:O,transmissionMap:Ut,thicknessMap:Gt,gradientMap:P,opaque:_.transparent===!1&&_.blending===Is&&_.alphaToCoverage===!1,alphaMap:at,alphaTest:J,alphaHash:ht,combine:_.combine,mapUv:At&&g(_.map.channel),aoMapUv:Lt&&g(_.aoMap.channel),lightMapUv:Nt&&g(_.lightMap.channel),bumpMapUv:Jt&&g(_.bumpMap.channel),normalMapUv:Qt&&g(_.normalMap.channel),displacementMapUv:me&&g(_.displacementMap.channel),emissiveMapUv:de&&g(_.emissiveMap.channel),metalnessMapUv:ge&&g(_.metalnessMap.channel),roughnessMapUv:be&&g(_.roughnessMap.channel),anisotropyMapUv:G&&g(_.anisotropyMap.channel),clearcoatMapUv:K&&g(_.clearcoatMap.channel),clearcoatNormalMapUv:st&&g(_.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ot&&g(_.clearcoatRoughnessMap.channel),iridescenceMapUv:Z&&g(_.iridescenceMap.channel),iridescenceThicknessMapUv:Q&&g(_.iridescenceThicknessMap.channel),sheenColorMapUv:ct&&g(_.sheenColorMap.channel),sheenRoughnessMapUv:Tt&&g(_.sheenRoughnessMap.channel),specularMapUv:dt&&g(_.specularMap.channel),specularColorMapUv:lt&&g(_.specularColorMap.channel),specularIntensityMapUv:Pt&&g(_.specularIntensityMap.channel),transmissionMapUv:Ut&&g(_.transmissionMap.channel),thicknessMapUv:Gt&&g(_.thicknessMap.channel),alphaMapUv:at&&g(_.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(Qt||L),vertexNormals:!!U.attributes.normal,vertexColors:_.vertexColors,vertexAlphas:_.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:I.isPoints===!0&&!!U.attributes.uv&&(At||at),fog:!!X,useFog:_.fog===!0,fogExp2:!!X&&X.isFogExp2,flatShading:_.wireframe===!1&&(_.flatShading===!0||U.attributes.normal===void 0&&Qt===!1&&(_.isMeshLambertMaterial||_.isMeshPhongMaterial||_.isMeshStandardMaterial||_.isMeshPhysicalMaterial)),sizeAttenuation:_.sizeAttenuation===!0,logarithmicDepthBuffer:u,reversedDepthBuffer:z,skinning:I.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:ut,morphTextureStride:kt,numDirLights:E.directional.length,numPointLights:E.point.length,numSpotLights:E.spot.length,numSpotLightMaps:E.spotLightMap.length,numRectAreaLights:E.rectArea.length,numHemiLights:E.hemi.length,numDirLightShadows:E.directionalShadowMap.length,numPointLightShadows:E.pointShadowMap.length,numSpotLightShadows:E.spotShadowMap.length,numSpotLightShadowsWithMaps:E.numSpotLightShadowsWithMaps,numLightProbes:E.numLightProbes,numLightProbeGrids:W.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:_.dithering,shadowMapEnabled:i.shadowMap.enabled&&D.length>0,shadowMapType:i.shadowMap.type,toneMapping:tt,decodeVideoTexture:At&&_.map.isVideoTexture===!0&&Kt.getTransfer(_.map.colorSpace)===te,decodeVideoTextureEmissive:de&&_.emissiveMap.isVideoTexture===!0&&Kt.getTransfer(_.emissiveMap.colorSpace)===te,premultipliedAlpha:_.premultipliedAlpha,doubleSided:_.side===wn,flipSided:_.side===Ce,useDepthPacking:_.depthPacking>=0,depthPacking:_.depthPacking||0,index0AttributeName:_.index0AttributeName,extensionClipCullDistance:gt&&_.extensions.clipCullDistance===!0&&e.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(gt&&_.extensions.multiDraw===!0||Dt)&&e.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:e.has("KHR_parallel_shader_compile"),customProgramCacheKey:_.customProgramCacheKey()};return wt.vertexUv1s=c.has(1),wt.vertexUv2s=c.has(2),wt.vertexUv3s=c.has(3),c.clear(),wt}function m(_){const E=[];if(_.shaderID?E.push(_.shaderID):(E.push(_.customVertexShaderID),E.push(_.customFragmentShaderID)),_.defines!==void 0)for(const D in _.defines)E.push(D),E.push(_.defines[D]);return _.isRawShaderMaterial===!1&&(p(E,_),w(E,_),E.push(i.outputColorSpace)),E.push(_.customProgramCacheKey),E.join()}function p(_,E){_.push(E.precision),_.push(E.outputColorSpace),_.push(E.envMapMode),_.push(E.envMapCubeUVHeight),_.push(E.mapUv),_.push(E.alphaMapUv),_.push(E.lightMapUv),_.push(E.aoMapUv),_.push(E.bumpMapUv),_.push(E.normalMapUv),_.push(E.displacementMapUv),_.push(E.emissiveMapUv),_.push(E.metalnessMapUv),_.push(E.roughnessMapUv),_.push(E.anisotropyMapUv),_.push(E.clearcoatMapUv),_.push(E.clearcoatNormalMapUv),_.push(E.clearcoatRoughnessMapUv),_.push(E.iridescenceMapUv),_.push(E.iridescenceThicknessMapUv),_.push(E.sheenColorMapUv),_.push(E.sheenRoughnessMapUv),_.push(E.specularMapUv),_.push(E.specularColorMapUv),_.push(E.specularIntensityMapUv),_.push(E.transmissionMapUv),_.push(E.thicknessMapUv),_.push(E.combine),_.push(E.fogExp2),_.push(E.sizeAttenuation),_.push(E.morphTargetsCount),_.push(E.morphAttributeCount),_.push(E.numDirLights),_.push(E.numPointLights),_.push(E.numSpotLights),_.push(E.numSpotLightMaps),_.push(E.numHemiLights),_.push(E.numRectAreaLights),_.push(E.numDirLightShadows),_.push(E.numPointLightShadows),_.push(E.numSpotLightShadows),_.push(E.numSpotLightShadowsWithMaps),_.push(E.numLightProbes),_.push(E.shadowMapType),_.push(E.toneMapping),_.push(E.numClippingPlanes),_.push(E.numClipIntersection),_.push(E.depthPacking)}function w(_,E){a.disableAll(),E.instancing&&a.enable(0),E.instancingColor&&a.enable(1),E.instancingMorph&&a.enable(2),E.matcap&&a.enable(3),E.envMap&&a.enable(4),E.normalMapObjectSpace&&a.enable(5),E.normalMapTangentSpace&&a.enable(6),E.clearcoat&&a.enable(7),E.iridescence&&a.enable(8),E.alphaTest&&a.enable(9),E.vertexColors&&a.enable(10),E.vertexAlphas&&a.enable(11),E.vertexUv1s&&a.enable(12),E.vertexUv2s&&a.enable(13),E.vertexUv3s&&a.enable(14),E.vertexTangents&&a.enable(15),E.anisotropy&&a.enable(16),E.alphaHash&&a.enable(17),E.batching&&a.enable(18),E.dispersion&&a.enable(19),E.batchingColor&&a.enable(20),E.gradientMap&&a.enable(21),E.packedNormalMap&&a.enable(22),E.vertexNormals&&a.enable(23),_.push(a.mask),a.disableAll(),E.fog&&a.enable(0),E.useFog&&a.enable(1),E.flatShading&&a.enable(2),E.logarithmicDepthBuffer&&a.enable(3),E.reversedDepthBuffer&&a.enable(4),E.skinning&&a.enable(5),E.morphTargets&&a.enable(6),E.morphNormals&&a.enable(7),E.morphColors&&a.enable(8),E.premultipliedAlpha&&a.enable(9),E.shadowMapEnabled&&a.enable(10),E.doubleSided&&a.enable(11),E.flipSided&&a.enable(12),E.useDepthPacking&&a.enable(13),E.dithering&&a.enable(14),E.transmission&&a.enable(15),E.sheen&&a.enable(16),E.opaque&&a.enable(17),E.pointsUvs&&a.enable(18),E.decodeVideoTexture&&a.enable(19),E.decodeVideoTextureEmissive&&a.enable(20),E.alphaToCoverage&&a.enable(21),E.numLightProbeGrids>0&&a.enable(22),E.hasPositionAttribute&&a.enable(23),_.push(a.mask)}function A(_){const E=f[_.type];let D;if(E){const C=On[E];D=wm.clone(C.uniforms)}else D=_.uniforms;return D}function M(_,E){let D=h.get(E);return D!==void 0?++D.usedTimes:(D=new e_(i,E,_,s),l.push(D),h.set(E,D)),D}function S(_){if(--_.usedTimes===0){const E=l.indexOf(_);l[E]=l[l.length-1],l.pop(),h.delete(_.cacheKey),_.destroy()}}function b(_){o.remove(_)}function R(){o.dispose()}return{getParameters:x,getProgramCacheKey:m,getUniforms:A,acquireProgram:M,releaseProgram:S,releaseShaderCache:b,programs:l,dispose:R}}function o_(){let i=new WeakMap;function t(a){return i.has(a)}function e(a){let o=i.get(a);return o===void 0&&(o={},i.set(a,o)),o}function n(a){i.delete(a)}function s(a,o,c){i.get(a)[o]=c}function r(){i=new WeakMap}return{has:t,get:e,remove:n,update:s,dispose:r}}function c_(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.material.id!==t.material.id?i.material.id-t.material.id:i.materialVariant!==t.materialVariant?i.materialVariant-t.materialVariant:i.z!==t.z?i.z-t.z:i.id-t.id}function Pu(i,t){return i.groupOrder!==t.groupOrder?i.groupOrder-t.groupOrder:i.renderOrder!==t.renderOrder?i.renderOrder-t.renderOrder:i.z!==t.z?t.z-i.z:i.id-t.id}function Iu(){const i=[];let t=0;const e=[],n=[],s=[];function r(){t=0,e.length=0,n.length=0,s.length=0}function a(d){let f=0;return d.isInstancedMesh&&(f+=2),d.isSkinnedMesh&&(f+=1),f}function o(d,f,g,x,m,p){let w=i[t];return w===void 0?(w={id:d.id,object:d,geometry:f,material:g,materialVariant:a(d),groupOrder:x,renderOrder:d.renderOrder,z:m,group:p},i[t]=w):(w.id=d.id,w.object=d,w.geometry=f,w.material=g,w.materialVariant=a(d),w.groupOrder=x,w.renderOrder=d.renderOrder,w.z=m,w.group=p),t++,w}function c(d,f,g,x,m,p){const w=o(d,f,g,x,m,p);g.transmission>0?n.push(w):g.transparent===!0?s.push(w):e.push(w)}function l(d,f,g,x,m,p){const w=o(d,f,g,x,m,p);g.transmission>0?n.unshift(w):g.transparent===!0?s.unshift(w):e.unshift(w)}function h(d,f,g){e.length>1&&e.sort(d||c_),n.length>1&&n.sort(f||Pu),s.length>1&&s.sort(f||Pu),g&&(e.reverse(),n.reverse(),s.reverse())}function u(){for(let d=t,f=i.length;d<f;d++){const g=i[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:s,init:r,push:c,unshift:l,finish:u,sort:h}}function l_(){let i=new WeakMap;function t(n,s){const r=i.get(n);let a;return r===void 0?(a=new Iu,i.set(n,[a])):s>=r.length?(a=new Iu,r.push(a)):a=r[s],a}function e(){i=new WeakMap}return{get:t,dispose:e}}function h_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={direction:new F,color:new Mt};break;case"SpotLight":e={position:new F,direction:new F,color:new Mt,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":e={position:new F,color:new Mt,distance:0,decay:0};break;case"HemisphereLight":e={direction:new F,skyColor:new Mt,groundColor:new Mt};break;case"RectAreaLight":e={color:new Mt,position:new F,halfWidth:new F,halfHeight:new F};break}return i[t.id]=e,e}}}function u_(){const i={};return{get:function(t){if(i[t.id]!==void 0)return i[t.id];let e;switch(t.type){case"DirectionalLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"SpotLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft};break;case"PointLight":e={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ft,shadowCameraNear:1,shadowCameraFar:1e3};break}return i[t.id]=e,e}}}let d_=0;function f_(i,t){return(t.castShadow?2:0)-(i.castShadow?2:0)+(t.map?1:0)-(i.map?1:0)}function p_(i){const t=new h_,e=u_(),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 F);const s=new F,r=new he,a=new he;function o(l){let h=0,u=0,d=0;for(let E=0;E<9;E++)n.probe[E].set(0,0,0);let f=0,g=0,x=0,m=0,p=0,w=0,A=0,M=0,S=0,b=0,R=0;l.sort(f_);for(let E=0,D=l.length;E<D;E++){const C=l[E],I=C.color,W=C.intensity,X=C.distance;let U=null;if(C.shadow&&C.shadow.map&&(C.shadow.map.texture.format===$i?U=C.shadow.map.texture:U=C.shadow.map.depthTexture||C.shadow.map.texture),C.isAmbientLight)h+=I.r*W,u+=I.g*W,d+=I.b*W;else if(C.isLightProbe){for(let q=0;q<9;q++)n.probe[q].addScaledVector(C.sh.coefficients[q],W);R++}else if(C.isDirectionalLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.directionalShadow[f]=$,n.directionalShadowMap[f]=U,n.directionalShadowMatrix[f]=C.shadow.matrix,w++}n.directional[f]=q,f++}else if(C.isSpotLight){const q=t.get(C);q.position.setFromMatrixPosition(C.matrixWorld),q.color.copy(I).multiplyScalar(W),q.distance=X,q.coneCos=Math.cos(C.angle),q.penumbraCos=Math.cos(C.angle*(1-C.penumbra)),q.decay=C.decay,n.spot[x]=q;const H=C.shadow;if(C.map&&(n.spotLightMap[S]=C.map,S++,H.updateMatrices(C),C.castShadow&&b++),n.spotLightMatrix[x]=H.matrix,C.castShadow){const $=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,n.spotShadow[x]=$,n.spotShadowMap[x]=U,M++}x++}else if(C.isRectAreaLight){const q=t.get(C);q.color.copy(I).multiplyScalar(W),q.halfWidth.set(C.width*.5,0,0),q.halfHeight.set(0,C.height*.5,0),n.rectArea[m]=q,m++}else if(C.isPointLight){const q=t.get(C);if(q.color.copy(C.color).multiplyScalar(C.intensity),q.distance=C.distance,q.decay=C.decay,C.castShadow){const H=C.shadow,$=e.get(C);$.shadowIntensity=H.intensity,$.shadowBias=H.bias,$.shadowNormalBias=H.normalBias,$.shadowRadius=H.radius,$.shadowMapSize=H.mapSize,$.shadowCameraNear=H.camera.near,$.shadowCameraFar=H.camera.far,n.pointShadow[g]=$,n.pointShadowMap[g]=U,n.pointShadowMatrix[g]=C.shadow.matrix,A++}n.point[g]=q,g++}else if(C.isHemisphereLight){const q=t.get(C);q.skyColor.copy(C.color).multiplyScalar(W),q.groundColor.copy(C.groundColor).multiplyScalar(W),n.hemi[p]=q,p++}}m>0&&(i.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!==x||_.rectAreaLength!==m||_.hemiLength!==p||_.numDirectionalShadows!==w||_.numPointShadows!==A||_.numSpotShadows!==M||_.numSpotMaps!==S||_.numLightProbes!==R)&&(n.directional.length=f,n.spot.length=x,n.rectArea.length=m,n.point.length=g,n.hemi.length=p,n.directionalShadow.length=w,n.directionalShadowMap.length=w,n.pointShadow.length=A,n.pointShadowMap.length=A,n.spotShadow.length=M,n.spotShadowMap.length=M,n.directionalShadowMatrix.length=w,n.pointShadowMatrix.length=A,n.spotLightMatrix.length=M+S-b,n.spotLightMap.length=S,n.numSpotLightShadowsWithMaps=b,n.numLightProbes=R,_.directionalLength=f,_.pointLength=g,_.spotLength=x,_.rectAreaLength=m,_.hemiLength=p,_.numDirectionalShadows=w,_.numPointShadows=A,_.numSpotShadows=M,_.numSpotMaps=S,_.numLightProbes=R,n.version=d_++)}function c(l,h){let u=0,d=0,f=0,g=0,x=0;const m=h.matrixWorldInverse;for(let p=0,w=l.length;p<w;p++){const A=l[p];if(A.isDirectionalLight){const M=n.directional[u];M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),u++}else if(A.isSpotLight){const M=n.spot[f];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),M.direction.setFromMatrixPosition(A.matrixWorld),s.setFromMatrixPosition(A.target.matrixWorld),M.direction.sub(s),M.direction.transformDirection(m),f++}else if(A.isRectAreaLight){const M=n.rectArea[g];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),a.identity(),r.copy(A.matrixWorld),r.premultiply(m),a.extractRotation(r),M.halfWidth.set(A.width*.5,0,0),M.halfHeight.set(0,A.height*.5,0),M.halfWidth.applyMatrix4(a),M.halfHeight.applyMatrix4(a),g++}else if(A.isPointLight){const M=n.point[d];M.position.setFromMatrixPosition(A.matrixWorld),M.position.applyMatrix4(m),d++}else if(A.isHemisphereLight){const M=n.hemi[x];M.direction.setFromMatrixPosition(A.matrixWorld),M.direction.transformDirection(m),x++}}}return{setup:o,setupView:c,state:n}}function Lu(i){const t=new p_(i),e=[],n=[],s=[];function r(d){u.camera=d,e.length=0,n.length=0,s.length=0}function a(d){e.push(d)}function o(d){n.push(d)}function c(d){s.push(d)}function l(){t.setup(e)}function h(d){t.setupView(e,d)}const u={lightsArray:e,shadowsArray:n,lightProbeGridArray:s,camera:null,lights:t,transmissionRenderTarget:{},textureUnits:0};return{init:r,state:u,setupLights:l,setupLightsView:h,pushLight:a,pushShadow:o,pushLightProbeGrid:c}}function m_(i){let t=new WeakMap;function e(s,r=0){const a=t.get(s);let o;return a===void 0?(o=new Lu(i),t.set(s,[o])):r>=a.length?(o=new Lu(i),a.push(o)):o=a[r],o}function n(){t=new WeakMap}return{get:e,dispose:n}}const g_=`void main() {
|
|
4628
4628
|
gl_Position = vec4( position, 1.0 );
|
|
4629
|
-
}`,
|
|
4629
|
+
}`,v_=`uniform sampler2D shadow_pass;
|
|
4630
4630
|
uniform vec2 resolution;
|
|
4631
4631
|
uniform float radius;
|
|
4632
4632
|
void main() {
|
|
@@ -4651,12 +4651,12 @@ void main() {
|
|
|
4651
4651
|
squared_mean = squared_mean / samples;
|
|
4652
4652
|
float std_dev = sqrt( max( 0.0, squared_mean - mean * mean ) );
|
|
4653
4653
|
gl_FragColor = vec4( mean, std_dev, 0.0, 1.0 );
|
|
4654
|
-
}`,j_=[new U(1,0,0),new U(-1,0,0),new U(0,1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1)],e2=[new U(0,-1,0),new U(0,-1,0),new U(0,0,1),new U(0,0,-1),new U(0,-1,0),new U(0,-1,0)],Mu=new ht,Ks=new U,Uo=new U;function t2(i,e,t){let n=new Bc;const s=new Fe,r=new Fe,a=new ft,o=new hm,l=new um,c={},h=t.maxTextureSize,u={[_i]:Nt,[Nt]:_i,[vn]:vn},d=new Ft({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Fe},radius:{value:4}},vertexShader:J_,fragmentShader:Q_}),p=d.clone();p.defines.HORIZONTAL_PASS=1;const g=new yt;g.setAttribute("position",new ct(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new rt(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=ar;let f=this.type;this.render=function(b,R,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===ep&&(Oe("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=ar);const E=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),L=i.state;L.setBlending(Zn),L.buffers.depth.getReversed()===!0?L.buffers.color.setClear(0,0,0,0):L.buffers.color.setClear(1,1,1,1),L.buffers.depth.setTest(!0),L.setScissorTest(!1);const X=f!==this.type;X&&R.traverse(function(q){q.material&&(Array.isArray(q.material)?q.material.forEach(F=>F.needsUpdate=!0):q.material.needsUpdate=!0)});for(let q=0,F=b.length;q<F;q++){const W=b[q],V=W.shadow;if(V===void 0){Oe("WebGLShadowMap:",W,"has no shadow.");continue}if(V.autoUpdate===!1&&V.needsUpdate===!1)continue;s.copy(V.mapSize);const Q=V.getFrameExtents();s.multiply(Q),r.copy(V.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/Q.x),s.x=r.x*Q.x,V.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/Q.y),s.y=r.y*Q.y,V.mapSize.y=r.y));const te=i.state.buffers.depth.getReversed();if(V.camera._reversedDepth=te,V.map===null||X===!0){if(V.map!==null&&(V.map.depthTexture!==null&&(V.map.depthTexture.dispose(),V.map.depthTexture=null),V.map.dispose()),this.type===js){if(W.isPointLight){Oe("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}V.map=new Mn(s.x,s.y,{format:Gi,type:Jn,minFilter:Gt,magFilter:Gt,generateMipmaps:!1}),V.map.texture.name=W.name+".shadowMap",V.map.depthTexture=new Is(s.x,s.y,Ln),V.map.depthTexture.name=W.name+".shadowMapDepth",V.map.depthTexture.format=Qn,V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ut,V.map.depthTexture.magFilter=Ut}else W.isPointLight?(V.map=new i0(s.x),V.map.depthTexture=new sm(s.x,zn)):(V.map=new Mn(s.x,s.y),V.map.depthTexture=new Is(s.x,s.y,zn)),V.map.depthTexture.name=W.name+".shadowMap",V.map.depthTexture.format=Qn,this.type===ar?(V.map.depthTexture.compareFunction=te?Nc:Lc,V.map.depthTexture.minFilter=Gt,V.map.depthTexture.magFilter=Gt):(V.map.depthTexture.compareFunction=null,V.map.depthTexture.minFilter=Ut,V.map.depthTexture.magFilter=Ut);V.camera.updateProjectionMatrix()}const ee=V.map.isWebGLCubeRenderTarget?6:1;for(let se=0;se<ee;se++){if(V.map.isWebGLCubeRenderTarget)i.setRenderTarget(V.map,se),i.clear();else{se===0&&(i.setRenderTarget(V.map),i.clear());const ge=V.getViewport(se);a.set(r.x*ge.x,r.y*ge.y,r.x*ge.z,r.y*ge.w),L.viewport(a)}if(W.isPointLight){const ge=V.camera,Ve=V.matrix,at=W.distance||ge.far;at!==ge.far&&(ge.far=at,ge.updateProjectionMatrix()),Ks.setFromMatrixPosition(W.matrixWorld),ge.position.copy(Ks),Uo.copy(ge.position),Uo.add(j_[se]),ge.up.copy(e2[se]),ge.lookAt(Uo),ge.updateMatrixWorld(),Ve.makeTranslation(-Ks.x,-Ks.y,-Ks.z),Mu.multiplyMatrices(ge.projectionMatrix,ge.matrixWorldInverse),V._frustum.setFromProjectionMatrix(Mu,ge.coordinateSystem,ge.reversedDepth)}else V.updateMatrices(W);n=V.getFrustum(),M(R,_,V.camera,W,this.type)}V.isPointLightShadow!==!0&&this.type===js&&w(V,_),V.needsUpdate=!1}f=this.type,m.needsUpdate=!1,i.setRenderTarget(E,D,C)};function w(b,R){const _=e.update(x);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,p.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,p.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Mn(s.x,s.y,{format:Gi,type:Jn})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,_,d,x,null),p.uniforms.shadow_pass.value=b.mapPass.texture,p.uniforms.resolution.value=b.mapSize,p.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(R,null,_,p,x,null)}function T(b,R,_,E){let D=null;const C=_.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)D=C;else if(D=_.isPointLight===!0?l:o,i.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 L=D.uuid,X=R.uuid;let q=c[L];q===void 0&&(q={},c[L]=q);let F=q[X];F===void 0&&(F=D.clone(),q[X]=F,R.addEventListener("dispose",S)),D=F}if(D.visible=R.visible,D.wireframe=R.wireframe,E===js?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,_.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const L=i.properties.get(D);L.light=_}return D}function M(b,R,_,E,D){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&D===js)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,b.matrixWorld);const X=e.update(b),q=b.material;if(Array.isArray(q)){const F=X.groups;for(let W=0,V=F.length;W<V;W++){const Q=F[W],te=q[Q.materialIndex];if(te&&te.visible){const ee=T(b,te,E,D);b.onBeforeShadow(i,b,R,_,X,ee,Q),i.renderBufferDirect(_,null,X,ee,b,Q),b.onAfterShadow(i,b,R,_,X,ee,Q)}}}else if(q.visible){const F=T(b,q,E,D);b.onBeforeShadow(i,b,R,_,X,F,null),i.renderBufferDirect(_,null,X,F,b,null),b.onAfterShadow(i,b,R,_,X,F,null)}}const L=b.children;for(let X=0,q=L.length;X<q;X++)M(L[X],R,_,E,D)}function S(b){b.target.removeEventListener("dispose",S);for(const _ in c){const E=c[_],D=b.target.uuid;D in E&&(E[D].dispose(),delete E[D])}}}function n2(i,e){function t(){let P=!1;const ae=new ft;let $=null;const he=new ft(0,0,0,0);return{setMask:function(me){$!==me&&!P&&(i.colorMask(me,me,me,me),$=me)},setLocked:function(me){P=me},setClear:function(me,j,be,ye,gt){gt===!0&&(me*=ye,j*=ye,be*=ye),ae.set(me,j,be,ye),he.equals(ae)===!1&&(i.clearColor(me,j,be,ye),he.copy(ae))},reset:function(){P=!1,$=null,he.set(-1,0,0,0)}}}function n(){let P=!1,ae=!1,$=null,he=null,me=null;return{setReversed:function(j){if(ae!==j){const be=e.get("EXT_clip_control");j?be.clipControlEXT(be.LOWER_LEFT_EXT,be.ZERO_TO_ONE_EXT):be.clipControlEXT(be.LOWER_LEFT_EXT,be.NEGATIVE_ONE_TO_ONE_EXT),ae=j;const ye=me;me=null,this.setClear(ye)}},getReversed:function(){return ae},setTest:function(j){j?ne(i.DEPTH_TEST):k(i.DEPTH_TEST)},setMask:function(j){$!==j&&!P&&(i.depthMask(j),$=j)},setFunc:function(j){if(ae&&(j=Lp[j]),he!==j){switch(j){case ol:i.depthFunc(i.NEVER);break;case ll:i.depthFunc(i.ALWAYS);break;case cl:i.depthFunc(i.LESS);break;case Ds:i.depthFunc(i.LEQUAL);break;case hl:i.depthFunc(i.EQUAL);break;case ul:i.depthFunc(i.GEQUAL);break;case dl:i.depthFunc(i.GREATER);break;case fl:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}he=j}},setLocked:function(j){P=j},setClear:function(j){me!==j&&(me=j,ae&&(j=1-j),i.clearDepth(j))},reset:function(){P=!1,$=null,he=null,me=null,ae=!1}}}function s(){let P=!1,ae=null,$=null,he=null,me=null,j=null,be=null,ye=null,gt=null;return{setTest:function(ot){P||(ot?ne(i.STENCIL_TEST):k(i.STENCIL_TEST))},setMask:function(ot){ae!==ot&&!P&&(i.stencilMask(ot),ae=ot)},setFunc:function(ot,yn,Sn){($!==ot||he!==yn||me!==Sn)&&(i.stencilFunc(ot,yn,Sn),$=ot,he=yn,me=Sn)},setOp:function(ot,yn,Sn){(j!==ot||be!==yn||ye!==Sn)&&(i.stencilOp(ot,yn,Sn),j=ot,be=yn,ye=Sn)},setLocked:function(ot){P=ot},setClear:function(ot){gt!==ot&&(i.clearStencil(ot),gt=ot)},reset:function(){P=!1,ae=null,$=null,he=null,me=null,j=null,be=null,ye=null,gt=null}}}const r=new t,a=new n,o=new s,l=new WeakMap,c=new WeakMap;let h={},u={},d={},p=new WeakMap,g=[],x=null,m=!1,f=null,w=null,T=null,M=null,S=null,b=null,R=null,_=new xe(0,0,0),E=0,D=!1,C=null,L=null,X=null,q=null,F=null;const W=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let V=!1,Q=0;const te=i.getParameter(i.VERSION);te.indexOf("WebGL")!==-1?(Q=parseFloat(/^WebGL (\d)/.exec(te)[1]),V=Q>=1):te.indexOf("OpenGL ES")!==-1&&(Q=parseFloat(/^OpenGL ES (\d)/.exec(te)[1]),V=Q>=2);let ee=null,se={};const ge=i.getParameter(i.SCISSOR_BOX),Ve=i.getParameter(i.VIEWPORT),at=new ft().fromArray(ge),We=new ft().fromArray(Ve);function Z(P,ae,$,he){const me=new Uint8Array(4),j=i.createTexture();i.bindTexture(P,j),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let be=0;be<$;be++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(ae,0,i.RGBA,1,1,he,0,i.RGBA,i.UNSIGNED_BYTE,me):i.texImage2D(ae+be,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,me);return j}const re={};re[i.TEXTURE_2D]=Z(i.TEXTURE_2D,i.TEXTURE_2D,1),re[i.TEXTURE_CUBE_MAP]=Z(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),re[i.TEXTURE_2D_ARRAY]=Z(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),re[i.TEXTURE_3D]=Z(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),ne(i.DEPTH_TEST),a.setFunc(Ds),$e(!1),Je(Mh),ne(i.CULL_FACE),Ie(Zn);function ne(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function k(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function De(P,ae){return d[P]!==ae?(i.bindFramebuffer(P,ae),d[P]=ae,P===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=ae),P===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=ae),!0):!1}function Pe(P,ae){let $=g,he=!1;if(P){$=p.get(ae),$===void 0&&($=[],p.set(ae,$));const me=P.textures;if($.length!==me.length||$[0]!==i.COLOR_ATTACHMENT0){for(let j=0,be=me.length;j<be;j++)$[j]=i.COLOR_ATTACHMENT0+j;$.length=me.length,he=!0}}else $[0]!==i.BACK&&($[0]=i.BACK,he=!0);he&&i.drawBuffers($)}function Re(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const Me={[Pi]:i.FUNC_ADD,[np]:i.FUNC_SUBTRACT,[ip]:i.FUNC_REVERSE_SUBTRACT};Me[sp]=i.MIN,Me[rp]=i.MAX;const Ue={[ap]:i.ZERO,[op]:i.ONE,[lp]:i.SRC_COLOR,[rl]:i.SRC_ALPHA,[pp]:i.SRC_ALPHA_SATURATE,[dp]:i.DST_COLOR,[hp]:i.DST_ALPHA,[cp]:i.ONE_MINUS_SRC_COLOR,[al]:i.ONE_MINUS_SRC_ALPHA,[fp]:i.ONE_MINUS_DST_COLOR,[up]:i.ONE_MINUS_DST_ALPHA,[mp]:i.CONSTANT_COLOR,[gp]:i.ONE_MINUS_CONSTANT_COLOR,[vp]:i.CONSTANT_ALPHA,[_p]:i.ONE_MINUS_CONSTANT_ALPHA};function Ie(P,ae,$,he,me,j,be,ye,gt,ot){if(P===Zn){m===!0&&(k(i.BLEND),m=!1);return}if(m===!1&&(ne(i.BLEND),m=!0),P!==tp){if(P!==f||ot!==D){if((w!==Pi||S!==Pi)&&(i.blendEquation(i.FUNC_ADD),w=Pi,S=Pi),ot)switch(P){case bs:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Bi:i.blendFunc(i.ONE,i.ONE);break;case yh:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Sh:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:qe("WebGLState: Invalid blending: ",P);break}else switch(P){case bs:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Bi:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case yh:qe("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Sh:qe("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:qe("WebGLState: Invalid blending: ",P);break}T=null,M=null,b=null,R=null,_.set(0,0,0),E=0,f=P,D=ot}return}me=me||ae,j=j||$,be=be||he,(ae!==w||me!==S)&&(i.blendEquationSeparate(Me[ae],Me[me]),w=ae,S=me),($!==T||he!==M||j!==b||be!==R)&&(i.blendFuncSeparate(Ue[$],Ue[he],Ue[j],Ue[be]),T=$,M=he,b=j,R=be),(ye.equals(_)===!1||gt!==E)&&(i.blendColor(ye.r,ye.g,ye.b,gt),_.copy(ye),E=gt),f=P,D=!1}function Le(P,ae){P.side===vn?k(i.CULL_FACE):ne(i.CULL_FACE);let $=P.side===Nt;ae&&($=!$),$e($),P.blending===bs&&P.transparent===!1?Ie(Zn):Ie(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const he=P.stencilWrite;o.setTest(he),he&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),dt(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?ne(i.SAMPLE_ALPHA_TO_COVERAGE):k(i.SAMPLE_ALPHA_TO_COVERAGE)}function $e(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Je(P){P!==Qf?(ne(i.CULL_FACE),P!==L&&(P===Mh?i.cullFace(i.BACK):P===jf?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):k(i.CULL_FACE),L=P}function pt(P){P!==X&&(V&&i.lineWidth(P),X=P)}function dt(P,ae,$){P?(ne(i.POLYGON_OFFSET_FILL),(q!==ae||F!==$)&&(q=ae,F=$,a.getReversed()&&(ae=-ae),i.polygonOffset(ae,$))):k(i.POLYGON_OFFSET_FILL)}function mt(P){P?ne(i.SCISSOR_TEST):k(i.SCISSOR_TEST)}function St(P){P===void 0&&(P=i.TEXTURE0+W-1),ee!==P&&(i.activeTexture(P),ee=P)}function I(P,ae,$){$===void 0&&(ee===null?$=i.TEXTURE0+W-1:$=ee);let he=se[$];he===void 0&&(he={type:void 0,texture:void 0},se[$]=he),(he.type!==P||he.texture!==ae)&&(ee!==$&&(i.activeTexture($),ee=$),i.bindTexture(P,ae||re[P]),he.type=P,he.texture=ae)}function Kt(){const P=se[ee];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function Qe(){try{i.compressedTexImage2D(...arguments)}catch(P){qe("WebGLState:",P)}}function A(){try{i.compressedTexImage3D(...arguments)}catch(P){qe("WebGLState:",P)}}function v(){try{i.texSubImage2D(...arguments)}catch(P){qe("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){qe("WebGLState:",P)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(P){qe("WebGLState:",P)}}function Y(){try{i.compressedTexSubImage3D(...arguments)}catch(P){qe("WebGLState:",P)}}function ie(){try{i.texStorage2D(...arguments)}catch(P){qe("WebGLState:",P)}}function oe(){try{i.texStorage3D(...arguments)}catch(P){qe("WebGLState:",P)}}function K(){try{i.texImage2D(...arguments)}catch(P){qe("WebGLState:",P)}}function J(){try{i.texImage3D(...arguments)}catch(P){qe("WebGLState:",P)}}function le(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function we(P,ae){u[P]!==ae&&(i.pixelStorei(P,ae),u[P]=ae)}function ue(P){at.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),at.copy(P))}function ce(P){We.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),We.copy(P))}function Ce(P,ae){let $=c.get(ae);$===void 0&&($=new WeakMap,c.set(ae,$));let he=$.get(P);he===void 0&&(he=i.getUniformBlockIndex(ae,P.name),$.set(P,he))}function Ne(P,ae){const he=c.get(ae).get(P);l.get(ae)!==he&&(i.uniformBlockBinding(ae,he,P.__bindingPointIndex),l.set(ae,he))}function Be(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},ee=null,se={},d={},p=new WeakMap,g=[],x=null,m=!1,f=null,w=null,T=null,M=null,S=null,b=null,R=null,_=new xe(0,0,0),E=0,D=!1,C=null,L=null,X=null,q=null,F=null,at.set(0,0,i.canvas.width,i.canvas.height),We.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:ne,disable:k,bindFramebuffer:De,drawBuffers:Pe,useProgram:Re,setBlending:Ie,setMaterial:Le,setFlipSided:$e,setCullFace:Je,setLineWidth:pt,setPolygonOffset:dt,setScissorTest:mt,activeTexture:St,bindTexture:I,unbindTexture:Kt,compressedTexImage2D:Qe,compressedTexImage3D:A,texImage2D:K,texImage3D:J,pixelStorei:we,getParameter:le,updateUBOMapping:Ce,uniformBlockBinding:Ne,texStorage2D:ie,texStorage3D:oe,texSubImage2D:v,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:Y,scissor:ue,viewport:ce,reset:Be}}function i2(i,e,t,n,s,r,a){const o=e.has("WEBGL_multisampled_render_to_texture")?e.get("WEBGL_multisampled_render_to_texture"):null,l=typeof navigator>"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Fe,h=new WeakMap,u=new Set;let d;const p=new WeakMap;let g=!1;try{g=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function x(A,v){return g?new OffscreenCanvas(A,v):Ra("canvas")}function m(A,v,O){let G=1;const Y=Qe(A);if((Y.width>O||Y.height>O)&&(G=O/Math.max(Y.width,Y.height)),G<1)if(typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&A instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&A instanceof ImageBitmap||typeof VideoFrame<"u"&&A instanceof VideoFrame){const ie=Math.floor(G*Y.width),oe=Math.floor(G*Y.height);d===void 0&&(d=x(ie,oe));const K=v?x(ie,oe):d;return K.width=ie,K.height=oe,K.getContext("2d").drawImage(A,0,0,ie,oe),Oe("WebGLRenderer: Texture has been resized from ("+Y.width+"x"+Y.height+") to ("+ie+"x"+oe+")."),K}else return"data"in A&&Oe("WebGLRenderer: Image in DataTexture is too big ("+Y.width+"x"+Y.height+")."),A;return A}function f(A){return A.generateMipmaps}function w(A){i.generateMipmap(A)}function T(A){return A.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:A.isWebGL3DRenderTarget?i.TEXTURE_3D:A.isWebGLArrayRenderTarget||A.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(A,v,O,G,Y,ie=!1){if(A!==null){if(i[A]!==void 0)return i[A];Oe("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+A+"'")}let oe;G&&(oe=e.get("EXT_texture_norm16"),oe||Oe("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let K=v;if(v===i.RED&&(O===i.FLOAT&&(K=i.R32F),O===i.HALF_FLOAT&&(K=i.R16F),O===i.UNSIGNED_BYTE&&(K=i.R8),O===i.UNSIGNED_SHORT&&oe&&(K=oe.R16_EXT),O===i.SHORT&&oe&&(K=oe.R16_SNORM_EXT)),v===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.R8UI),O===i.UNSIGNED_SHORT&&(K=i.R16UI),O===i.UNSIGNED_INT&&(K=i.R32UI),O===i.BYTE&&(K=i.R8I),O===i.SHORT&&(K=i.R16I),O===i.INT&&(K=i.R32I)),v===i.RG&&(O===i.FLOAT&&(K=i.RG32F),O===i.HALF_FLOAT&&(K=i.RG16F),O===i.UNSIGNED_BYTE&&(K=i.RG8),O===i.UNSIGNED_SHORT&&oe&&(K=oe.RG16_EXT),O===i.SHORT&&oe&&(K=oe.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RG8UI),O===i.UNSIGNED_SHORT&&(K=i.RG16UI),O===i.UNSIGNED_INT&&(K=i.RG32UI),O===i.BYTE&&(K=i.RG8I),O===i.SHORT&&(K=i.RG16I),O===i.INT&&(K=i.RG32I)),v===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGB8UI),O===i.UNSIGNED_SHORT&&(K=i.RGB16UI),O===i.UNSIGNED_INT&&(K=i.RGB32UI),O===i.BYTE&&(K=i.RGB8I),O===i.SHORT&&(K=i.RGB16I),O===i.INT&&(K=i.RGB32I)),v===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(K=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(K=i.RGBA16UI),O===i.UNSIGNED_INT&&(K=i.RGBA32UI),O===i.BYTE&&(K=i.RGBA8I),O===i.SHORT&&(K=i.RGBA16I),O===i.INT&&(K=i.RGBA32I)),v===i.RGB&&(O===i.UNSIGNED_SHORT&&oe&&(K=oe.RGB16_EXT),O===i.SHORT&&oe&&(K=oe.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(K=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(K=i.R11F_G11F_B10F)),v===i.RGBA){const J=ie?Ta:Ye.getTransfer(Y);O===i.FLOAT&&(K=i.RGBA32F),O===i.HALF_FLOAT&&(K=i.RGBA16F),O===i.UNSIGNED_BYTE&&(K=J===je?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&oe&&(K=oe.RGBA16_EXT),O===i.SHORT&&oe&&(K=oe.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(K=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(K=i.RGB5_A1)}return(K===i.R16F||K===i.R32F||K===i.RG16F||K===i.RG32F||K===i.RGBA16F||K===i.RGBA32F)&&e.get("EXT_color_buffer_float"),K}function S(A,v){let O;return A?v===null||v===zn||v===ur?O=i.DEPTH24_STENCIL8:v===Ln?O=i.DEPTH32F_STENCIL8:v===hr&&(O=i.DEPTH24_STENCIL8,Oe("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===zn||v===ur?O=i.DEPTH_COMPONENT24:v===Ln?O=i.DEPTH_COMPONENT32F:v===hr&&(O=i.DEPTH_COMPONENT16),O}function b(A,v){return f(A)===!0||A.isFramebufferTexture&&A.minFilter!==Ut&&A.minFilter!==Gt?Math.log2(Math.max(v.width,v.height))+1:A.mipmaps!==void 0&&A.mipmaps.length>0?A.mipmaps.length:A.isCompressedTexture&&Array.isArray(A.image)?v.mipmaps.length:1}function R(A){const v=A.target;v.removeEventListener("dispose",R),E(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function _(A){const v=A.target;v.removeEventListener("dispose",_),C(v)}function E(A){const v=n.get(A);if(v.__webglInit===void 0)return;const O=A.source,G=p.get(O);if(G){const Y=G[v.__cacheKey];Y.usedTimes--,Y.usedTimes===0&&D(A),Object.keys(G).length===0&&p.delete(O)}n.remove(A)}function D(A){const v=n.get(A);i.deleteTexture(v.__webglTexture);const O=A.source,G=p.get(O);delete G[v.__cacheKey],a.memory.textures--}function C(A){const v=n.get(A);if(A.depthTexture&&(A.depthTexture.dispose(),n.remove(A.depthTexture)),A.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(v.__webglFramebuffer[G]))for(let Y=0;Y<v.__webglFramebuffer[G].length;Y++)i.deleteFramebuffer(v.__webglFramebuffer[G][Y]);else i.deleteFramebuffer(v.__webglFramebuffer[G]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[G])}else{if(Array.isArray(v.__webglFramebuffer))for(let G=0;G<v.__webglFramebuffer.length;G++)i.deleteFramebuffer(v.__webglFramebuffer[G]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let G=0;G<v.__webglColorRenderbuffer.length;G++)v.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[G]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const O=A.textures;for(let G=0,Y=O.length;G<Y;G++){const ie=n.get(O[G]);ie.__webglTexture&&(i.deleteTexture(ie.__webglTexture),a.memory.textures--),n.remove(O[G])}n.remove(A)}let L=0;function X(){L=0}function q(){return L}function F(A){L=A}function W(){const A=L;return A>=s.maxTextures&&Oe("WebGLTextures: Trying to use "+A+" texture units while this GPU supports only "+s.maxTextures),L+=1,A}function V(A){const v=[];return v.push(A.wrapS),v.push(A.wrapT),v.push(A.wrapR||0),v.push(A.magFilter),v.push(A.minFilter),v.push(A.anisotropy),v.push(A.internalFormat),v.push(A.format),v.push(A.type),v.push(A.generateMipmaps),v.push(A.premultiplyAlpha),v.push(A.flipY),v.push(A.unpackAlignment),v.push(A.colorSpace),v.join()}function Q(A,v){const O=n.get(A);if(A.isVideoTexture&&I(A),A.isRenderTargetTexture===!1&&A.isExternalTexture!==!0&&A.version>0&&O.__version!==A.version){const G=A.image;if(G===null)Oe("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Oe("WebGLRenderer: Texture marked for update but image is incomplete");else{k(O,A,v);return}}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+v)}function te(A,v){const O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){k(O,A,v);return}else A.isExternalTexture&&(O.__webglTexture=A.sourceTexture?A.sourceTexture:null);t.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+v)}function ee(A,v){const O=n.get(A);if(A.isRenderTargetTexture===!1&&A.version>0&&O.__version!==A.version){k(O,A,v);return}t.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+v)}function se(A,v){const O=n.get(A);if(A.isCubeDepthTexture!==!0&&A.version>0&&O.__version!==A.version){De(O,A,v);return}t.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+v)}const ge={[pl]:i.REPEAT,[Kn]:i.CLAMP_TO_EDGE,[ml]:i.MIRRORED_REPEAT},Ve={[Ut]:i.NEAREST,[yp]:i.NEAREST_MIPMAP_NEAREST,[br]:i.NEAREST_MIPMAP_LINEAR,[Gt]:i.LINEAR,[to]:i.LINEAR_MIPMAP_NEAREST,[Ui]:i.LINEAR_MIPMAP_LINEAR},at={[bp]:i.NEVER,[Cp]:i.ALWAYS,[wp]:i.LESS,[Lc]:i.LEQUAL,[Ap]:i.EQUAL,[Nc]:i.GEQUAL,[Tp]:i.GREATER,[Rp]:i.NOTEQUAL};function We(A,v){if(v.type===Ln&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Gt||v.magFilter===to||v.magFilter===br||v.magFilter===Ui||v.minFilter===Gt||v.minFilter===to||v.minFilter===br||v.minFilter===Ui)&&Oe("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(A,i.TEXTURE_WRAP_S,ge[v.wrapS]),i.texParameteri(A,i.TEXTURE_WRAP_T,ge[v.wrapT]),(A===i.TEXTURE_3D||A===i.TEXTURE_2D_ARRAY)&&i.texParameteri(A,i.TEXTURE_WRAP_R,ge[v.wrapR]),i.texParameteri(A,i.TEXTURE_MAG_FILTER,Ve[v.magFilter]),i.texParameteri(A,i.TEXTURE_MIN_FILTER,Ve[v.minFilter]),v.compareFunction&&(i.texParameteri(A,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(A,i.TEXTURE_COMPARE_FUNC,at[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Ut||v.minFilter!==br&&v.minFilter!==Ui||v.type===Ln&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const O=e.get("EXT_texture_filter_anisotropic");i.texParameterf(A,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Z(A,v){let O=!1;A.__webglInit===void 0&&(A.__webglInit=!0,v.addEventListener("dispose",R));const G=v.source;let Y=p.get(G);Y===void 0&&(Y={},p.set(G,Y));const ie=V(v);if(ie!==A.__cacheKey){Y[ie]===void 0&&(Y[ie]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),Y[ie].usedTimes++;const oe=Y[A.__cacheKey];oe!==void 0&&(Y[A.__cacheKey].usedTimes--,oe.usedTimes===0&&D(v)),A.__cacheKey=ie,A.__webglTexture=Y[ie].texture}return O}function re(A,v,O){return Math.floor(Math.floor(A/O)/v)}function ne(A,v,O,G){const ie=A.updateRanges;if(ie.length===0)t.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,O,G,v.data);else{ie.sort((we,ue)=>we.start-ue.start);let oe=0;for(let we=1;we<ie.length;we++){const ue=ie[oe],ce=ie[we],Ce=ue.start+ue.count,Ne=re(ce.start,v.width,4),Be=re(ue.start,v.width,4);ce.start<=Ce+1&&Ne===Be&&re(ce.start+ce.count-1,v.width,4)===Ne?ue.count=Math.max(ue.count,ce.start+ce.count-ue.start):(++oe,ie[oe]=ce)}ie.length=oe+1;const K=t.getParameter(i.UNPACK_ROW_LENGTH),J=t.getParameter(i.UNPACK_SKIP_PIXELS),le=t.getParameter(i.UNPACK_SKIP_ROWS);t.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let we=0,ue=ie.length;we<ue;we++){const ce=ie[we],Ce=Math.floor(ce.start/4),Ne=Math.ceil(ce.count/4),Be=Ce%v.width,P=Math.floor(Ce/v.width),ae=Ne,$=1;t.pixelStorei(i.UNPACK_SKIP_PIXELS,Be),t.pixelStorei(i.UNPACK_SKIP_ROWS,P),t.texSubImage2D(i.TEXTURE_2D,0,Be,P,ae,$,O,G,v.data)}A.clearUpdateRanges(),t.pixelStorei(i.UNPACK_ROW_LENGTH,K),t.pixelStorei(i.UNPACK_SKIP_PIXELS,J),t.pixelStorei(i.UNPACK_SKIP_ROWS,le)}}function k(A,v,O){let G=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(G=i.TEXTURE_3D);const Y=Z(A,v),ie=v.source;t.bindTexture(G,A.__webglTexture,i.TEXTURE0+O);const oe=n.get(ie);if(ie.version!==oe.__version||Y===!0){if(t.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const $=Ye.getPrimaries(Ye.workingColorSpace),he=v.colorSpace===fi?null:Ye.getPrimaries(v.colorSpace),me=v.colorSpace===fi||$===he?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,me)}t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment);let J=m(v.image,!1,s.maxTextureSize);J=Kt(v,J);const le=r.convert(v.format,v.colorSpace),we=r.convert(v.type);let ue=M(v.internalFormat,le,we,v.normalized,v.colorSpace,v.isVideoTexture);We(G,v);let ce;const Ce=v.mipmaps,Ne=v.isVideoTexture!==!0,Be=oe.__version===void 0||Y===!0,P=ie.dataReady,ae=b(v,J);if(v.isDepthTexture)ue=S(v.format===Fi,v.type),Be&&(Ne?t.texStorage2D(i.TEXTURE_2D,1,ue,J.width,J.height):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,le,we,null));else if(v.isDataTexture)if(Ce.length>0){Ne&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Ce[0].width,Ce[0].height);for(let $=0,he=Ce.length;$<he;$++)ce=Ce[$],Ne?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,we,ce.data):t.texImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,le,we,ce.data);v.generateMipmaps=!1}else Ne?(Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height),P&&ne(v,J,le,we)):t.texImage2D(i.TEXTURE_2D,0,ue,J.width,J.height,0,le,we,J.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Ne&&Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,Ce[0].width,Ce[0].height,J.depth);for(let $=0,he=Ce.length;$<he;$++)if(ce=Ce[$],v.format!==_n)if(le!==null)if(Ne){if(P)if(v.layerUpdates.size>0){const me=Jh(ce.width,ce.height,v.format,v.type);for(const j of v.layerUpdates){const be=ce.data.subarray(j*me/ce.data.BYTES_PER_ELEMENT,(j+1)*me/ce.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,j,ce.width,ce.height,1,le,be)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ce.width,ce.height,J.depth,le,ce.data)}else t.compressedTexImage3D(i.TEXTURE_2D_ARRAY,$,ue,ce.width,ce.height,J.depth,0,ce.data,0,0);else Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ne?P&&t.texSubImage3D(i.TEXTURE_2D_ARRAY,$,0,0,0,ce.width,ce.height,J.depth,le,we,ce.data):t.texImage3D(i.TEXTURE_2D_ARRAY,$,ue,ce.width,ce.height,J.depth,0,le,we,ce.data)}else{Ne&&Be&&t.texStorage2D(i.TEXTURE_2D,ae,ue,Ce[0].width,Ce[0].height);for(let $=0,he=Ce.length;$<he;$++)ce=Ce[$],v.format!==_n?le!==null?Ne?P&&t.compressedTexSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,ce.data):t.compressedTexImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,ce.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ne?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,ce.width,ce.height,le,we,ce.data):t.texImage2D(i.TEXTURE_2D,$,ue,ce.width,ce.height,0,le,we,ce.data)}else if(v.isDataArrayTexture)if(Ne){if(Be&&t.texStorage3D(i.TEXTURE_2D_ARRAY,ae,ue,J.width,J.height,J.depth),P)if(v.layerUpdates.size>0){const $=Jh(J.width,J.height,v.format,v.type);for(const he of v.layerUpdates){const me=J.data.subarray(he*$/J.data.BYTES_PER_ELEMENT,(he+1)*$/J.data.BYTES_PER_ELEMENT);t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,he,J.width,J.height,1,le,we,me)}v.clearLayerUpdates()}else t.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,J.width,J.height,J.depth,le,we,J.data)}else t.texImage3D(i.TEXTURE_2D_ARRAY,0,ue,J.width,J.height,J.depth,0,le,we,J.data);else if(v.isData3DTexture)Ne?(Be&&t.texStorage3D(i.TEXTURE_3D,ae,ue,J.width,J.height,J.depth),P&&t.texSubImage3D(i.TEXTURE_3D,0,0,0,0,J.width,J.height,J.depth,le,we,J.data)):t.texImage3D(i.TEXTURE_3D,0,ue,J.width,J.height,J.depth,0,le,we,J.data);else if(v.isFramebufferTexture){if(Be)if(Ne)t.texStorage2D(i.TEXTURE_2D,ae,ue,J.width,J.height);else{let $=J.width,he=J.height;for(let me=0;me<ae;me++)t.texImage2D(i.TEXTURE_2D,me,ue,$,he,0,le,we,null),$>>=1,he>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in i){const $=i.canvas;if($.hasAttribute("layoutsubtree")||$.setAttribute("layoutsubtree","true"),J.parentNode!==$){$.appendChild(J),u.add(v),$.onpaint=he=>{const me=he.changedElements;for(const j of u)me.includes(j.image)&&(j.needsUpdate=!0)},$.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,J);else{const me=i.RGBA,j=i.RGBA,be=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,me,j,be,J)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Ce.length>0){if(Ne&&Be){const $=Qe(Ce[0]);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}for(let $=0,he=Ce.length;$<he;$++)ce=Ce[$],Ne?P&&t.texSubImage2D(i.TEXTURE_2D,$,0,0,le,we,ce):t.texImage2D(i.TEXTURE_2D,$,ue,le,we,ce);v.generateMipmaps=!1}else if(Ne){if(Be){const $=Qe(J);t.texStorage2D(i.TEXTURE_2D,ae,ue,$.width,$.height)}P&&t.texSubImage2D(i.TEXTURE_2D,0,0,0,le,we,J)}else t.texImage2D(i.TEXTURE_2D,0,ue,le,we,J);f(v)&&w(G),oe.__version=ie.version,v.onUpdate&&v.onUpdate(v)}A.__version=v.version}function De(A,v,O){if(v.image.length!==6)return;const G=Z(A,v),Y=v.source;t.bindTexture(i.TEXTURE_CUBE_MAP,A.__webglTexture,i.TEXTURE0+O);const ie=n.get(Y);if(Y.version!==ie.__version||G===!0){t.activeTexture(i.TEXTURE0+O);const oe=Ye.getPrimaries(Ye.workingColorSpace),K=v.colorSpace===fi?null:Ye.getPrimaries(v.colorSpace),J=v.colorSpace===fi||oe===K?i.NONE:i.BROWSER_DEFAULT_WEBGL;t.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),t.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),t.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),t.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,J);const le=v.isCompressedTexture||v.image[0].isCompressedTexture,we=v.image[0]&&v.image[0].isDataTexture,ue=[];for(let j=0;j<6;j++)!le&&!we?ue[j]=m(v.image[j],!0,s.maxCubemapSize):ue[j]=we?v.image[j].image:v.image[j],ue[j]=Kt(v,ue[j]);const ce=ue[0],Ce=r.convert(v.format,v.colorSpace),Ne=r.convert(v.type),Be=M(v.internalFormat,Ce,Ne,v.normalized,v.colorSpace),P=v.isVideoTexture!==!0,ae=ie.__version===void 0||G===!0,$=Y.dataReady;let he=b(v,ce);We(i.TEXTURE_CUBE_MAP,v);let me;if(le){P&&ae&&t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,ce.width,ce.height);for(let j=0;j<6;j++){me=ue[j].mipmaps;for(let be=0;be<me.length;be++){const ye=me[be];v.format!==_n?Ce!==null?P?$&&t.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,ye.width,ye.height,Ce,ye.data):t.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,ye.width,ye.height,0,ye.data):Oe("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,0,0,ye.width,ye.height,Ce,Ne,ye.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be,Be,ye.width,ye.height,0,Ce,Ne,ye.data)}}}else{if(me=v.mipmaps,P&&ae){me.length>0&&he++;const j=Qe(ue[0]);t.texStorage2D(i.TEXTURE_CUBE_MAP,he,Be,j.width,j.height)}for(let j=0;j<6;j++)if(we){P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,ue[j].width,ue[j].height,Ce,Ne,ue[j].data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,ue[j].width,ue[j].height,0,Ce,Ne,ue[j].data);for(let be=0;be<me.length;be++){const gt=me[be].image[j].image;P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,gt.width,gt.height,Ce,Ne,gt.data):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,gt.width,gt.height,0,Ce,Ne,gt.data)}}else{P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,0,0,Ce,Ne,ue[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,0,Be,Ce,Ne,ue[j]);for(let be=0;be<me.length;be++){const ye=me[be];P?$&&t.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,0,0,Ce,Ne,ye.image[j]):t.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+j,be+1,Be,Ce,Ne,ye.image[j])}}}f(v)&&w(i.TEXTURE_CUBE_MAP),ie.__version=Y.version,v.onUpdate&&v.onUpdate(v)}A.__version=v.version}function Pe(A,v,O,G,Y,ie){const oe=r.convert(O.format,O.colorSpace),K=r.convert(O.type),J=M(O.internalFormat,oe,K,O.normalized,O.colorSpace),le=n.get(v),we=n.get(O);if(we.__renderTarget=v,!le.__hasExternalTextures){const ue=Math.max(1,v.width>>ie),ce=Math.max(1,v.height>>ie);Y===i.TEXTURE_3D||Y===i.TEXTURE_2D_ARRAY?t.texImage3D(Y,ie,J,ue,ce,v.depth,0,oe,K,null):t.texImage2D(Y,ie,J,ue,ce,0,oe,K,null)}t.bindFramebuffer(i.FRAMEBUFFER,A),St(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,Y,we.__webglTexture,0,mt(v)):(Y===i.TEXTURE_2D||Y>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&Y<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,Y,we.__webglTexture,ie),t.bindFramebuffer(i.FRAMEBUFFER,null)}function Re(A,v,O){if(i.bindRenderbuffer(i.RENDERBUFFER,A),v.depthBuffer){const G=v.depthTexture,Y=G&&G.isDepthTexture?G.type:null,ie=S(v.stencilBuffer,Y),oe=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;St(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,mt(v),ie,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,mt(v),ie,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,ie,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,oe,i.RENDERBUFFER,A)}else{const G=v.textures;for(let Y=0;Y<G.length;Y++){const ie=G[Y],oe=r.convert(ie.format,ie.colorSpace),K=r.convert(ie.type),J=M(ie.internalFormat,oe,K,ie.normalized,ie.colorSpace);St(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,mt(v),J,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,mt(v),J,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,J,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function Me(A,v,O){const G=v.isWebGLCubeRenderTarget===!0;if(t.bindFramebuffer(i.FRAMEBUFFER,A),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const Y=n.get(v.depthTexture);if(Y.__renderTarget=v,(!Y.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),G){if(Y.__webglInit===void 0&&(Y.__webglInit=!0,v.depthTexture.addEventListener("dispose",R)),Y.__webglTexture===void 0){Y.__webglTexture=i.createTexture(),t.bindTexture(i.TEXTURE_CUBE_MAP,Y.__webglTexture),We(i.TEXTURE_CUBE_MAP,v.depthTexture);const le=r.convert(v.depthTexture.format),we=r.convert(v.depthTexture.type);let ue;v.depthTexture.format===Qn?ue=i.DEPTH_COMPONENT24:v.depthTexture.format===Fi&&(ue=i.DEPTH24_STENCIL8);for(let ce=0;ce<6;ce++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+ce,0,ue,v.width,v.height,0,le,we,null)}}else Q(v.depthTexture,0);const ie=Y.__webglTexture,oe=mt(v),K=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,J=v.depthTexture.format===Fi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===Qn)St(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,ie,0);else if(v.depthTexture.format===Fi)St(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,J,K,ie,0,oe):i.framebufferTexture2D(i.FRAMEBUFFER,J,K,ie,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function Ue(A){const v=n.get(A),O=A.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==A.depthTexture){const G=A.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),G){const Y=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,G.removeEventListener("dispose",Y)};G.addEventListener("dispose",Y),v.__depthDisposeCallback=Y}v.__boundDepthTexture=G}if(A.depthTexture&&!v.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)Me(v.__webglFramebuffer[G],A,G);else{const G=A.texture.mipmaps;G&&G.length>0?Me(v.__webglFramebuffer[0],A,0):Me(v.__webglFramebuffer,A,0)}else if(O){v.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[G]),v.__webglDepthbuffer[G]===void 0)v.__webglDepthbuffer[G]=i.createRenderbuffer(),Re(v.__webglDepthbuffer[G],A,!1);else{const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=v.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,ie)}}else{const G=A.texture.mipmaps;if(G&&G.length>0?t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),Re(v.__webglDepthbuffer,A,!1);else{const Y=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ie=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,ie),i.framebufferRenderbuffer(i.FRAMEBUFFER,Y,i.RENDERBUFFER,ie)}}t.bindFramebuffer(i.FRAMEBUFFER,null)}function Ie(A,v,O){const G=n.get(A);v!==void 0&&Pe(G.__webglFramebuffer,A,A.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&Ue(A)}function Le(A){const v=A.texture,O=n.get(A),G=n.get(v);A.addEventListener("dispose",_);const Y=A.textures,ie=A.isWebGLCubeRenderTarget===!0,oe=Y.length>1;if(oe||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=v.version,a.memory.textures++),ie){O.__webglFramebuffer=[];for(let K=0;K<6;K++)if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer[K]=[];for(let J=0;J<v.mipmaps.length;J++)O.__webglFramebuffer[K][J]=i.createFramebuffer()}else O.__webglFramebuffer[K]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer=[];for(let K=0;K<v.mipmaps.length;K++)O.__webglFramebuffer[K]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(oe)for(let K=0,J=Y.length;K<J;K++){const le=n.get(Y[K]);le.__webglTexture===void 0&&(le.__webglTexture=i.createTexture(),a.memory.textures++)}if(A.samples>0&&St(A)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],t.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let K=0;K<Y.length;K++){const J=Y[K];O.__webglColorRenderbuffer[K]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[K]);const le=r.convert(J.format,J.colorSpace),we=r.convert(J.type),ue=M(J.internalFormat,le,we,J.normalized,J.colorSpace,A.isXRRenderTarget===!0),ce=mt(A);i.renderbufferStorageMultisample(i.RENDERBUFFER,ce,ue,A.width,A.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+K,i.RENDERBUFFER,O.__webglColorRenderbuffer[K])}i.bindRenderbuffer(i.RENDERBUFFER,null),A.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),Re(O.__webglDepthRenderbuffer,A,!0)),t.bindFramebuffer(i.FRAMEBUFFER,null)}}if(ie){t.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),We(i.TEXTURE_CUBE_MAP,v);for(let K=0;K<6;K++)if(v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)Pe(O.__webglFramebuffer[K][J],A,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,J);else Pe(O.__webglFramebuffer[K],A,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+K,0);f(v)&&w(i.TEXTURE_CUBE_MAP),t.unbindTexture()}else if(oe){for(let K=0,J=Y.length;K<J;K++){const le=Y[K],we=n.get(le);let ue=i.TEXTURE_2D;(A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(ue=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(ue,we.__webglTexture),We(ue,le),Pe(O.__webglFramebuffer,A,le,i.COLOR_ATTACHMENT0+K,ue,0),f(le)&&w(ue)}t.unbindTexture()}else{let K=i.TEXTURE_2D;if((A.isWebGL3DRenderTarget||A.isWebGLArrayRenderTarget)&&(K=A.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),t.bindTexture(K,G.__webglTexture),We(K,v),v.mipmaps&&v.mipmaps.length>0)for(let J=0;J<v.mipmaps.length;J++)Pe(O.__webglFramebuffer[J],A,v,i.COLOR_ATTACHMENT0,K,J);else Pe(O.__webglFramebuffer,A,v,i.COLOR_ATTACHMENT0,K,0);f(v)&&w(K),t.unbindTexture()}A.depthBuffer&&Ue(A)}function $e(A){const v=A.textures;for(let O=0,G=v.length;O<G;O++){const Y=v[O];if(f(Y)){const ie=T(A),oe=n.get(Y).__webglTexture;t.bindTexture(ie,oe),w(ie),t.unbindTexture()}}}const Je=[],pt=[];function dt(A){if(A.samples>0){if(St(A)===!1){const v=A.textures,O=A.width,G=A.height;let Y=i.COLOR_BUFFER_BIT;const ie=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,oe=n.get(A),K=v.length>1;if(K)for(let le=0;le<v.length;le++)t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,null),t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,null,0);t.bindFramebuffer(i.READ_FRAMEBUFFER,oe.__webglMultisampledFramebuffer);const J=A.texture.mipmaps;J&&J.length>0?t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer[0]):t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglFramebuffer);for(let le=0;le<v.length;le++){if(A.resolveDepthBuffer&&(A.depthBuffer&&(Y|=i.DEPTH_BUFFER_BIT),A.stencilBuffer&&A.resolveStencilBuffer&&(Y|=i.STENCIL_BUFFER_BIT)),K){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const we=n.get(v[le]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,we,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,Y,i.NEAREST),l===!0&&(Je.length=0,pt.length=0,Je.push(i.COLOR_ATTACHMENT0+le),A.depthBuffer&&A.resolveDepthBuffer===!1&&(Je.push(ie),pt.push(ie),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,pt)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Je))}if(t.bindFramebuffer(i.READ_FRAMEBUFFER,null),t.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),K)for(let le=0;le<v.length;le++){t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.RENDERBUFFER,oe.__webglColorRenderbuffer[le]);const we=n.get(v[le]).__webglTexture;t.bindFramebuffer(i.FRAMEBUFFER,oe.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+le,i.TEXTURE_2D,we,0)}t.bindFramebuffer(i.DRAW_FRAMEBUFFER,oe.__webglMultisampledFramebuffer)}else if(A.depthBuffer&&A.resolveDepthBuffer===!1&&l){const v=A.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function mt(A){return Math.min(s.maxSamples,A.samples)}function St(A){const v=n.get(A);return A.samples>0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function I(A){const v=a.render.frame;h.get(A)!==v&&(h.set(A,v),A.update())}function Kt(A,v){const O=A.colorSpace,G=A.format,Y=A.type;return A.isCompressedTexture===!0||A.isVideoTexture===!0||O!==Aa&&O!==fi&&(Ye.getTransfer(O)===je?(G!==_n||Y!==nn)&&Oe("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):qe("WebGLTextures: Unsupported texture color space:",O)),v}function Qe(A){return typeof HTMLImageElement<"u"&&A instanceof HTMLImageElement?(c.width=A.naturalWidth||A.width,c.height=A.naturalHeight||A.height):typeof VideoFrame<"u"&&A instanceof VideoFrame?(c.width=A.displayWidth,c.height=A.displayHeight):(c.width=A.width,c.height=A.height),c}this.allocateTextureUnit=W,this.resetTextureUnits=X,this.getTextureUnits=q,this.setTextureUnits=F,this.setTexture2D=Q,this.setTexture2DArray=te,this.setTexture3D=ee,this.setTextureCube=se,this.rebindTextures=Ie,this.setupRenderTarget=Le,this.updateRenderTargetMipmap=$e,this.updateMultisampleRenderTarget=dt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Pe,this.useMultisampledRTT=St,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function s2(i,e){function t(n,s=fi){let r;const a=Ye.getTransfer(s);if(n===nn)return i.UNSIGNED_BYTE;if(n===Rc)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Cc)return i.UNSIGNED_SHORT_5_5_5_1;if(n===Fd)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===Od)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Nd)return i.BYTE;if(n===Ud)return i.SHORT;if(n===hr)return i.UNSIGNED_SHORT;if(n===Tc)return i.INT;if(n===zn)return i.UNSIGNED_INT;if(n===Ln)return i.FLOAT;if(n===Jn)return i.HALF_FLOAT;if(n===zd)return i.ALPHA;if(n===Bd)return i.RGB;if(n===_n)return i.RGBA;if(n===Qn)return i.DEPTH_COMPONENT;if(n===Fi)return i.DEPTH_STENCIL;if(n===kd)return i.RED;if(n===Dc)return i.RED_INTEGER;if(n===Gi)return i.RG;if(n===Pc)return i.RG_INTEGER;if(n===Ic)return i.RGBA_INTEGER;if(n===ma||n===ga||n===va||n===_a)if(a===je)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===ma)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===ga)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===va)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===_a)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===ma)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===ga)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===va)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===_a)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===gl||n===vl||n===_l||n===xl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===gl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===vl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===_l)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===xl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Ml||n===yl||n===Sl||n===El||n===bl||n===ba||n===wl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Ml||n===yl)return a===je?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Sl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===El)return r.COMPRESSED_R11_EAC;if(n===bl)return r.COMPRESSED_SIGNED_R11_EAC;if(n===ba)return r.COMPRESSED_RG11_EAC;if(n===wl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Al||n===Tl||n===Rl||n===Cl||n===Dl||n===Pl||n===Il||n===Ll||n===Nl||n===Ul||n===Fl||n===Ol||n===zl||n===Bl)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Al)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===Tl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Rl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Cl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Dl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Pl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Il)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===Ll)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Nl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Ul)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Fl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===Ol)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===zl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Bl)return a===je?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===kl||n===Gl||n===Hl)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(n===kl)return a===je?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===Gl)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===Hl)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===Vl||n===Wl||n===wa||n===Xl)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(n===Vl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===Wl)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===wa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===Xl)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===ur?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:t}}const r2=`
|
|
4654
|
+
}`,__=[new F(1,0,0),new F(-1,0,0),new F(0,1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1)],x_=[new F(0,-1,0),new F(0,-1,0),new F(0,0,1),new F(0,0,-1),new F(0,-1,0),new F(0,-1,0)],Nu=new he,sr=new F,Ko=new F;function M_(i,t,e){let n=new th;const s=new Ft,r=new Ft,a=new pe,o=new Cm,c=new Dm,l={},h=e.maxTextureSize,u={[Ti]:Ce,[Ce]:Ti,[wn]:wn},d=new Be({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ft},radius:{value:4}},vertexShader:g_,fragmentShader:v_}),f=d.clone();f.defines.HORIZONTAL_PASS=1;const g=new Ee;g.setAttribute("position",new le(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const x=new se(g,d),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=gr;let p=this.type;this.render=function(b,R,_){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||b.length===0)return;this.type===vp&&(Ot("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=gr);const E=i.getRenderTarget(),D=i.getActiveCubeFace(),C=i.getActiveMipmapLevel(),I=i.state;I.setBlending(si),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 W=p!==this.type;W&&R.traverse(function(X){X.material&&(Array.isArray(X.material)?X.material.forEach(U=>U.needsUpdate=!0):X.material.needsUpdate=!0)});for(let X=0,U=b.length;X<U;X++){const q=b[X],H=q.shadow;if(H===void 0){Ot("WebGLShadowMap:",q,"has no shadow.");continue}if(H.autoUpdate===!1&&H.needsUpdate===!1)continue;s.copy(H.mapSize);const $=H.getFrameExtents();s.multiply($),r.copy(H.mapSize),(s.x>h||s.y>h)&&(s.x>h&&(r.x=Math.floor(h/$.x),s.x=r.x*$.x,H.mapSize.x=r.x),s.y>h&&(r.y=Math.floor(h/$.y),s.y=r.y*$.y,H.mapSize.y=r.y));const et=i.state.buffers.depth.getReversed();if(H.camera._reversedDepth=et,H.map===null||W===!0){if(H.map!==null&&(H.map.depthTexture!==null&&(H.map.depthTexture.dispose(),H.map.depthTexture=null),H.map.dispose()),this.type===lr){if(q.isPointLight){Ot("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}H.map=new Rn(s.x,s.y,{format:$i,type:xn,minFilter:Te,magFilter:Te,generateMipmaps:!1}),H.map.texture.name=q.name+".shadowMap",H.map.depthTexture=new Hs(s.x,s.y,Vn),H.map.depthTexture.name=q.name+".shadowMapDepth",H.map.depthTexture.format=ai,H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ke,H.map.depthTexture.magFilter=ke}else q.isPointLight?(H.map=new M0(s.x),H.map.depthTexture=new Em(s.x,Kn)):(H.map=new Rn(s.x,s.y),H.map.depthTexture=new Hs(s.x,s.y,Kn)),H.map.depthTexture.name=q.name+".shadowMap",H.map.depthTexture.format=ai,this.type===gr?(H.map.depthTexture.compareFunction=et?Kl:Yl,H.map.depthTexture.minFilter=Te,H.map.depthTexture.magFilter=Te):(H.map.depthTexture.compareFunction=null,H.map.depthTexture.minFilter=ke,H.map.depthTexture.magFilter=ke);H.camera.updateProjectionMatrix()}const j=H.map.isWebGLCubeRenderTarget?6:1;for(let it=0;it<j;it++){if(H.map.isWebGLCubeRenderTarget)i.setRenderTarget(H.map,it),i.clear();else{it===0&&(i.setRenderTarget(H.map),i.clear());const ut=H.getViewport(it);a.set(r.x*ut.x,r.y*ut.y,r.x*ut.z,r.y*ut.w),I.viewport(a)}if(q.isPointLight){const ut=H.camera,kt=H.matrix,qt=q.distance||ut.far;qt!==ut.far&&(ut.far=qt,ut.updateProjectionMatrix()),sr.setFromMatrixPosition(q.matrixWorld),ut.position.copy(sr),Ko.copy(ut.position),Ko.add(__[it]),ut.up.copy(x_[it]),ut.lookAt(Ko),ut.updateMatrixWorld(),kt.makeTranslation(-sr.x,-sr.y,-sr.z),Nu.multiplyMatrices(ut.projectionMatrix,ut.matrixWorldInverse),H._frustum.setFromProjectionMatrix(Nu,ut.coordinateSystem,ut.reversedDepth)}else H.updateMatrices(q);n=H.getFrustum(),M(R,_,H.camera,q,this.type)}H.isPointLightShadow!==!0&&this.type===lr&&w(H,_),H.needsUpdate=!1}p=this.type,m.needsUpdate=!1,i.setRenderTarget(E,D,C)};function w(b,R){const _=t.update(x);d.defines.VSM_SAMPLES!==b.blurSamples&&(d.defines.VSM_SAMPLES=b.blurSamples,f.defines.VSM_SAMPLES=b.blurSamples,d.needsUpdate=!0,f.needsUpdate=!0),b.mapPass===null&&(b.mapPass=new Rn(s.x,s.y,{format:$i,type:xn})),d.uniforms.shadow_pass.value=b.map.depthTexture,d.uniforms.resolution.value=b.mapSize,d.uniforms.radius.value=b.radius,i.setRenderTarget(b.mapPass),i.clear(),i.renderBufferDirect(R,null,_,d,x,null),f.uniforms.shadow_pass.value=b.mapPass.texture,f.uniforms.resolution.value=b.mapSize,f.uniforms.radius.value=b.radius,i.setRenderTarget(b.map),i.clear(),i.renderBufferDirect(R,null,_,f,x,null)}function A(b,R,_,E){let D=null;const C=_.isPointLight===!0?b.customDistanceMaterial:b.customDepthMaterial;if(C!==void 0)D=C;else if(D=_.isPointLight===!0?c:o,i.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=D.uuid,W=R.uuid;let X=l[I];X===void 0&&(X={},l[I]=X);let U=X[W];U===void 0&&(U=D.clone(),X[W]=U,R.addEventListener("dispose",S)),D=U}if(D.visible=R.visible,D.wireframe=R.wireframe,E===lr?D.side=R.shadowSide!==null?R.shadowSide:R.side:D.side=R.shadowSide!==null?R.shadowSide:u[R.side],D.alphaMap=R.alphaMap,D.alphaTest=R.alphaToCoverage===!0?.5:R.alphaTest,D.map=R.map,D.clipShadows=R.clipShadows,D.clippingPlanes=R.clippingPlanes,D.clipIntersection=R.clipIntersection,D.displacementMap=R.displacementMap,D.displacementScale=R.displacementScale,D.displacementBias=R.displacementBias,D.wireframeLinewidth=R.wireframeLinewidth,D.linewidth=R.linewidth,_.isPointLight===!0&&D.isMeshDistanceMaterial===!0){const I=i.properties.get(D);I.light=_}return D}function M(b,R,_,E,D){if(b.visible===!1)return;if(b.layers.test(R.layers)&&(b.isMesh||b.isLine||b.isPoints)&&(b.castShadow||b.receiveShadow&&D===lr)&&(!b.frustumCulled||n.intersectsObject(b))){b.modelViewMatrix.multiplyMatrices(_.matrixWorldInverse,b.matrixWorld);const W=t.update(b),X=b.material;if(Array.isArray(X)){const U=W.groups;for(let q=0,H=U.length;q<H;q++){const $=U[q],et=X[$.materialIndex];if(et&&et.visible){const j=A(b,et,E,D);b.onBeforeShadow(i,b,R,_,W,j,$),i.renderBufferDirect(_,null,W,j,b,$),b.onAfterShadow(i,b,R,_,W,j,$)}}}else if(X.visible){const U=A(b,X,E,D);b.onBeforeShadow(i,b,R,_,W,U,null),i.renderBufferDirect(_,null,W,U,b,null),b.onAfterShadow(i,b,R,_,W,U,null)}}const I=b.children;for(let W=0,X=I.length;W<X;W++)M(I[W],R,_,E,D)}function S(b){b.target.removeEventListener("dispose",S);for(const _ in l){const E=l[_],D=b.target.uuid;D in E&&(E[D].dispose(),delete E[D])}}}function y_(i,t){function e(){let P=!1;const at=new pe;let J=null;const ht=new pe(0,0,0,0);return{setMask:function(gt){J!==gt&&!P&&(i.colorMask(gt,gt,gt,gt),J=gt)},setLocked:function(gt){P=gt},setClear:function(gt,tt,wt,yt,ve){ve===!0&&(gt*=yt,tt*=yt,wt*=yt),at.set(gt,tt,wt,yt),ht.equals(at)===!1&&(i.clearColor(gt,tt,wt,yt),ht.copy(at))},reset:function(){P=!1,J=null,ht.set(-1,0,0,0)}}}function n(){let P=!1,at=!1,J=null,ht=null,gt=null;return{setReversed:function(tt){if(at!==tt){const wt=t.get("EXT_clip_control");tt?wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.ZERO_TO_ONE_EXT):wt.clipControlEXT(wt.LOWER_LEFT_EXT,wt.NEGATIVE_ONE_TO_ONE_EXT),at=tt;const yt=gt;gt=null,this.setClear(yt)}},getReversed:function(){return at},setTest:function(tt){tt?nt(i.DEPTH_TEST):z(i.DEPTH_TEST)},setMask:function(tt){J!==tt&&!P&&(i.depthMask(tt),J=tt)},setFunc:function(tt){if(at&&(tt=$p[tt]),ht!==tt){switch(tt){case Mc:i.depthFunc(i.NEVER);break;case yc:i.depthFunc(i.ALWAYS);break;case Sc:i.depthFunc(i.LESS);break;case ks:i.depthFunc(i.LEQUAL);break;case Ec:i.depthFunc(i.EQUAL);break;case bc:i.depthFunc(i.GEQUAL);break;case wc:i.depthFunc(i.GREATER);break;case Ac:i.depthFunc(i.NOTEQUAL);break;default:i.depthFunc(i.LEQUAL)}ht=tt}},setLocked:function(tt){P=tt},setClear:function(tt){gt!==tt&&(gt=tt,at&&(tt=1-tt),i.clearDepth(tt))},reset:function(){P=!1,J=null,ht=null,gt=null,at=!1}}}function s(){let P=!1,at=null,J=null,ht=null,gt=null,tt=null,wt=null,yt=null,ve=null;return{setTest:function(oe){P||(oe?nt(i.STENCIL_TEST):z(i.STENCIL_TEST))},setMask:function(oe){at!==oe&&!P&&(i.stencilMask(oe),at=oe)},setFunc:function(oe,Dn,Pn){(J!==oe||ht!==Dn||gt!==Pn)&&(i.stencilFunc(oe,Dn,Pn),J=oe,ht=Dn,gt=Pn)},setOp:function(oe,Dn,Pn){(tt!==oe||wt!==Dn||yt!==Pn)&&(i.stencilOp(oe,Dn,Pn),tt=oe,wt=Dn,yt=Pn)},setLocked:function(oe){P=oe},setClear:function(oe){ve!==oe&&(i.clearStencil(oe),ve=oe)},reset:function(){P=!1,at=null,J=null,ht=null,gt=null,tt=null,wt=null,yt=null,ve=null}}}const r=new e,a=new n,o=new s,c=new WeakMap,l=new WeakMap;let h={},u={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,w=null,A=null,M=null,S=null,b=null,R=null,_=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null;const q=i.getParameter(i.MAX_COMBINED_TEXTURE_IMAGE_UNITS);let H=!1,$=0;const et=i.getParameter(i.VERSION);et.indexOf("WebGL")!==-1?($=parseFloat(/^WebGL (\d)/.exec(et)[1]),H=$>=1):et.indexOf("OpenGL ES")!==-1&&($=parseFloat(/^OpenGL ES (\d)/.exec(et)[1]),H=$>=2);let j=null,it={};const ut=i.getParameter(i.SCISSOR_BOX),kt=i.getParameter(i.VIEWPORT),qt=new pe().fromArray(ut),Bt=new pe().fromArray(kt);function Y(P,at,J,ht){const gt=new Uint8Array(4),tt=i.createTexture();i.bindTexture(P,tt),i.texParameteri(P,i.TEXTURE_MIN_FILTER,i.NEAREST),i.texParameteri(P,i.TEXTURE_MAG_FILTER,i.NEAREST);for(let wt=0;wt<J;wt++)P===i.TEXTURE_3D||P===i.TEXTURE_2D_ARRAY?i.texImage3D(at,0,i.RGBA,1,1,ht,0,i.RGBA,i.UNSIGNED_BYTE,gt):i.texImage2D(at+wt,0,i.RGBA,1,1,0,i.RGBA,i.UNSIGNED_BYTE,gt);return tt}const rt={};rt[i.TEXTURE_2D]=Y(i.TEXTURE_2D,i.TEXTURE_2D,1),rt[i.TEXTURE_CUBE_MAP]=Y(i.TEXTURE_CUBE_MAP,i.TEXTURE_CUBE_MAP_POSITIVE_X,6),rt[i.TEXTURE_2D_ARRAY]=Y(i.TEXTURE_2D_ARRAY,i.TEXTURE_2D_ARRAY,1,1),rt[i.TEXTURE_3D]=Y(i.TEXTURE_3D,i.TEXTURE_3D,1,1),r.setClear(0,0,0,1),a.setClear(1),o.setClear(0),nt(i.DEPTH_TEST),a.setFunc(ks),Jt(!1),Qt(Nh),nt(i.CULL_FACE),Lt(si);function nt(P){h[P]!==!0&&(i.enable(P),h[P]=!0)}function z(P){h[P]!==!1&&(i.disable(P),h[P]=!1)}function bt(P,at){return d[P]!==at?(i.bindFramebuffer(P,at),d[P]=at,P===i.DRAW_FRAMEBUFFER&&(d[i.FRAMEBUFFER]=at),P===i.FRAMEBUFFER&&(d[i.DRAW_FRAMEBUFFER]=at),!0):!1}function Dt(P,at){let J=g,ht=!1;if(P){J=f.get(at),J===void 0&&(J=[],f.set(at,J));const gt=P.textures;if(J.length!==gt.length||J[0]!==i.COLOR_ATTACHMENT0){for(let tt=0,wt=gt.length;tt<wt;tt++)J[tt]=i.COLOR_ATTACHMENT0+tt;J.length=gt.length,ht=!0}}else J[0]!==i.BACK&&(J[0]=i.BACK,ht=!0);ht&&i.drawBuffers(J)}function At(P){return x!==P?(i.useProgram(P),x=P,!0):!1}const _t={[Gi]:i.FUNC_ADD,[xp]:i.FUNC_SUBTRACT,[Mp]:i.FUNC_REVERSE_SUBTRACT};_t[yp]=i.MIN,_t[Sp]=i.MAX;const It={[Ep]:i.ZERO,[bp]:i.ONE,[wp]:i.SRC_COLOR,[_c]:i.SRC_ALPHA,[Pp]:i.SRC_ALPHA_SATURATE,[Cp]:i.DST_COLOR,[Tp]:i.DST_ALPHA,[Ap]:i.ONE_MINUS_SRC_COLOR,[xc]:i.ONE_MINUS_SRC_ALPHA,[Dp]:i.ONE_MINUS_DST_COLOR,[Rp]:i.ONE_MINUS_DST_ALPHA,[Ip]:i.CONSTANT_COLOR,[Lp]:i.ONE_MINUS_CONSTANT_COLOR,[Np]:i.CONSTANT_ALPHA,[Up]:i.ONE_MINUS_CONSTANT_ALPHA};function Lt(P,at,J,ht,gt,tt,wt,yt,ve,oe){if(P===si){m===!0&&(z(i.BLEND),m=!1);return}if(m===!1&&(nt(i.BLEND),m=!0),P!==_p){if(P!==p||oe!==D){if((w!==Gi||S!==Gi)&&(i.blendEquation(i.FUNC_ADD),w=Gi,S=Gi),oe)switch(P){case Is:i.blendFuncSeparate(i.ONE,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ri:i.blendFunc(i.ONE,i.ONE);break;case Uh:i.blendFuncSeparate(i.ZERO,i.ONE_MINUS_SRC_COLOR,i.ZERO,i.ONE);break;case Fh:i.blendFuncSeparate(i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ZERO,i.ONE);break;default:Yt("WebGLState: Invalid blending: ",P);break}else switch(P){case Is:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA);break;case Ri:i.blendFuncSeparate(i.SRC_ALPHA,i.ONE,i.ONE,i.ONE);break;case Uh:Yt("WebGLState: SubtractiveBlending requires material.premultipliedAlpha = true");break;case Fh:Yt("WebGLState: MultiplyBlending requires material.premultipliedAlpha = true");break;default:Yt("WebGLState: Invalid blending: ",P);break}A=null,M=null,b=null,R=null,_.set(0,0,0),E=0,p=P,D=oe}return}gt=gt||at,tt=tt||J,wt=wt||ht,(at!==w||gt!==S)&&(i.blendEquationSeparate(_t[at],_t[gt]),w=at,S=gt),(J!==A||ht!==M||tt!==b||wt!==R)&&(i.blendFuncSeparate(It[J],It[ht],It[tt],It[wt]),A=J,M=ht,b=tt,R=wt),(yt.equals(_)===!1||ve!==E)&&(i.blendColor(yt.r,yt.g,yt.b,ve),_.copy(yt),E=ve),p=P,D=!1}function Nt(P,at){P.side===wn?z(i.CULL_FACE):nt(i.CULL_FACE);let J=P.side===Ce;at&&(J=!J),Jt(J),P.blending===Is&&P.transparent===!1?Lt(si):Lt(P.blending,P.blendEquation,P.blendSrc,P.blendDst,P.blendEquationAlpha,P.blendSrcAlpha,P.blendDstAlpha,P.blendColor,P.blendAlpha,P.premultipliedAlpha),a.setFunc(P.depthFunc),a.setTest(P.depthTest),a.setMask(P.depthWrite),r.setMask(P.colorWrite);const ht=P.stencilWrite;o.setTest(ht),ht&&(o.setMask(P.stencilWriteMask),o.setFunc(P.stencilFunc,P.stencilRef,P.stencilFuncMask),o.setOp(P.stencilFail,P.stencilZFail,P.stencilZPass)),de(P.polygonOffset,P.polygonOffsetFactor,P.polygonOffsetUnits),P.alphaToCoverage===!0?nt(i.SAMPLE_ALPHA_TO_COVERAGE):z(i.SAMPLE_ALPHA_TO_COVERAGE)}function Jt(P){C!==P&&(P?i.frontFace(i.CW):i.frontFace(i.CCW),C=P)}function Qt(P){P!==mp?(nt(i.CULL_FACE),P!==I&&(P===Nh?i.cullFace(i.BACK):P===gp?i.cullFace(i.FRONT):i.cullFace(i.FRONT_AND_BACK))):z(i.CULL_FACE),I=P}function me(P){P!==W&&(H&&i.lineWidth(P),W=P)}function de(P,at,J){P?(nt(i.POLYGON_OFFSET_FILL),(X!==at||U!==J)&&(X=at,U=J,a.getReversed()&&(at=-at),i.polygonOffset(at,J))):z(i.POLYGON_OFFSET_FILL)}function ge(P){P?nt(i.SCISSOR_TEST):z(i.SCISSOR_TEST)}function be(P){P===void 0&&(P=i.TEXTURE0+q-1),j!==P&&(i.activeTexture(P),j=P)}function L(P,at,J){J===void 0&&(j===null?J=i.TEXTURE0+q-1:J=j);let ht=it[J];ht===void 0&&(ht={type:void 0,texture:void 0},it[J]=ht),(ht.type!==P||ht.texture!==at)&&(j!==J&&(i.activeTexture(J),j=J),i.bindTexture(P,at||rt[P]),ht.type=P,ht.texture=at)}function Je(){const P=it[j];P!==void 0&&P.type!==void 0&&(i.bindTexture(P.type,null),P.type=void 0,P.texture=void 0)}function jt(){try{i.compressedTexImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function T(){try{i.compressedTexImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function v(){try{i.texSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function O(){try{i.texSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function G(){try{i.compressedTexSubImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function K(){try{i.compressedTexSubImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function st(){try{i.texStorage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ot(){try{i.texStorage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Z(){try{i.texImage2D(...arguments)}catch(P){Yt("WebGLState:",P)}}function Q(){try{i.texImage3D(...arguments)}catch(P){Yt("WebGLState:",P)}}function ct(P){return u[P]!==void 0?u[P]:i.getParameter(P)}function Tt(P,at){u[P]!==at&&(i.pixelStorei(P,at),u[P]=at)}function dt(P){qt.equals(P)===!1&&(i.scissor(P.x,P.y,P.z,P.w),qt.copy(P))}function lt(P){Bt.equals(P)===!1&&(i.viewport(P.x,P.y,P.z,P.w),Bt.copy(P))}function Pt(P,at){let J=l.get(at);J===void 0&&(J=new WeakMap,l.set(at,J));let ht=J.get(P);ht===void 0&&(ht=i.getUniformBlockIndex(at,P.name),J.set(P,ht))}function Ut(P,at){const ht=l.get(at).get(P);c.get(at)!==ht&&(i.uniformBlockBinding(at,ht,P.__bindingPointIndex),c.set(at,ht))}function Gt(){i.disable(i.BLEND),i.disable(i.CULL_FACE),i.disable(i.DEPTH_TEST),i.disable(i.POLYGON_OFFSET_FILL),i.disable(i.SCISSOR_TEST),i.disable(i.STENCIL_TEST),i.disable(i.SAMPLE_ALPHA_TO_COVERAGE),i.blendEquation(i.FUNC_ADD),i.blendFunc(i.ONE,i.ZERO),i.blendFuncSeparate(i.ONE,i.ZERO,i.ONE,i.ZERO),i.blendColor(0,0,0,0),i.colorMask(!0,!0,!0,!0),i.clearColor(0,0,0,0),i.depthMask(!0),i.depthFunc(i.LESS),a.setReversed(!1),i.clearDepth(1),i.stencilMask(4294967295),i.stencilFunc(i.ALWAYS,0,4294967295),i.stencilOp(i.KEEP,i.KEEP,i.KEEP),i.clearStencil(0),i.cullFace(i.BACK),i.frontFace(i.CCW),i.polygonOffset(0,0),i.activeTexture(i.TEXTURE0),i.bindFramebuffer(i.FRAMEBUFFER,null),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),i.bindFramebuffer(i.READ_FRAMEBUFFER,null),i.useProgram(null),i.lineWidth(1),i.scissor(0,0,i.canvas.width,i.canvas.height),i.viewport(0,0,i.canvas.width,i.canvas.height),i.pixelStorei(i.PACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_ALIGNMENT,4),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,!1),i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),i.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,i.BROWSER_DEFAULT_WEBGL),i.pixelStorei(i.PACK_ROW_LENGTH,0),i.pixelStorei(i.PACK_SKIP_PIXELS,0),i.pixelStorei(i.PACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_ROW_LENGTH,0),i.pixelStorei(i.UNPACK_IMAGE_HEIGHT,0),i.pixelStorei(i.UNPACK_SKIP_PIXELS,0),i.pixelStorei(i.UNPACK_SKIP_ROWS,0),i.pixelStorei(i.UNPACK_SKIP_IMAGES,0),h={},u={},j=null,it={},d={},f=new WeakMap,g=[],x=null,m=!1,p=null,w=null,A=null,M=null,S=null,b=null,R=null,_=new Mt(0,0,0),E=0,D=!1,C=null,I=null,W=null,X=null,U=null,qt.set(0,0,i.canvas.width,i.canvas.height),Bt.set(0,0,i.canvas.width,i.canvas.height),r.reset(),a.reset(),o.reset()}return{buffers:{color:r,depth:a,stencil:o},enable:nt,disable:z,bindFramebuffer:bt,drawBuffers:Dt,useProgram:At,setBlending:Lt,setMaterial:Nt,setFlipSided:Jt,setCullFace:Qt,setLineWidth:me,setPolygonOffset:de,setScissorTest:ge,activeTexture:be,bindTexture:L,unbindTexture:Je,compressedTexImage2D:jt,compressedTexImage3D:T,texImage2D:Z,texImage3D:Q,pixelStorei:Tt,getParameter:ct,updateUBOMapping:Pt,uniformBlockBinding:Ut,texStorage2D:st,texStorage3D:ot,texSubImage2D:v,texSubImage3D:O,compressedTexSubImage2D:G,compressedTexSubImage3D:K,scissor:dt,viewport:lt,reset:Gt}}function S_(i,t,e,n,s,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 Ft,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 x(T,v){return g?new OffscreenCanvas(T,v):ka("canvas")}function m(T,v,O){let G=1;const K=jt(T);if((K.width>O||K.height>O)&&(G=O/Math.max(K.width,K.height)),G<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(G*K.width),ot=Math.floor(G*K.height);d===void 0&&(d=x(st,ot));const Z=v?x(st,ot):d;return Z.width=st,Z.height=ot,Z.getContext("2d").drawImage(T,0,0,st,ot),Ot("WebGLRenderer: Texture has been resized from ("+K.width+"x"+K.height+") to ("+st+"x"+ot+")."),Z}else return"data"in T&&Ot("WebGLRenderer: Image in DataTexture is too big ("+K.width+"x"+K.height+")."),T;return T}function p(T){return T.generateMipmaps}function w(T){i.generateMipmap(T)}function A(T){return T.isWebGLCubeRenderTarget?i.TEXTURE_CUBE_MAP:T.isWebGL3DRenderTarget?i.TEXTURE_3D:T.isWebGLArrayRenderTarget||T.isCompressedArrayTexture?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D}function M(T,v,O,G,K,st=!1){if(T!==null){if(i[T]!==void 0)return i[T];Ot("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+T+"'")}let ot;G&&(ot=t.get("EXT_texture_norm16"),ot||Ot("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let Z=v;if(v===i.RED&&(O===i.FLOAT&&(Z=i.R32F),O===i.HALF_FLOAT&&(Z=i.R16F),O===i.UNSIGNED_BYTE&&(Z=i.R8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.R16_EXT),O===i.SHORT&&ot&&(Z=ot.R16_SNORM_EXT)),v===i.RED_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.R8UI),O===i.UNSIGNED_SHORT&&(Z=i.R16UI),O===i.UNSIGNED_INT&&(Z=i.R32UI),O===i.BYTE&&(Z=i.R8I),O===i.SHORT&&(Z=i.R16I),O===i.INT&&(Z=i.R32I)),v===i.RG&&(O===i.FLOAT&&(Z=i.RG32F),O===i.HALF_FLOAT&&(Z=i.RG16F),O===i.UNSIGNED_BYTE&&(Z=i.RG8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RG16_EXT),O===i.SHORT&&ot&&(Z=ot.RG16_SNORM_EXT)),v===i.RG_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RG8UI),O===i.UNSIGNED_SHORT&&(Z=i.RG16UI),O===i.UNSIGNED_INT&&(Z=i.RG32UI),O===i.BYTE&&(Z=i.RG8I),O===i.SHORT&&(Z=i.RG16I),O===i.INT&&(Z=i.RG32I)),v===i.RGB_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGB8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGB16UI),O===i.UNSIGNED_INT&&(Z=i.RGB32UI),O===i.BYTE&&(Z=i.RGB8I),O===i.SHORT&&(Z=i.RGB16I),O===i.INT&&(Z=i.RGB32I)),v===i.RGBA_INTEGER&&(O===i.UNSIGNED_BYTE&&(Z=i.RGBA8UI),O===i.UNSIGNED_SHORT&&(Z=i.RGBA16UI),O===i.UNSIGNED_INT&&(Z=i.RGBA32UI),O===i.BYTE&&(Z=i.RGBA8I),O===i.SHORT&&(Z=i.RGBA16I),O===i.INT&&(Z=i.RGBA32I)),v===i.RGB&&(O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGB16_EXT),O===i.SHORT&&ot&&(Z=ot.RGB16_SNORM_EXT),O===i.UNSIGNED_INT_5_9_9_9_REV&&(Z=i.RGB9_E5),O===i.UNSIGNED_INT_10F_11F_11F_REV&&(Z=i.R11F_G11F_B10F)),v===i.RGBA){const Q=st?Ba:Kt.getTransfer(K);O===i.FLOAT&&(Z=i.RGBA32F),O===i.HALF_FLOAT&&(Z=i.RGBA16F),O===i.UNSIGNED_BYTE&&(Z=Q===te?i.SRGB8_ALPHA8:i.RGBA8),O===i.UNSIGNED_SHORT&&ot&&(Z=ot.RGBA16_EXT),O===i.SHORT&&ot&&(Z=ot.RGBA16_SNORM_EXT),O===i.UNSIGNED_SHORT_4_4_4_4&&(Z=i.RGBA4),O===i.UNSIGNED_SHORT_5_5_5_1&&(Z=i.RGB5_A1)}return(Z===i.R16F||Z===i.R32F||Z===i.RG16F||Z===i.RG32F||Z===i.RGBA16F||Z===i.RGBA32F)&&t.get("EXT_color_buffer_float"),Z}function S(T,v){let O;return T?v===null||v===Kn||v===Sr?O=i.DEPTH24_STENCIL8:v===Vn?O=i.DEPTH32F_STENCIL8:v===yr&&(O=i.DEPTH24_STENCIL8,Ot("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===Kn||v===Sr?O=i.DEPTH_COMPONENT24:v===Vn?O=i.DEPTH_COMPONENT32F:v===yr&&(O=i.DEPTH_COMPONENT16),O}function b(T,v){return p(T)===!0||T.isFramebufferTexture&&T.minFilter!==ke&&T.minFilter!==Te?Math.log2(Math.max(v.width,v.height))+1:T.mipmaps!==void 0&&T.mipmaps.length>0?T.mipmaps.length:T.isCompressedTexture&&Array.isArray(T.image)?v.mipmaps.length:1}function R(T){const v=T.target;v.removeEventListener("dispose",R),E(v),v.isVideoTexture&&h.delete(v),v.isHTMLTexture&&u.delete(v)}function _(T){const v=T.target;v.removeEventListener("dispose",_),C(v)}function E(T){const v=n.get(T);if(v.__webglInit===void 0)return;const O=T.source,G=f.get(O);if(G){const K=G[v.__cacheKey];K.usedTimes--,K.usedTimes===0&&D(T),Object.keys(G).length===0&&f.delete(O)}n.remove(T)}function D(T){const v=n.get(T);i.deleteTexture(v.__webglTexture);const O=T.source,G=f.get(O);delete G[v.__cacheKey],a.memory.textures--}function C(T){const v=n.get(T);if(T.depthTexture&&(T.depthTexture.dispose(),n.remove(T.depthTexture)),T.isWebGLCubeRenderTarget)for(let G=0;G<6;G++){if(Array.isArray(v.__webglFramebuffer[G]))for(let K=0;K<v.__webglFramebuffer[G].length;K++)i.deleteFramebuffer(v.__webglFramebuffer[G][K]);else i.deleteFramebuffer(v.__webglFramebuffer[G]);v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer[G])}else{if(Array.isArray(v.__webglFramebuffer))for(let G=0;G<v.__webglFramebuffer.length;G++)i.deleteFramebuffer(v.__webglFramebuffer[G]);else i.deleteFramebuffer(v.__webglFramebuffer);if(v.__webglDepthbuffer&&i.deleteRenderbuffer(v.__webglDepthbuffer),v.__webglMultisampledFramebuffer&&i.deleteFramebuffer(v.__webglMultisampledFramebuffer),v.__webglColorRenderbuffer)for(let G=0;G<v.__webglColorRenderbuffer.length;G++)v.__webglColorRenderbuffer[G]&&i.deleteRenderbuffer(v.__webglColorRenderbuffer[G]);v.__webglDepthRenderbuffer&&i.deleteRenderbuffer(v.__webglDepthRenderbuffer)}const O=T.textures;for(let G=0,K=O.length;G<K;G++){const st=n.get(O[G]);st.__webglTexture&&(i.deleteTexture(st.__webglTexture),a.memory.textures--),n.remove(O[G])}n.remove(T)}let I=0;function W(){I=0}function X(){return I}function U(T){I=T}function q(){const T=I;return T>=s.maxTextures&&Ot("WebGLTextures: Trying to use "+T+" texture units while this GPU supports only "+s.maxTextures),I+=1,T}function H(T){const v=[];return v.push(T.wrapS),v.push(T.wrapT),v.push(T.wrapR||0),v.push(T.magFilter),v.push(T.minFilter),v.push(T.anisotropy),v.push(T.internalFormat),v.push(T.format),v.push(T.type),v.push(T.generateMipmaps),v.push(T.premultiplyAlpha),v.push(T.flipY),v.push(T.unpackAlignment),v.push(T.colorSpace),v.join()}function $(T,v){const O=n.get(T);if(T.isVideoTexture&&L(T),T.isRenderTargetTexture===!1&&T.isExternalTexture!==!0&&T.version>0&&O.__version!==T.version){const G=T.image;if(G===null)Ot("WebGLRenderer: Texture marked for update but no image data found.");else if(G.complete===!1)Ot("WebGLRenderer: Texture marked for update but image is incomplete");else{z(O,T,v);return}}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(i.TEXTURE_2D,O.__webglTexture,i.TEXTURE0+v)}function et(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}else T.isExternalTexture&&(O.__webglTexture=T.sourceTexture?T.sourceTexture:null);e.bindTexture(i.TEXTURE_2D_ARRAY,O.__webglTexture,i.TEXTURE0+v)}function j(T,v){const O=n.get(T);if(T.isRenderTargetTexture===!1&&T.version>0&&O.__version!==T.version){z(O,T,v);return}e.bindTexture(i.TEXTURE_3D,O.__webglTexture,i.TEXTURE0+v)}function it(T,v){const O=n.get(T);if(T.isCubeDepthTexture!==!0&&T.version>0&&O.__version!==T.version){bt(O,T,v);return}e.bindTexture(i.TEXTURE_CUBE_MAP,O.__webglTexture,i.TEXTURE0+v)}const ut={[Tc]:i.REPEAT,[hn]:i.CLAMP_TO_EDGE,[Rc]:i.MIRRORED_REPEAT},kt={[ke]:i.NEAREST,[zp]:i.NEAREST_MIPMAP_NEAREST,[Fr]:i.NEAREST_MIPMAP_LINEAR,[Te]:i.LINEAR,[mo]:i.LINEAR_MIPMAP_NEAREST,[Xi]:i.LINEAR_MIPMAP_LINEAR},qt={[Gp]:i.NEVER,[qp]:i.ALWAYS,[Hp]:i.LESS,[Yl]:i.LEQUAL,[Vp]:i.EQUAL,[Kl]:i.GEQUAL,[Wp]:i.GREATER,[Xp]:i.NOTEQUAL};function Bt(T,v){if(v.type===Vn&&t.has("OES_texture_float_linear")===!1&&(v.magFilter===Te||v.magFilter===mo||v.magFilter===Fr||v.magFilter===Xi||v.minFilter===Te||v.minFilter===mo||v.minFilter===Fr||v.minFilter===Xi)&&Ot("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),i.texParameteri(T,i.TEXTURE_WRAP_S,ut[v.wrapS]),i.texParameteri(T,i.TEXTURE_WRAP_T,ut[v.wrapT]),(T===i.TEXTURE_3D||T===i.TEXTURE_2D_ARRAY)&&i.texParameteri(T,i.TEXTURE_WRAP_R,ut[v.wrapR]),i.texParameteri(T,i.TEXTURE_MAG_FILTER,kt[v.magFilter]),i.texParameteri(T,i.TEXTURE_MIN_FILTER,kt[v.minFilter]),v.compareFunction&&(i.texParameteri(T,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE),i.texParameteri(T,i.TEXTURE_COMPARE_FUNC,qt[v.compareFunction])),t.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===ke||v.minFilter!==Fr&&v.minFilter!==Xi||v.type===Vn&&t.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||n.get(v).__currentAnisotropy){const O=t.get("EXT_texture_filter_anisotropic");i.texParameterf(T,O.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),n.get(v).__currentAnisotropy=v.anisotropy}}}function Y(T,v){let O=!1;T.__webglInit===void 0&&(T.__webglInit=!0,v.addEventListener("dispose",R));const G=v.source;let K=f.get(G);K===void 0&&(K={},f.set(G,K));const st=H(v);if(st!==T.__cacheKey){K[st]===void 0&&(K[st]={texture:i.createTexture(),usedTimes:0},a.memory.textures++,O=!0),K[st].usedTimes++;const ot=K[T.__cacheKey];ot!==void 0&&(K[T.__cacheKey].usedTimes--,ot.usedTimes===0&&D(v)),T.__cacheKey=st,T.__webglTexture=K[st].texture}return O}function rt(T,v,O){return Math.floor(Math.floor(T/O)/v)}function nt(T,v,O,G){const st=T.updateRanges;if(st.length===0)e.texSubImage2D(i.TEXTURE_2D,0,0,0,v.width,v.height,O,G,v.data);else{st.sort((Tt,dt)=>Tt.start-dt.start);let ot=0;for(let Tt=1;Tt<st.length;Tt++){const dt=st[ot],lt=st[Tt],Pt=dt.start+dt.count,Ut=rt(lt.start,v.width,4),Gt=rt(dt.start,v.width,4);lt.start<=Pt+1&&Ut===Gt&&rt(lt.start+lt.count-1,v.width,4)===Ut?dt.count=Math.max(dt.count,lt.start+lt.count-dt.start):(++ot,st[ot]=lt)}st.length=ot+1;const Z=e.getParameter(i.UNPACK_ROW_LENGTH),Q=e.getParameter(i.UNPACK_SKIP_PIXELS),ct=e.getParameter(i.UNPACK_SKIP_ROWS);e.pixelStorei(i.UNPACK_ROW_LENGTH,v.width);for(let Tt=0,dt=st.length;Tt<dt;Tt++){const lt=st[Tt],Pt=Math.floor(lt.start/4),Ut=Math.ceil(lt.count/4),Gt=Pt%v.width,P=Math.floor(Pt/v.width),at=Ut,J=1;e.pixelStorei(i.UNPACK_SKIP_PIXELS,Gt),e.pixelStorei(i.UNPACK_SKIP_ROWS,P),e.texSubImage2D(i.TEXTURE_2D,0,Gt,P,at,J,O,G,v.data)}T.clearUpdateRanges(),e.pixelStorei(i.UNPACK_ROW_LENGTH,Z),e.pixelStorei(i.UNPACK_SKIP_PIXELS,Q),e.pixelStorei(i.UNPACK_SKIP_ROWS,ct)}}function z(T,v,O){let G=i.TEXTURE_2D;(v.isDataArrayTexture||v.isCompressedArrayTexture)&&(G=i.TEXTURE_2D_ARRAY),v.isData3DTexture&&(G=i.TEXTURE_3D);const K=Y(T,v),st=v.source;e.bindTexture(G,T.__webglTexture,i.TEXTURE0+O);const ot=n.get(st);if(st.version!==ot.__version||K===!0){if(e.activeTexture(i.TEXTURE0+O),(typeof ImageBitmap<"u"&&v.image instanceof ImageBitmap)===!1){const J=Kt.getPrimaries(Kt.workingColorSpace),ht=v.colorSpace===Si?null:Kt.getPrimaries(v.colorSpace),gt=v.colorSpace===Si||J===ht?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,gt)}e.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment);let Q=m(v.image,!1,s.maxTextureSize);Q=Je(v,Q);const ct=r.convert(v.format,v.colorSpace),Tt=r.convert(v.type);let dt=M(v.internalFormat,ct,Tt,v.normalized,v.colorSpace,v.isVideoTexture);Bt(G,v);let lt;const Pt=v.mipmaps,Ut=v.isVideoTexture!==!0,Gt=ot.__version===void 0||K===!0,P=st.dataReady,at=b(v,Q);if(v.isDepthTexture)dt=S(v.format===qi,v.type),Gt&&(Ut?e.texStorage2D(i.TEXTURE_2D,1,dt,Q.width,Q.height):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Tt,null));else if(v.isDataTexture)if(Pt.length>0){Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Tt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Tt,lt.data);v.generateMipmaps=!1}else Ut?(Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Q.width,Q.height),P&&nt(v,Q,ct,Tt)):e.texImage2D(i.TEXTURE_2D,0,dt,Q.width,Q.height,0,ct,Tt,Q.data);else if(v.isCompressedTexture)if(v.isCompressedArrayTexture){Ut&&Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Pt[0].width,Pt[0].height,Q.depth);for(let J=0,ht=Pt.length;J<ht;J++)if(lt=Pt[J],v.format!==un)if(ct!==null)if(Ut){if(P)if(v.layerUpdates.size>0){const gt=uu(lt.width,lt.height,v.format,v.type);for(const tt of v.layerUpdates){const wt=lt.data.subarray(tt*gt/lt.data.BYTES_PER_ELEMENT,(tt+1)*gt/lt.data.BYTES_PER_ELEMENT);e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,tt,lt.width,lt.height,1,ct,wt)}v.clearLayerUpdates()}else e.compressedTexSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,lt.data)}else e.compressedTexImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,lt.data,0,0);else Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else Ut?P&&e.texSubImage3D(i.TEXTURE_2D_ARRAY,J,0,0,0,lt.width,lt.height,Q.depth,ct,Tt,lt.data):e.texImage3D(i.TEXTURE_2D_ARRAY,J,dt,lt.width,lt.height,Q.depth,0,ct,Tt,lt.data)}else{Ut&&Gt&&e.texStorage2D(i.TEXTURE_2D,at,dt,Pt[0].width,Pt[0].height);for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],v.format!==un?ct!==null?Ut?P&&e.compressedTexSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,lt.data):e.compressedTexImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,lt.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,lt.width,lt.height,ct,Tt,lt.data):e.texImage2D(i.TEXTURE_2D,J,dt,lt.width,lt.height,0,ct,Tt,lt.data)}else if(v.isDataArrayTexture)if(Ut){if(Gt&&e.texStorage3D(i.TEXTURE_2D_ARRAY,at,dt,Q.width,Q.height,Q.depth),P)if(v.layerUpdates.size>0){const J=uu(Q.width,Q.height,v.format,v.type);for(const ht of v.layerUpdates){const gt=Q.data.subarray(ht*J/Q.data.BYTES_PER_ELEMENT,(ht+1)*J/Q.data.BYTES_PER_ELEMENT);e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,ht,Q.width,Q.height,1,ct,Tt,gt)}v.clearLayerUpdates()}else e.texSubImage3D(i.TEXTURE_2D_ARRAY,0,0,0,0,Q.width,Q.height,Q.depth,ct,Tt,Q.data)}else e.texImage3D(i.TEXTURE_2D_ARRAY,0,dt,Q.width,Q.height,Q.depth,0,ct,Tt,Q.data);else if(v.isData3DTexture)Ut?(Gt&&e.texStorage3D(i.TEXTURE_3D,at,dt,Q.width,Q.height,Q.depth),P&&e.texSubImage3D(i.TEXTURE_3D,0,0,0,0,Q.width,Q.height,Q.depth,ct,Tt,Q.data)):e.texImage3D(i.TEXTURE_3D,0,dt,Q.width,Q.height,Q.depth,0,ct,Tt,Q.data);else if(v.isFramebufferTexture){if(Gt)if(Ut)e.texStorage2D(i.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(i.TEXTURE_2D,gt,dt,J,ht,0,ct,Tt,null),J>>=1,ht>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in i){const J=i.canvas;if(J.hasAttribute("layoutsubtree")||J.setAttribute("layoutsubtree","true"),Q.parentNode!==J){J.appendChild(Q),u.add(v),J.onpaint=ht=>{const gt=ht.changedElements;for(const tt of u)gt.includes(tt.image)&&(tt.needsUpdate=!0)},J.requestPaint();return}if(i.texElementImage2D.length===3)i.texElementImage2D(i.TEXTURE_2D,i.RGBA8,Q);else{const gt=i.RGBA,tt=i.RGBA,wt=i.UNSIGNED_BYTE;i.texElementImage2D(i.TEXTURE_2D,0,gt,tt,wt,Q)}i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE)}}else if(Pt.length>0){if(Ut&&Gt){const J=jt(Pt[0]);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}for(let J=0,ht=Pt.length;J<ht;J++)lt=Pt[J],Ut?P&&e.texSubImage2D(i.TEXTURE_2D,J,0,0,ct,Tt,lt):e.texImage2D(i.TEXTURE_2D,J,dt,ct,Tt,lt);v.generateMipmaps=!1}else if(Ut){if(Gt){const J=jt(Q);e.texStorage2D(i.TEXTURE_2D,at,dt,J.width,J.height)}P&&e.texSubImage2D(i.TEXTURE_2D,0,0,0,ct,Tt,Q)}else e.texImage2D(i.TEXTURE_2D,0,dt,ct,Tt,Q);p(v)&&w(G),ot.__version=st.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function bt(T,v,O){if(v.image.length!==6)return;const G=Y(T,v),K=v.source;e.bindTexture(i.TEXTURE_CUBE_MAP,T.__webglTexture,i.TEXTURE0+O);const st=n.get(K);if(K.version!==st.__version||G===!0){e.activeTexture(i.TEXTURE0+O);const ot=Kt.getPrimaries(Kt.workingColorSpace),Z=v.colorSpace===Si?null:Kt.getPrimaries(v.colorSpace),Q=v.colorSpace===Si||ot===Z?i.NONE:i.BROWSER_DEFAULT_WEBGL;e.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,v.flipY),e.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,v.premultiplyAlpha),e.pixelStorei(i.UNPACK_ALIGNMENT,v.unpackAlignment),e.pixelStorei(i.UNPACK_COLORSPACE_CONVERSION_WEBGL,Q);const ct=v.isCompressedTexture||v.image[0].isCompressedTexture,Tt=v.image[0]&&v.image[0].isDataTexture,dt=[];for(let tt=0;tt<6;tt++)!ct&&!Tt?dt[tt]=m(v.image[tt],!0,s.maxCubemapSize):dt[tt]=Tt?v.image[tt].image:v.image[tt],dt[tt]=Je(v,dt[tt]);const lt=dt[0],Pt=r.convert(v.format,v.colorSpace),Ut=r.convert(v.type),Gt=M(v.internalFormat,Pt,Ut,v.normalized,v.colorSpace),P=v.isVideoTexture!==!0,at=st.__version===void 0||G===!0,J=K.dataReady;let ht=b(v,lt);Bt(i.TEXTURE_CUBE_MAP,v);let gt;if(ct){P&&at&&e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,lt.width,lt.height);for(let tt=0;tt<6;tt++){gt=dt[tt].mipmaps;for(let wt=0;wt<gt.length;wt++){const yt=gt[wt];v.format!==un?Pt!==null?P?J&&e.compressedTexSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,0,0,yt.width,yt.height,Pt,yt.data):e.compressedTexImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,Gt,yt.width,yt.height,0,yt.data):Ot("WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()"):P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,0,0,yt.width,yt.height,Pt,Ut,yt.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt,Gt,yt.width,yt.height,0,Pt,Ut,yt.data)}}}else{if(gt=v.mipmaps,P&&at){gt.length>0&&ht++;const tt=jt(dt[0]);e.texStorage2D(i.TEXTURE_CUBE_MAP,ht,Gt,tt.width,tt.height)}for(let tt=0;tt<6;tt++)if(Tt){P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,dt[tt].width,dt[tt].height,Pt,Ut,dt[tt].data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,dt[tt].width,dt[tt].height,0,Pt,Ut,dt[tt].data);for(let wt=0;wt<gt.length;wt++){const ve=gt[wt].image[tt].image;P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,0,0,ve.width,ve.height,Pt,Ut,ve.data):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,Gt,ve.width,ve.height,0,Pt,Ut,ve.data)}}else{P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,0,0,Pt,Ut,dt[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,0,Gt,Pt,Ut,dt[tt]);for(let wt=0;wt<gt.length;wt++){const yt=gt[wt];P?J&&e.texSubImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,0,0,Pt,Ut,yt.image[tt]):e.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+tt,wt+1,Gt,Pt,Ut,yt.image[tt])}}}p(v)&&w(i.TEXTURE_CUBE_MAP),st.__version=K.version,v.onUpdate&&v.onUpdate(v)}T.__version=v.version}function Dt(T,v,O,G,K,st){const ot=r.convert(O.format,O.colorSpace),Z=r.convert(O.type),Q=M(O.internalFormat,ot,Z,O.normalized,O.colorSpace),ct=n.get(v),Tt=n.get(O);if(Tt.__renderTarget=v,!ct.__hasExternalTextures){const dt=Math.max(1,v.width>>st),lt=Math.max(1,v.height>>st);K===i.TEXTURE_3D||K===i.TEXTURE_2D_ARRAY?e.texImage3D(K,st,Q,dt,lt,v.depth,0,ot,Z,null):e.texImage2D(K,st,Q,dt,lt,0,ot,Z,null)}e.bindFramebuffer(i.FRAMEBUFFER,T),be(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,G,K,Tt.__webglTexture,0,ge(v)):(K===i.TEXTURE_2D||K>=i.TEXTURE_CUBE_MAP_POSITIVE_X&&K<=i.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&i.framebufferTexture2D(i.FRAMEBUFFER,G,K,Tt.__webglTexture,st),e.bindFramebuffer(i.FRAMEBUFFER,null)}function At(T,v,O){if(i.bindRenderbuffer(i.RENDERBUFFER,T),v.depthBuffer){const G=v.depthTexture,K=G&&G.isDepthTexture?G.type:null,st=S(v.stencilBuffer,K),ot=v.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;be(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(v),st,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(v),st,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,st,v.width,v.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,ot,i.RENDERBUFFER,T)}else{const G=v.textures;for(let K=0;K<G.length;K++){const st=G[K],ot=r.convert(st.format,st.colorSpace),Z=r.convert(st.type),Q=M(st.internalFormat,ot,Z,st.normalized,st.colorSpace);be(v)?o.renderbufferStorageMultisampleEXT(i.RENDERBUFFER,ge(v),Q,v.width,v.height):O?i.renderbufferStorageMultisample(i.RENDERBUFFER,ge(v),Q,v.width,v.height):i.renderbufferStorage(i.RENDERBUFFER,Q,v.width,v.height)}}i.bindRenderbuffer(i.RENDERBUFFER,null)}function _t(T,v,O){const G=v.isWebGLCubeRenderTarget===!0;if(e.bindFramebuffer(i.FRAMEBUFFER,T),!(v.depthTexture&&v.depthTexture.isDepthTexture))throw new Error("THREE.WebGLTextures: renderTarget.depthTexture must be an instance of THREE.DepthTexture.");const K=n.get(v.depthTexture);if(K.__renderTarget=v,(!K.__webglTexture||v.depthTexture.image.width!==v.width||v.depthTexture.image.height!==v.height)&&(v.depthTexture.image.width=v.width,v.depthTexture.image.height=v.height,v.depthTexture.needsUpdate=!0),G){if(K.__webglInit===void 0&&(K.__webglInit=!0,v.depthTexture.addEventListener("dispose",R)),K.__webglTexture===void 0){K.__webglTexture=i.createTexture(),e.bindTexture(i.TEXTURE_CUBE_MAP,K.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,v.depthTexture);const ct=r.convert(v.depthTexture.format),Tt=r.convert(v.depthTexture.type);let dt;v.depthTexture.format===ai?dt=i.DEPTH_COMPONENT24:v.depthTexture.format===qi&&(dt=i.DEPTH24_STENCIL8);for(let lt=0;lt<6;lt++)i.texImage2D(i.TEXTURE_CUBE_MAP_POSITIVE_X+lt,0,dt,v.width,v.height,0,ct,Tt,null)}}else $(v.depthTexture,0);const st=K.__webglTexture,ot=ge(v),Z=G?i.TEXTURE_CUBE_MAP_POSITIVE_X+O:i.TEXTURE_2D,Q=v.depthTexture.format===qi?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;if(v.depthTexture.format===ai)be(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else if(v.depthTexture.format===qi)be(v)?o.framebufferTexture2DMultisampleEXT(i.FRAMEBUFFER,Q,Z,st,0,ot):i.framebufferTexture2D(i.FRAMEBUFFER,Q,Z,st,0);else throw new Error("THREE.WebGLTextures: Unknown depthTexture format.")}function It(T){const v=n.get(T),O=T.isWebGLCubeRenderTarget===!0;if(v.__boundDepthTexture!==T.depthTexture){const G=T.depthTexture;if(v.__depthDisposeCallback&&v.__depthDisposeCallback(),G){const K=()=>{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,G.removeEventListener("dispose",K)};G.addEventListener("dispose",K),v.__depthDisposeCallback=K}v.__boundDepthTexture=G}if(T.depthTexture&&!v.__autoAllocateDepthBuffer)if(O)for(let G=0;G<6;G++)_t(v.__webglFramebuffer[G],T,G);else{const G=T.texture.mipmaps;G&&G.length>0?_t(v.__webglFramebuffer[0],T,0):_t(v.__webglFramebuffer,T,0)}else if(O){v.__webglDepthbuffer=[];for(let G=0;G<6;G++)if(e.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[G]),v.__webglDepthbuffer[G]===void 0)v.__webglDepthbuffer[G]=i.createRenderbuffer(),At(v.__webglDepthbuffer[G],T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=v.__webglDepthbuffer[G];i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}else{const G=T.texture.mipmaps;if(G&&G.length>0?e.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer[0]):e.bindFramebuffer(i.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=i.createRenderbuffer(),At(v.__webglDepthbuffer,T,!1);else{const K=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,st=v.__webglDepthbuffer;i.bindRenderbuffer(i.RENDERBUFFER,st),i.framebufferRenderbuffer(i.FRAMEBUFFER,K,i.RENDERBUFFER,st)}}e.bindFramebuffer(i.FRAMEBUFFER,null)}function Lt(T,v,O){const G=n.get(T);v!==void 0&&Dt(G.__webglFramebuffer,T,T.texture,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,0),O!==void 0&&It(T)}function Nt(T){const v=T.texture,O=n.get(T),G=n.get(v);T.addEventListener("dispose",_);const K=T.textures,st=T.isWebGLCubeRenderTarget===!0,ot=K.length>1;if(ot||(G.__webglTexture===void 0&&(G.__webglTexture=i.createTexture()),G.__version=v.version,a.memory.textures++),st){O.__webglFramebuffer=[];for(let Z=0;Z<6;Z++)if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer[Z]=[];for(let Q=0;Q<v.mipmaps.length;Q++)O.__webglFramebuffer[Z][Q]=i.createFramebuffer()}else O.__webglFramebuffer[Z]=i.createFramebuffer()}else{if(v.mipmaps&&v.mipmaps.length>0){O.__webglFramebuffer=[];for(let Z=0;Z<v.mipmaps.length;Z++)O.__webglFramebuffer[Z]=i.createFramebuffer()}else O.__webglFramebuffer=i.createFramebuffer();if(ot)for(let Z=0,Q=K.length;Z<Q;Z++){const ct=n.get(K[Z]);ct.__webglTexture===void 0&&(ct.__webglTexture=i.createTexture(),a.memory.textures++)}if(T.samples>0&&be(T)===!1){O.__webglMultisampledFramebuffer=i.createFramebuffer(),O.__webglColorRenderbuffer=[],e.bindFramebuffer(i.FRAMEBUFFER,O.__webglMultisampledFramebuffer);for(let Z=0;Z<K.length;Z++){const Q=K[Z];O.__webglColorRenderbuffer[Z]=i.createRenderbuffer(),i.bindRenderbuffer(i.RENDERBUFFER,O.__webglColorRenderbuffer[Z]);const ct=r.convert(Q.format,Q.colorSpace),Tt=r.convert(Q.type),dt=M(Q.internalFormat,ct,Tt,Q.normalized,Q.colorSpace,T.isXRRenderTarget===!0),lt=ge(T);i.renderbufferStorageMultisample(i.RENDERBUFFER,lt,dt,T.width,T.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+Z,i.RENDERBUFFER,O.__webglColorRenderbuffer[Z])}i.bindRenderbuffer(i.RENDERBUFFER,null),T.depthBuffer&&(O.__webglDepthRenderbuffer=i.createRenderbuffer(),At(O.__webglDepthRenderbuffer,T,!0)),e.bindFramebuffer(i.FRAMEBUFFER,null)}}if(st){e.bindTexture(i.TEXTURE_CUBE_MAP,G.__webglTexture),Bt(i.TEXTURE_CUBE_MAP,v);for(let Z=0;Z<6;Z++)if(v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Z][Q],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,Q);else Dt(O.__webglFramebuffer[Z],T,v,i.COLOR_ATTACHMENT0,i.TEXTURE_CUBE_MAP_POSITIVE_X+Z,0);p(v)&&w(i.TEXTURE_CUBE_MAP),e.unbindTexture()}else if(ot){for(let Z=0,Q=K.length;Z<Q;Z++){const ct=K[Z],Tt=n.get(ct);let dt=i.TEXTURE_2D;(T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(dt=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(dt,Tt.__webglTexture),Bt(dt,ct),Dt(O.__webglFramebuffer,T,ct,i.COLOR_ATTACHMENT0+Z,dt,0),p(ct)&&w(dt)}e.unbindTexture()}else{let Z=i.TEXTURE_2D;if((T.isWebGL3DRenderTarget||T.isWebGLArrayRenderTarget)&&(Z=T.isWebGL3DRenderTarget?i.TEXTURE_3D:i.TEXTURE_2D_ARRAY),e.bindTexture(Z,G.__webglTexture),Bt(Z,v),v.mipmaps&&v.mipmaps.length>0)for(let Q=0;Q<v.mipmaps.length;Q++)Dt(O.__webglFramebuffer[Q],T,v,i.COLOR_ATTACHMENT0,Z,Q);else Dt(O.__webglFramebuffer,T,v,i.COLOR_ATTACHMENT0,Z,0);p(v)&&w(Z),e.unbindTexture()}T.depthBuffer&&It(T)}function Jt(T){const v=T.textures;for(let O=0,G=v.length;O<G;O++){const K=v[O];if(p(K)){const st=A(T),ot=n.get(K).__webglTexture;e.bindTexture(st,ot),w(st),e.unbindTexture()}}}const Qt=[],me=[];function de(T){if(T.samples>0){if(be(T)===!1){const v=T.textures,O=T.width,G=T.height;let K=i.COLOR_BUFFER_BIT;const st=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT,ot=n.get(T),Z=v.length>1;if(Z)for(let ct=0;ct<v.length;ct++)e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,null),e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,null,0);e.bindFramebuffer(i.READ_FRAMEBUFFER,ot.__webglMultisampledFramebuffer);const Q=T.texture.mipmaps;Q&&Q.length>0?e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer[0]):e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglFramebuffer);for(let ct=0;ct<v.length;ct++){if(T.resolveDepthBuffer&&(T.depthBuffer&&(K|=i.DEPTH_BUFFER_BIT),T.stencilBuffer&&T.resolveStencilBuffer&&(K|=i.STENCIL_BUFFER_BIT)),Z){i.framebufferRenderbuffer(i.READ_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Tt=n.get(v[ct]).__webglTexture;i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,Tt,0)}i.blitFramebuffer(0,0,O,G,0,0,O,G,K,i.NEAREST),c===!0&&(Qt.length=0,me.length=0,Qt.push(i.COLOR_ATTACHMENT0+ct),T.depthBuffer&&T.resolveDepthBuffer===!1&&(Qt.push(st),me.push(st),i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,me)),i.invalidateFramebuffer(i.READ_FRAMEBUFFER,Qt))}if(e.bindFramebuffer(i.READ_FRAMEBUFFER,null),e.bindFramebuffer(i.DRAW_FRAMEBUFFER,null),Z)for(let ct=0;ct<v.length;ct++){e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglMultisampledFramebuffer),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.RENDERBUFFER,ot.__webglColorRenderbuffer[ct]);const Tt=n.get(v[ct]).__webglTexture;e.bindFramebuffer(i.FRAMEBUFFER,ot.__webglFramebuffer),i.framebufferTexture2D(i.DRAW_FRAMEBUFFER,i.COLOR_ATTACHMENT0+ct,i.TEXTURE_2D,Tt,0)}e.bindFramebuffer(i.DRAW_FRAMEBUFFER,ot.__webglMultisampledFramebuffer)}else if(T.depthBuffer&&T.resolveDepthBuffer===!1&&c){const v=T.stencilBuffer?i.DEPTH_STENCIL_ATTACHMENT:i.DEPTH_ATTACHMENT;i.invalidateFramebuffer(i.DRAW_FRAMEBUFFER,[v])}}}function ge(T){return Math.min(s.maxSamples,T.samples)}function be(T){const v=n.get(T);return T.samples>0&&t.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function L(T){const v=a.render.frame;h.get(T)!==v&&(h.set(T,v),T.update())}function Je(T,v){const O=T.colorSpace,G=T.format,K=T.type;return T.isCompressedTexture===!0||T.isVideoTexture===!0||O!==za&&O!==Si&&(Kt.getTransfer(O)===te?(G!==un||K!==ln)&&Ot("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):Yt("WebGLTextures: Unsupported texture color space:",O)),v}function jt(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=q,this.resetTextureUnits=W,this.getTextureUnits=X,this.setTextureUnits=U,this.setTexture2D=$,this.setTexture2DArray=et,this.setTexture3D=j,this.setTextureCube=it,this.rebindTextures=Lt,this.setupRenderTarget=Nt,this.updateRenderTargetMipmap=Jt,this.updateMultisampleRenderTarget=de,this.setupDepthRenderbuffer=It,this.setupFrameBufferTexture=Dt,this.useMultisampledRTT=be,this.isReversedDepthBuffer=function(){return e.buffers.depth.getReversed()}}function E_(i,t){function e(n,s=Si){let r;const a=Kt.getTransfer(s);if(n===ln)return i.UNSIGNED_BYTE;if(n===Hl)return i.UNSIGNED_SHORT_4_4_4_4;if(n===Vl)return i.UNSIGNED_SHORT_5_5_5_1;if(n===jd)return i.UNSIGNED_INT_5_9_9_9_REV;if(n===t0)return i.UNSIGNED_INT_10F_11F_11F_REV;if(n===Jd)return i.BYTE;if(n===Qd)return i.SHORT;if(n===yr)return i.UNSIGNED_SHORT;if(n===Gl)return i.INT;if(n===Kn)return i.UNSIGNED_INT;if(n===Vn)return i.FLOAT;if(n===xn)return i.HALF_FLOAT;if(n===e0)return i.ALPHA;if(n===n0)return i.RGB;if(n===un)return i.RGBA;if(n===ai)return i.DEPTH_COMPONENT;if(n===qi)return i.DEPTH_STENCIL;if(n===i0)return i.RED;if(n===Wl)return i.RED_INTEGER;if(n===$i)return i.RG;if(n===Xl)return i.RG_INTEGER;if(n===ql)return i.RGBA_INTEGER;if(n===Ta||n===Ra||n===Ca||n===Da)if(a===te)if(r=t.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(n===Ta)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(n===Ra)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(n===Ca)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(n===Da)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=t.get("WEBGL_compressed_texture_s3tc"),r!==null){if(n===Ta)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(n===Ra)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(n===Ca)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(n===Da)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(n===Cc||n===Dc||n===Pc||n===Ic)if(r=t.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(n===Cc)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(n===Dc)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(n===Pc)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(n===Ic)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(n===Lc||n===Nc||n===Uc||n===Fc||n===Oc||n===Fa||n===zc)if(r=t.get("WEBGL_compressed_texture_etc"),r!==null){if(n===Lc||n===Nc)return a===te?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(n===Uc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(n===Fc)return r.COMPRESSED_R11_EAC;if(n===Oc)return r.COMPRESSED_SIGNED_R11_EAC;if(n===Fa)return r.COMPRESSED_RG11_EAC;if(n===zc)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(n===Bc||n===kc||n===Gc||n===Hc||n===Vc||n===Wc||n===Xc||n===qc||n===Yc||n===Kc||n===Zc||n===$c||n===Jc||n===Qc)if(r=t.get("WEBGL_compressed_texture_astc"),r!==null){if(n===Bc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(n===kc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(n===Gc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(n===Hc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(n===Vc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(n===Wc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(n===Xc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(n===qc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(n===Yc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(n===Kc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(n===Zc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(n===$c)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(n===Jc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(n===Qc)return a===te?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(n===jc||n===tl||n===el)if(r=t.get("EXT_texture_compression_bptc"),r!==null){if(n===jc)return a===te?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(n===tl)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(n===el)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(n===nl||n===il||n===Oa||n===sl)if(r=t.get("EXT_texture_compression_rgtc"),r!==null){if(n===nl)return r.COMPRESSED_RED_RGTC1_EXT;if(n===il)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(n===Oa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(n===sl)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return n===Sr?i.UNSIGNED_INT_24_8:i[n]!==void 0?i[n]:null}return{convert:e}}const b_=`
|
|
4655
4655
|
void main() {
|
|
4656
4656
|
|
|
4657
4657
|
gl_Position = vec4( position, 1.0 );
|
|
4658
4658
|
|
|
4659
|
-
}`,
|
|
4659
|
+
}`,w_=`
|
|
4660
4660
|
uniform sampler2DArray depthColor;
|
|
4661
4661
|
uniform float depthWidth;
|
|
4662
4662
|
uniform float depthHeight;
|
|
@@ -4675,7 +4675,7 @@ void main() {
|
|
|
4675
4675
|
|
|
4676
4676
|
}
|
|
4677
4677
|
|
|
4678
|
-
}`;class o2{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const n=new $d(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=n}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,n=new Ft({vertexShader:r2,fragmentShader:a2,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new rt(new Fs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class l2 extends Xi{constructor(e,t){super();const n=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,h=null,u=null,d=null,p=null,g=null;const x=typeof XRWebGLBinding<"u",m=new o2,f={},w=t.getContextAttributes();let T=null,M=null;const S=[],b=[],R=new Fe;let _=null;const E=new tn;E.viewport=new ft;const D=new tn;D.viewport=new ft;const C=[E,D],L=new _m;let X=null,q=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Z){let re=S[Z];return re===void 0&&(re=new co,S[Z]=re),re.getTargetRaySpace()},this.getControllerGrip=function(Z){let re=S[Z];return re===void 0&&(re=new co,S[Z]=re),re.getGripSpace()},this.getHand=function(Z){let re=S[Z];return re===void 0&&(re=new co,S[Z]=re),re.getHandSpace()};function F(Z){const re=b.indexOf(Z.inputSource);if(re===-1)return;const ne=S[re];ne!==void 0&&(ne.update(Z.inputSource,Z.frame,c||a),ne.dispatchEvent({type:Z.type,data:Z.inputSource}))}function W(){s.removeEventListener("select",F),s.removeEventListener("selectstart",F),s.removeEventListener("selectend",F),s.removeEventListener("squeeze",F),s.removeEventListener("squeezestart",F),s.removeEventListener("squeezeend",F),s.removeEventListener("end",W),s.removeEventListener("inputsourceschange",V);for(let Z=0;Z<S.length;Z++){const re=b[Z];re!==null&&(b[Z]=null,S[Z].disconnect(re))}X=null,q=null,m.reset();for(const Z in f)delete f[Z];e.setRenderTarget(T),p=null,d=null,u=null,s=null,M=null,We.stop(),n.isPresenting=!1,e.setPixelRatio(_),e.setSize(R.width,R.height,!1),n.dispatchEvent({type:"sessionend"})}this.setFramebufferScaleFactor=function(Z){r=Z,n.isPresenting===!0&&Oe("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Z){o=Z,n.isPresenting===!0&&Oe("WebXRManager: Cannot change reference space type while presenting.")},this.getReferenceSpace=function(){return c||a},this.setReferenceSpace=function(Z){c=Z},this.getBaseLayer=function(){return d!==null?d:p},this.getBinding=function(){return u===null&&x&&(u=new XRWebGLBinding(s,t)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Z){if(s=Z,s!==null){if(T=e.getRenderTarget(),s.addEventListener("select",F),s.addEventListener("selectstart",F),s.addEventListener("selectend",F),s.addEventListener("squeeze",F),s.addEventListener("squeezestart",F),s.addEventListener("squeezeend",F),s.addEventListener("end",W),s.addEventListener("inputsourceschange",V),w.xrCompatible!==!0&&await t.makeXRCompatible(),_=e.getPixelRatio(),e.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let ne=null,k=null,De=null;w.depth&&(De=w.stencil?t.DEPTH24_STENCIL8:t.DEPTH_COMPONENT24,ne=w.stencil?Fi:Qn,k=w.stencil?ur:zn);const Pe={colorFormat:t.RGBA8,depthFormat:De,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Pe),s.updateRenderState({layers:[d]}),e.setPixelRatio(1),e.setSize(d.textureWidth,d.textureHeight,!1),M=new Mn(d.textureWidth,d.textureHeight,{format:_n,type:nn,depthTexture:new Is(d.textureWidth,d.textureHeight,k,void 0,void 0,void 0,void 0,void 0,void 0,ne),stencilBuffer:w.stencil,colorSpace:e.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const ne={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};p=new XRWebGLLayer(s,t,ne),s.updateRenderState({baseLayer:p}),e.setPixelRatio(1),e.setSize(p.framebufferWidth,p.framebufferHeight,!1),M=new Mn(p.framebufferWidth,p.framebufferHeight,{format:_n,type:nn,colorSpace:e.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:p.ignoreDepthValues===!1,resolveStencilBuffer:p.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(l),c=null,a=await s.requestReferenceSpace(o),We.setContext(s),We.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function V(Z){for(let re=0;re<Z.removed.length;re++){const ne=Z.removed[re],k=b.indexOf(ne);k>=0&&(b[k]=null,S[k].disconnect(ne))}for(let re=0;re<Z.added.length;re++){const ne=Z.added[re];let k=b.indexOf(ne);if(k===-1){for(let Pe=0;Pe<S.length;Pe++)if(Pe>=b.length){b.push(ne),k=Pe;break}else if(b[Pe]===null){b[Pe]=ne,k=Pe;break}if(k===-1)break}const De=S[k];De&&De.connect(ne)}}const Q=new U,te=new U;function ee(Z,re,ne){Q.setFromMatrixPosition(re.matrixWorld),te.setFromMatrixPosition(ne.matrixWorld);const k=Q.distanceTo(te),De=re.projectionMatrix.elements,Pe=ne.projectionMatrix.elements,Re=De[14]/(De[10]-1),Me=De[14]/(De[10]+1),Ue=(De[9]+1)/De[5],Ie=(De[9]-1)/De[5],Le=(De[8]-1)/De[0],$e=(Pe[8]+1)/Pe[0],Je=Re*Le,pt=Re*$e,dt=k/(-Le+$e),mt=dt*-Le;if(re.matrixWorld.decompose(Z.position,Z.quaternion,Z.scale),Z.translateX(mt),Z.translateZ(dt),Z.matrixWorld.compose(Z.position,Z.quaternion,Z.scale),Z.matrixWorldInverse.copy(Z.matrixWorld).invert(),De[10]===-1)Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse);else{const St=Re+dt,I=Me+dt,Kt=Je-mt,Qe=pt+(k-mt),A=Ue*Me/I*St,v=Ie*Me/I*St;Z.projectionMatrix.makePerspective(Kt,Qe,A,v,St,I),Z.projectionMatrixInverse.copy(Z.projectionMatrix).invert()}}function se(Z,re){re===null?Z.matrixWorld.copy(Z.matrix):Z.matrixWorld.multiplyMatrices(re.matrixWorld,Z.matrix),Z.matrixWorldInverse.copy(Z.matrixWorld).invert()}this.updateCamera=function(Z){if(s===null)return;let re=Z.near,ne=Z.far;m.texture!==null&&(m.depthNear>0&&(re=m.depthNear),m.depthFar>0&&(ne=m.depthFar)),L.near=D.near=E.near=re,L.far=D.far=E.far=ne,(X!==L.near||q!==L.far)&&(s.updateRenderState({depthNear:L.near,depthFar:L.far}),X=L.near,q=L.far),L.layers.mask=Z.layers.mask|6,E.layers.mask=L.layers.mask&-5,D.layers.mask=L.layers.mask&-3;const k=Z.parent,De=L.cameras;se(L,k);for(let Pe=0;Pe<De.length;Pe++)se(De[Pe],k);De.length===2?ee(L,E,D):L.projectionMatrix.copy(E.projectionMatrix),ge(Z,L,k)};function ge(Z,re,ne){ne===null?Z.matrix.copy(re.matrixWorld):(Z.matrix.copy(ne.matrixWorld),Z.matrix.invert(),Z.matrix.multiply(re.matrixWorld)),Z.matrix.decompose(Z.position,Z.quaternion,Z.scale),Z.updateMatrixWorld(!0),Z.projectionMatrix.copy(re.projectionMatrix),Z.projectionMatrixInverse.copy(re.projectionMatrixInverse),Z.isPerspectiveCamera&&(Z.fov=Kl*2*Math.atan(1/Z.projectionMatrix.elements[5]),Z.zoom=1)}this.getCamera=function(){return L},this.getFoveation=function(){if(!(d===null&&p===null))return l},this.setFoveation=function(Z){l=Z,d!==null&&(d.fixedFoveation=Z),p!==null&&p.fixedFoveation!==void 0&&(p.fixedFoveation=Z)},this.hasDepthSensing=function(){return m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(L)},this.getCameraTexture=function(Z){return f[Z]};let Ve=null;function at(Z,re){if(h=re.getViewerPose(c||a),g=re,h!==null){const ne=h.views;p!==null&&(e.setRenderTargetFramebuffer(M,p.framebuffer),e.setRenderTarget(M));let k=!1;ne.length!==L.cameras.length&&(L.cameras.length=0,k=!0);for(let Me=0;Me<ne.length;Me++){const Ue=ne[Me];let Ie=null;if(p!==null)Ie=p.getViewport(Ue);else{const $e=u.getViewSubImage(d,Ue);Ie=$e.viewport,Me===0&&(e.setRenderTargetTextures(M,$e.colorTexture,$e.depthStencilTexture),e.setRenderTarget(M))}let Le=C[Me];Le===void 0&&(Le=new tn,Le.layers.enable(Me),Le.viewport=new ft,C[Me]=Le),Le.matrix.fromArray(Ue.transform.matrix),Le.matrix.decompose(Le.position,Le.quaternion,Le.scale),Le.projectionMatrix.fromArray(Ue.projectionMatrix),Le.projectionMatrixInverse.copy(Le.projectionMatrix).invert(),Le.viewport.set(Ie.x,Ie.y,Ie.width,Ie.height),Me===0&&(L.matrix.copy(Le.matrix),L.matrix.decompose(L.position,L.quaternion,L.scale)),k===!0&&L.cameras.push(Le)}const De=s.enabledFeatures;if(De&&De.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const Me=u.getDepthInformation(ne[0]);Me&&Me.isValid&&Me.texture&&m.init(Me,s.renderState)}if(De&&De.includes("camera-access")&&x){e.state.unbindTexture(),u=n.getBinding();for(let Me=0;Me<ne.length;Me++){const Ue=ne[Me].camera;if(Ue){let Ie=f[Ue];Ie||(Ie=new $d,f[Ue]=Ie);const Le=u.getCameraImage(Ue);Ie.sourceTexture=Le}}}}for(let ne=0;ne<S.length;ne++){const k=b[ne],De=S[ne];k!==null&&De!==void 0&&De.update(k,re,c||a)}Ve&&Ve(Z,re),re.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:re}),g=null}const We=new t0;We.setAnimationLoop(at),this.setAnimationLoop=function(Z){Ve=Z},this.dispose=function(){}}}const c2=new ht,l0=new ze;l0.set(-1,0,0,0,1,0,0,0,1);function h2(i,e){function t(m,f){m.matrixAutoUpdate===!0&&m.updateMatrix(),f.value.copy(m.matrix)}function n(m,f){f.color.getRGB(m.fogColor.value,Jd(i)),f.isFog?(m.fogNear.value=f.near,m.fogFar.value=f.far):f.isFogExp2&&(m.fogDensity.value=f.density)}function s(m,f,w,T,M){f.isNodeMaterial?f.uniformsNeedUpdate=!1:f.isMeshBasicMaterial?r(m,f):f.isMeshLambertMaterial?(r(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshToonMaterial?(r(m,f),u(m,f)):f.isMeshPhongMaterial?(r(m,f),h(m,f),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)):f.isMeshStandardMaterial?(r(m,f),d(m,f),f.isMeshPhysicalMaterial&&p(m,f,M)):f.isMeshMatcapMaterial?(r(m,f),g(m,f)):f.isMeshDepthMaterial?r(m,f):f.isMeshDistanceMaterial?(r(m,f),x(m,f)):f.isMeshNormalMaterial?r(m,f):f.isLineBasicMaterial?(a(m,f),f.isLineDashedMaterial&&o(m,f)):f.isPointsMaterial?l(m,f,w,T):f.isSpriteMaterial?c(m,f):f.isShadowMaterial?(m.color.value.copy(f.color),m.opacity.value=f.opacity):f.isShaderMaterial&&(f.uniformsNeedUpdate=!1)}function r(m,f){m.opacity.value=f.opacity,f.color&&m.diffuse.value.copy(f.color),f.emissive&&m.emissive.value.copy(f.emissive).multiplyScalar(f.emissiveIntensity),f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.bumpMap&&(m.bumpMap.value=f.bumpMap,t(f.bumpMap,m.bumpMapTransform),m.bumpScale.value=f.bumpScale,f.side===Nt&&(m.bumpScale.value*=-1)),f.normalMap&&(m.normalMap.value=f.normalMap,t(f.normalMap,m.normalMapTransform),m.normalScale.value.copy(f.normalScale),f.side===Nt&&m.normalScale.value.negate()),f.displacementMap&&(m.displacementMap.value=f.displacementMap,t(f.displacementMap,m.displacementMapTransform),m.displacementScale.value=f.displacementScale,m.displacementBias.value=f.displacementBias),f.emissiveMap&&(m.emissiveMap.value=f.emissiveMap,t(f.emissiveMap,m.emissiveMapTransform)),f.specularMap&&(m.specularMap.value=f.specularMap,t(f.specularMap,m.specularMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest);const w=e.get(f),T=w.envMap,M=w.envMapRotation;T&&(m.envMap.value=T,m.envMapRotation.value.setFromMatrix4(c2.makeRotationFromEuler(M)).transpose(),T.isCubeTexture&&T.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(l0),m.reflectivity.value=f.reflectivity,m.ior.value=f.ior,m.refractionRatio.value=f.refractionRatio),f.lightMap&&(m.lightMap.value=f.lightMap,m.lightMapIntensity.value=f.lightMapIntensity,t(f.lightMap,m.lightMapTransform)),f.aoMap&&(m.aoMap.value=f.aoMap,m.aoMapIntensity.value=f.aoMapIntensity,t(f.aoMap,m.aoMapTransform))}function a(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform))}function o(m,f){m.dashSize.value=f.dashSize,m.totalSize.value=f.dashSize+f.gapSize,m.scale.value=f.scale}function l(m,f,w,T){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.size.value=f.size*w,m.scale.value=T*.5,f.map&&(m.map.value=f.map,t(f.map,m.uvTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function c(m,f){m.diffuse.value.copy(f.color),m.opacity.value=f.opacity,m.rotation.value=f.rotation,f.map&&(m.map.value=f.map,t(f.map,m.mapTransform)),f.alphaMap&&(m.alphaMap.value=f.alphaMap,t(f.alphaMap,m.alphaMapTransform)),f.alphaTest>0&&(m.alphaTest.value=f.alphaTest)}function h(m,f){m.specular.value.copy(f.specular),m.shininess.value=Math.max(f.shininess,1e-4)}function u(m,f){f.gradientMap&&(m.gradientMap.value=f.gradientMap)}function d(m,f){m.metalness.value=f.metalness,f.metalnessMap&&(m.metalnessMap.value=f.metalnessMap,t(f.metalnessMap,m.metalnessMapTransform)),m.roughness.value=f.roughness,f.roughnessMap&&(m.roughnessMap.value=f.roughnessMap,t(f.roughnessMap,m.roughnessMapTransform)),f.envMap&&(m.envMapIntensity.value=f.envMapIntensity)}function p(m,f,w){m.ior.value=f.ior,f.sheen>0&&(m.sheenColor.value.copy(f.sheenColor).multiplyScalar(f.sheen),m.sheenRoughness.value=f.sheenRoughness,f.sheenColorMap&&(m.sheenColorMap.value=f.sheenColorMap,t(f.sheenColorMap,m.sheenColorMapTransform)),f.sheenRoughnessMap&&(m.sheenRoughnessMap.value=f.sheenRoughnessMap,t(f.sheenRoughnessMap,m.sheenRoughnessMapTransform))),f.clearcoat>0&&(m.clearcoat.value=f.clearcoat,m.clearcoatRoughness.value=f.clearcoatRoughness,f.clearcoatMap&&(m.clearcoatMap.value=f.clearcoatMap,t(f.clearcoatMap,m.clearcoatMapTransform)),f.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=f.clearcoatRoughnessMap,t(f.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),f.clearcoatNormalMap&&(m.clearcoatNormalMap.value=f.clearcoatNormalMap,t(f.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(f.clearcoatNormalScale),f.side===Nt&&m.clearcoatNormalScale.value.negate())),f.dispersion>0&&(m.dispersion.value=f.dispersion),f.iridescence>0&&(m.iridescence.value=f.iridescence,m.iridescenceIOR.value=f.iridescenceIOR,m.iridescenceThicknessMinimum.value=f.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=f.iridescenceThicknessRange[1],f.iridescenceMap&&(m.iridescenceMap.value=f.iridescenceMap,t(f.iridescenceMap,m.iridescenceMapTransform)),f.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=f.iridescenceThicknessMap,t(f.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),f.transmission>0&&(m.transmission.value=f.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),f.transmissionMap&&(m.transmissionMap.value=f.transmissionMap,t(f.transmissionMap,m.transmissionMapTransform)),m.thickness.value=f.thickness,f.thicknessMap&&(m.thicknessMap.value=f.thicknessMap,t(f.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=f.attenuationDistance,m.attenuationColor.value.copy(f.attenuationColor)),f.anisotropy>0&&(m.anisotropyVector.value.set(f.anisotropy*Math.cos(f.anisotropyRotation),f.anisotropy*Math.sin(f.anisotropyRotation)),f.anisotropyMap&&(m.anisotropyMap.value=f.anisotropyMap,t(f.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=f.specularIntensity,m.specularColor.value.copy(f.specularColor),f.specularColorMap&&(m.specularColorMap.value=f.specularColorMap,t(f.specularColorMap,m.specularColorMapTransform)),f.specularIntensityMap&&(m.specularIntensityMap.value=f.specularIntensityMap,t(f.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,f){f.matcap&&(m.matcap.value=f.matcap)}function x(m,f){const w=e.get(f).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function u2(i,e,t,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function l(M,S){const b=S.program;n.uniformBlockBinding(M,b)}function c(M,S){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",w));const R=S.program;n.updateUBOMapping(M,R);const _=e.render.frame;r[M.id]!==_&&(d(M),r[M.id]=_)}function h(M){const S=u();M.__bindingPointIndex=S;const b=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,_),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return qe("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=s[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let _=0,E=b.length;_<E;_++){const D=b[_];if(Array.isArray(D))for(let C=0,L=D.length;C<L;C++)p(D[C],_,C,R);else p(D,_,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function p(M,S,b,R){if(x(M,S,b,R)===!0){const _=M.__offset,E=M.value;if(Array.isArray(E)){let D=0;for(let C=0;C<E.length;C++){const L=E[C],X=f(L);g(L,M.__data,D),typeof L!="number"&&typeof L!="boolean"&&!L.isMatrix3&&!ArrayBuffer.isView(L)&&(D+=X.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,b){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,b)}function x(M,S,b,R){const _=M.value,E=S+"_"+b;if(R[E]===void 0)return typeof _=="number"||typeof _=="boolean"?R[E]=_:ArrayBuffer.isView(_)?R[E]=_.slice():R[E]=_.clone(),!0;{const D=R[E];if(typeof _=="number"||typeof _=="boolean"){if(D!==_)return R[E]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(D.equals(_)===!1)return D.copy(_),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const R=16;for(let E=0,D=S.length;E<D;E++){const C=Array.isArray(S[E])?S[E]:[S[E]];for(let L=0,X=C.length;L<X;L++){const q=C[L],F=Array.isArray(q.value)?q.value:[q.value];for(let W=0,V=F.length;W<V;W++){const Q=F[W],te=f(Q),ee=b%R,se=ee%te.boundary,ge=ee+se;b+=se,ge!==0&&R-ge<te.storage&&(b+=R-ge),q.__data=new Float32Array(te.storage/Float32Array.BYTES_PER_ELEMENT),q.__offset=b,b+=te.storage}}}const _=b%R;return _>0&&(b+=R-_),M.__size=b,M.__cache={},this}function f(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?Oe("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Oe("WebGLRenderer: Unsupported uniform value type.",M),S}function w(M){const S=M.target;S.removeEventListener("dispose",w);const b=a.indexOf(S.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function T(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:l,update:c,dispose:T}}const d2=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 wn=null;function f2(){return wn===null&&(wn=new em(d2,16,16,Gi,Jn),wn.name="DFG_LUT",wn.minFilter=Gt,wn.magFilter=Gt,wn.wrapS=Kn,wn.wrapT=Kn,wn.generateMipmaps=!1,wn.needsUpdate=!0),wn}class p2{constructor(e={}){const{canvas:t=Pp(),context:n=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:h="default",failIfMajorPerformanceCaveat:u=!1,reversedDepthBuffer:d=!1,outputBufferType:p=nn}=e;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 x=p,m=new Set([Ic,Pc,Dc]),f=new Set([nn,zn,hr,ur,Rc,Cc]),w=new Uint32Array(4),T=new Int32Array(4),M=new U;let S=null,b=null;const R=[],_=[];let E=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Fn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,L=null,X=null,q=null,F=null;this._outputColorSpace=hn;let W=0,V=0,Q=null,te=-1,ee=null;const se=new ft,ge=new ft;let Ve=null;const at=new xe(0);let We=0,Z=t.width,re=t.height,ne=1,k=null,De=null;const Pe=new ft(0,0,Z,re),Re=new ft(0,0,Z,re);let Me=!1;const Ue=new Bc;let Ie=!1,Le=!1;const $e=new ht,Je=new U,pt=new ft,dt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let mt=!1;function St(){return Q===null?ne:1}let I=n;function Kt(y,N){return t.getContext(y,N)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${wc}`),t.addEventListener("webglcontextlost",gt,!1),t.addEventListener("webglcontextrestored",ot,!1),t.addEventListener("webglcontextcreationerror",yn,!1),I===null){const N="webgl2";if(I=Kt(N,y),I===null)throw Kt(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw qe("WebGLRenderer: "+y.message),y}let Qe,A,v,O,G,Y,ie,oe,K,J,le,we,ue,ce,Ce,Ne,Be,P,ae,$,he,me,j;function be(){Qe=new fv(I),Qe.init(),he=new s2(I,Qe),A=new rv(I,Qe,e,he),v=new n2(I,Qe),A.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),X=I.createFramebuffer(),q=I.createFramebuffer(),F=I.createFramebuffer(),O=new gv(I),G=new H_,Y=new i2(I,Qe,v,G,A,he,O),ie=new dv(D),oe=new Mm(I),me=new iv(I,oe),K=new pv(I,oe,O,me),J=new _v(I,K,oe,me,O),P=new vv(I,A,Y),Ce=new av(G),le=new G_(D,ie,Qe,A,me,Ce),we=new h2(D,G),ue=new W_,ce=new $_(Qe),Be=new nv(D,ie,v,J,g,l),Ne=new t2(D,J,A),j=new u2(I,O,A,v),ae=new sv(I,Qe,O),$=new mv(I,Qe,O),O.programs=le.programs,D.capabilities=A,D.extensions=Qe,D.properties=G,D.renderLists=ue,D.shadowMap=Ne,D.state=v,D.info=O}be(),x!==nn&&(E=new Mv(x,t.width,t.height,o,s,r));const ye=new l2(D,I);this.xr=ye,this.getContext=function(){return I},this.getContextAttributes=function(){return I.getContextAttributes()},this.forceContextLoss=function(){const y=Qe.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=Qe.get("WEBGL_lose_context");y&&y.restoreContext()},this.getPixelRatio=function(){return ne},this.setPixelRatio=function(y){y!==void 0&&(ne=y,this.setSize(Z,re,!1))},this.getSize=function(y){return y.set(Z,re)},this.setSize=function(y,N,H=!0){if(ye.isPresenting){Oe("WebGLRenderer: Can't change size while VR device is presenting.");return}Z=y,re=N,t.width=Math.floor(y*ne),t.height=Math.floor(N*ne),H===!0&&(t.style.width=y+"px",t.style.height=N+"px"),E!==null&&E.setSize(t.width,t.height),this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Z*ne,re*ne).floor()},this.setDrawingBufferSize=function(y,N,H){Z=y,re=N,ne=H,t.width=Math.floor(y*H),t.height=Math.floor(N*H),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(x===nn){qe("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Oe("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(se)},this.getViewport=function(y){return y.copy(Pe)},this.setViewport=function(y,N,H,z){y.isVector4?Pe.set(y.x,y.y,y.z,y.w):Pe.set(y,N,H,z),v.viewport(se.copy(Pe).multiplyScalar(ne).round())},this.getScissor=function(y){return y.copy(Re)},this.setScissor=function(y,N,H,z){y.isVector4?Re.set(y.x,y.y,y.z,y.w):Re.set(y,N,H,z),v.scissor(ge.copy(Re).multiplyScalar(ne).round())},this.getScissorTest=function(){return Me},this.setScissorTest=function(y){v.setScissorTest(Me=y)},this.setOpaqueSort=function(y){k=y},this.setTransparentSort=function(y){De=y},this.getClearColor=function(y){return y.copy(Be.getClearColor())},this.setClearColor=function(){Be.setClearColor(...arguments)},this.getClearAlpha=function(){return Be.getClearAlpha()},this.setClearAlpha=function(){Be.setClearAlpha(...arguments)},this.clear=function(y=!0,N=!0,H=!0){let z=0;if(y){let B=!1;if(Q!==null){const pe=Q.texture.format;B=m.has(pe)}if(B){const pe=Q.texture.type,_e=f.has(pe),fe=Be.getClearColor(),Ee=Be.getClearAlpha(),Ae=fe.r,ke=fe.g,He=fe.b;_e?(w[0]=Ae,w[1]=ke,w[2]=He,w[3]=Ee,I.clearBufferuiv(I.COLOR,0,w)):(T[0]=Ae,T[1]=ke,T[2]=He,T[3]=Ee,I.clearBufferiv(I.COLOR,0,T))}else z|=I.COLOR_BUFFER_BIT}N&&(z|=I.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),H&&(z|=I.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),z!==0&&I.clear(z)},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),L=y},this.dispose=function(){t.removeEventListener("webglcontextlost",gt,!1),t.removeEventListener("webglcontextrestored",ot,!1),t.removeEventListener("webglcontextcreationerror",yn,!1),Be.dispose(),ue.dispose(),ce.dispose(),G.dispose(),ie.dispose(),J.dispose(),me.dispose(),j.dispose(),le.dispose(),ye.dispose(),ye.removeEventListener("sessionstart",Qc),ye.removeEventListener("sessionend",jc),Si.stop()};function gt(y){y.preventDefault(),Ca("WebGLRenderer: Context Lost."),C=!0}function ot(){Ca("WebGLRenderer: Context Restored."),C=!1;const y=O.autoReset,N=Ne.enabled,H=Ne.autoUpdate,z=Ne.needsUpdate,B=Ne.type;be(),O.autoReset=y,Ne.enabled=N,Ne.autoUpdate=H,Ne.needsUpdate=z,Ne.type=B}function yn(y){qe("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Sn(y){const N=y.target;N.removeEventListener("dispose",Sn),Q0(N)}function Q0(y){j0(y),G.remove(y)}function j0(y){const N=G.get(y).programs;N!==void 0&&(N.forEach(function(H){le.releaseProgram(H)}),y.isShaderMaterial&&le.releaseShaderCache(y))}this.renderBufferDirect=function(y,N,H,z,B,pe){N===null&&(N=dt);const _e=B.isMesh&&B.matrixWorld.determinantAffine()<0,fe=nf(y,N,H,z,B);v.setMaterial(z,_e);let Ee=H.index,Ae=1;if(z.wireframe===!0){if(Ee=K.getWireframeAttribute(H),Ee===void 0)return;Ae=2}const ke=H.drawRange,He=H.attributes.position;let Te=ke.start*Ae,tt=(ke.start+ke.count)*Ae;pe!==null&&(Te=Math.max(Te,pe.start*Ae),tt=Math.min(tt,(pe.start+pe.count)*Ae)),Ee!==null?(Te=Math.max(Te,0),tt=Math.min(tt,Ee.count)):He!=null&&(Te=Math.max(Te,0),tt=Math.min(tt,He.count));const xt=tt-Te;if(xt<0||xt===1/0)return;me.setup(B,z,fe,H,Ee);let vt,it=ae;if(Ee!==null&&(vt=oe.get(Ee),it=$,it.setIndex(vt)),B.isMesh)z.wireframe===!0?(v.setLineWidth(z.wireframeLinewidth*St()),it.setMode(I.LINES)):it.setMode(I.TRIANGLES);else if(B.isLine){let Ot=z.linewidth;Ot===void 0&&(Ot=1),v.setLineWidth(Ot*St()),B.isLineSegments?it.setMode(I.LINES):B.isLineLoop?it.setMode(I.LINE_LOOP):it.setMode(I.LINE_STRIP)}else B.isPoints?it.setMode(I.POINTS):B.isSprite&&it.setMode(I.TRIANGLES);if(B.isBatchedMesh)if(Qe.get("WEBGL_multi_draw"))it.renderMultiDraw(B._multiDrawStarts,B._multiDrawCounts,B._multiDrawCount);else{const Ot=B._multiDrawStarts,ve=B._multiDrawCounts,$t=B._multiDrawCount,Ze=Ee?oe.get(Ee).bytesPerElement:1,sn=G.get(z).currentProgram.getUniforms();for(let En=0;En<$t;En++)sn.setValue(I,"_gl_DrawID",En),it.render(Ot[En]/Ze,ve[En])}else if(B.isInstancedMesh)it.renderInstances(Te,xt,B.count);else if(H.isInstancedBufferGeometry){const Ot=H._maxInstanceCount!==void 0?H._maxInstanceCount:1/0,ve=Math.min(H.instanceCount,Ot);it.renderInstances(Te,xt,ve)}else it.render(Te,xt)};function Jc(y,N,H){y.transparent===!0&&y.side===vn&&y.forceSinglePass===!1?(y.side=Nt,y.needsUpdate=!0,_r(y,N,H),y.side=_i,y.needsUpdate=!0,_r(y,N,H),y.side=vn):_r(y,N,H)}this.compile=function(y,N,H=null){H===null&&(H=y),b=ce.get(H),b.init(N),_.push(b),H.traverseVisible(function(B){B.isLight&&B.layers.test(N.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),y!==H&&y.traverseVisible(function(B){B.isLight&&B.layers.test(N.layers)&&(b.pushLight(B),B.castShadow&&b.pushShadow(B))}),b.setupLights();const z=new Set;return y.traverse(function(B){if(!(B.isMesh||B.isPoints||B.isLine||B.isSprite))return;const pe=B.material;if(pe)if(Array.isArray(pe))for(let _e=0;_e<pe.length;_e++){const fe=pe[_e];Jc(fe,H,B),z.add(fe)}else Jc(pe,H,B),z.add(pe)}),b=_.pop(),z},this.compileAsync=function(y,N,H=null){const z=this.compile(y,N,H);return new Promise(B=>{function pe(){if(z.forEach(function(_e){G.get(_e).currentProgram.isReady()&&z.delete(_e)}),z.size===0){B(y);return}setTimeout(pe,10)}Qe.get("KHR_parallel_shader_compile")!==null?pe():setTimeout(pe,10)})};let $a=null;function ef(y){$a&&$a(y)}function Qc(){Si.stop()}function jc(){Si.start()}const Si=new t0;Si.setAnimationLoop(ef),typeof self<"u"&&Si.setContext(self),this.setAnimationLoop=function(y){$a=y,ye.setAnimationLoop(y),y===null?Si.stop():Si.start()},ye.addEventListener("sessionstart",Qc),ye.addEventListener("sessionend",jc),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){qe("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;L!==null&&L.renderStart(y,N);const H=ye.enabled===!0&&ye.isPresenting===!0,z=E!==null&&(Q===null||H)&&E.begin(D,Q);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),ye.enabled===!0&&ye.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(ye.cameraAutoUpdate===!0&&ye.updateCamera(N),N=ye.getCamera()),y.isScene===!0&&y.onBeforeRender(D,y,N,Q),b=ce.get(y,_.length),b.init(N),b.state.textureUnits=Y.getTextureUnits(),_.push(b),$e.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),Ue.setFromProjectionMatrix($e,Nn,N.reversedDepth),Le=this.localClippingEnabled,Ie=Ce.init(this.clippingPlanes,Le),S=ue.get(y,R.length),S.init(),R.push(S),ye.enabled===!0&&ye.isPresenting===!0){const _e=D.xr.getDepthSensingMesh();_e!==null&&Ja(_e,N,-1/0,D.sortObjects)}Ja(y,N,0,D.sortObjects),S.finish(),D.sortObjects===!0&&S.sort(k,De,N.reversedDepth),mt=ye.enabled===!1||ye.isPresenting===!1||ye.hasDepthSensing()===!1,mt&&Be.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Ie===!0&&Ce.beginShadows();const B=b.state.shadowsArray;if(Ne.render(B,y,N),Ie===!0&&Ce.endShadows(),(z&&E.hasRenderPass())===!1){const _e=S.opaque,fe=S.transmissive;if(b.setupLights(),N.isArrayCamera){const Ee=N.cameras;if(fe.length>0)for(let Ae=0,ke=Ee.length;Ae<ke;Ae++){const He=Ee[Ae];th(_e,fe,y,He)}mt&&Be.render(y);for(let Ae=0,ke=Ee.length;Ae<ke;Ae++){const He=Ee[Ae];eh(S,y,He,He.viewport)}}else fe.length>0&&th(_e,fe,y,N),mt&&Be.render(y),eh(S,y,N)}Q!==null&&V===0&&(Y.updateMultisampleRenderTarget(Q),Y.updateRenderTargetMipmap(Q)),z&&E.end(D),y.isScene===!0&&y.onAfterRender(D,y,N),me.resetDefaultState(),te=-1,ee=null,_.pop(),_.length>0?(b=_[_.length-1],Y.setTextureUnits(b.state.textureUnits),Ie===!0&&Ce.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,L!==null&&L.renderEnd()};function Ja(y,N,H,z){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)H=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(N);else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight)b.pushLight(y),y.castShadow&&b.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||Ue.intersectsSprite(y)){z&&pt.setFromMatrixPosition(y.matrixWorld).applyMatrix4($e);const _e=J.update(y),fe=y.material;fe.visible&&S.push(y,_e,fe,H,pt.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||Ue.intersectsObject(y))){const _e=J.update(y),fe=y.material;if(z&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),pt.copy(y.boundingSphere.center)):(_e.boundingSphere===null&&_e.computeBoundingSphere(),pt.copy(_e.boundingSphere.center)),pt.applyMatrix4(y.matrixWorld).applyMatrix4($e)),Array.isArray(fe)){const Ee=_e.groups;for(let Ae=0,ke=Ee.length;Ae<ke;Ae++){const He=Ee[Ae],Te=fe[He.materialIndex];Te&&Te.visible&&S.push(y,_e,Te,H,pt.z,He)}}else fe.visible&&S.push(y,_e,fe,H,pt.z,null)}}const pe=y.children;for(let _e=0,fe=pe.length;_e<fe;_e++)Ja(pe[_e],N,H,z)}function eh(y,N,H,z){const{opaque:B,transmissive:pe,transparent:_e}=y;b.setupLightsView(H),Ie===!0&&Ce.setGlobalState(D.clippingPlanes,H),z&&v.viewport(se.copy(z)),B.length>0&&vr(B,N,H),pe.length>0&&vr(pe,N,H),_e.length>0&&vr(_e,N,H),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function th(y,N,H,z){if((H.isScene===!0?H.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[z.id]===void 0){const Te=Qe.has("EXT_color_buffer_half_float")||Qe.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[z.id]=new Mn(1,1,{generateMipmaps:!0,type:Te?Jn:nn,minFilter:Ui,samples:Math.max(4,A.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Ye.workingColorSpace})}const pe=b.state.transmissionRenderTarget[z.id],_e=z.viewport||se;pe.setSize(_e.z*D.transmissionResolutionScale,_e.w*D.transmissionResolutionScale);const fe=D.getRenderTarget(),Ee=D.getActiveCubeFace(),Ae=D.getActiveMipmapLevel();D.setRenderTarget(pe),D.getClearColor(at),We=D.getClearAlpha(),We<1&&D.setClearColor(16777215,.5),D.clear(),mt&&Be.render(H);const ke=D.toneMapping;D.toneMapping=Fn;const He=z.viewport;if(z.viewport!==void 0&&(z.viewport=void 0),b.setupLightsView(z),Ie===!0&&Ce.setGlobalState(D.clippingPlanes,z),vr(y,H,z),Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe),Qe.has("WEBGL_multisampled_render_to_texture")===!1){let Te=!1;for(let tt=0,xt=N.length;tt<xt;tt++){const vt=N[tt],{object:it,geometry:Ot,material:ve,group:$t}=vt;if(ve.side===vn&&it.layers.test(z.layers)){const Ze=ve.side;ve.side=Nt,ve.needsUpdate=!0,nh(it,H,z,Ot,ve,$t),ve.side=Ze,ve.needsUpdate=!0,Te=!0}}Te===!0&&(Y.updateMultisampleRenderTarget(pe),Y.updateRenderTargetMipmap(pe))}D.setRenderTarget(fe,Ee,Ae),D.setClearColor(at,We),He!==void 0&&(z.viewport=He),D.toneMapping=ke}function vr(y,N,H){const z=N.isScene===!0?N.overrideMaterial:null;for(let B=0,pe=y.length;B<pe;B++){const _e=y[B],{object:fe,geometry:Ee,group:Ae}=_e;let ke=_e.material;ke.allowOverride===!0&&z!==null&&(ke=z),fe.layers.test(H.layers)&&nh(fe,N,H,Ee,ke,Ae)}}function nh(y,N,H,z,B,pe){y.onBeforeRender(D,N,H,z,B,pe),y.modelViewMatrix.multiplyMatrices(H.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),B.onBeforeRender(D,N,H,z,y,pe),B.transparent===!0&&B.side===vn&&B.forceSinglePass===!1?(B.side=Nt,B.needsUpdate=!0,D.renderBufferDirect(H,N,z,B,y,pe),B.side=_i,B.needsUpdate=!0,D.renderBufferDirect(H,N,z,B,y,pe),B.side=vn):D.renderBufferDirect(H,N,z,B,y,pe),y.onAfterRender(D,N,H,z,B,pe)}function _r(y,N,H){N.isScene!==!0&&(N=dt);const z=G.get(y),B=b.state.lights,pe=b.state.shadowsArray,_e=B.state.version,fe=le.getParameters(y,B.state,pe,N,H,b.state.lightProbeGridArray),Ee=le.getProgramCacheKey(fe);let Ae=z.programs;z.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,z.fog=N.fog;const ke=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;z.envMap=ie.get(y.envMap||z.environment,ke),z.envMapRotation=z.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Ae===void 0&&(y.addEventListener("dispose",Sn),Ae=new Map,z.programs=Ae);let He=Ae.get(Ee);if(He!==void 0){if(z.currentProgram===He&&z.lightsStateVersion===_e)return sh(y,fe),He}else fe.uniforms=le.getUniforms(y),L!==null&&y.isNodeMaterial&&L.build(y,H,fe),y.onBeforeCompile(fe,D),He=le.acquireProgram(fe,Ee),Ae.set(Ee,He),z.uniforms=fe.uniforms;const Te=z.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Te.clippingPlanes=Ce.uniform),sh(y,fe),z.needsLights=rf(y),z.lightsStateVersion=_e,z.needsLights&&(Te.ambientLightColor.value=B.state.ambient,Te.lightProbe.value=B.state.probe,Te.directionalLights.value=B.state.directional,Te.directionalLightShadows.value=B.state.directionalShadow,Te.spotLights.value=B.state.spot,Te.spotLightShadows.value=B.state.spotShadow,Te.rectAreaLights.value=B.state.rectArea,Te.ltc_1.value=B.state.rectAreaLTC1,Te.ltc_2.value=B.state.rectAreaLTC2,Te.pointLights.value=B.state.point,Te.pointLightShadows.value=B.state.pointShadow,Te.hemisphereLights.value=B.state.hemi,Te.directionalShadowMatrix.value=B.state.directionalShadowMatrix,Te.spotLightMatrix.value=B.state.spotLightMatrix,Te.spotLightMap.value=B.state.spotLightMap,Te.pointShadowMatrix.value=B.state.pointShadowMatrix),z.lightProbeGrid=b.state.lightProbeGridArray.length>0,z.currentProgram=He,z.uniformsList=null,He}function ih(y){if(y.uniformsList===null){const N=y.currentProgram.getUniforms();y.uniformsList=Ma.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function sh(y,N){const H=G.get(y);H.outputColorSpace=N.outputColorSpace,H.batching=N.batching,H.batchingColor=N.batchingColor,H.instancing=N.instancing,H.instancingColor=N.instancingColor,H.instancingMorph=N.instancingMorph,H.skinning=N.skinning,H.morphTargets=N.morphTargets,H.morphNormals=N.morphNormals,H.morphColors=N.morphColors,H.morphTargetsCount=N.morphTargetsCount,H.numClippingPlanes=N.numClippingPlanes,H.numIntersection=N.numClipIntersection,H.vertexAlphas=N.vertexAlphas,H.vertexTangents=N.vertexTangents,H.toneMapping=N.toneMapping}function tf(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let H=0,z=y.length;H<z;H++){const B=y[H];if(B.texture!==null&&B.boundingBox.containsPoint(M))return B}return null}function nf(y,N,H,z,B){N.isScene!==!0&&(N=dt),Y.resetTextureUnits();const pe=N.fog,_e=z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial?N.environment:null,fe=Q===null?D.outputColorSpace:Q.isXRRenderTarget===!0?Q.texture.colorSpace:Ye.workingColorSpace,Ee=z.isMeshStandardMaterial||z.isMeshLambertMaterial&&!z.envMap||z.isMeshPhongMaterial&&!z.envMap,Ae=ie.get(z.envMap||_e,Ee),ke=z.vertexColors===!0&&!!H.attributes.color&&H.attributes.color.itemSize===4,He=!!H.attributes.tangent&&(!!z.normalMap||z.anisotropy>0),Te=!!H.morphAttributes.position,tt=!!H.morphAttributes.normal,xt=!!H.morphAttributes.color;let vt=Fn;z.toneMapped&&(Q===null||Q.isXRRenderTarget===!0)&&(vt=D.toneMapping);const it=H.morphAttributes.position||H.morphAttributes.normal||H.morphAttributes.color,Ot=it!==void 0?it.length:0,ve=G.get(z),$t=b.state.lights;if(Ie===!0&&(Le===!0||y!==ee)){const lt=y===ee&&z.id===te;Ce.setState(z,y,lt)}let Ze=!1;z.version===ve.__version?(ve.needsLights&&ve.lightsStateVersion!==$t.state.version||ve.outputColorSpace!==fe||B.isBatchedMesh&&ve.batching===!1||!B.isBatchedMesh&&ve.batching===!0||B.isBatchedMesh&&ve.batchingColor===!0&&B.colorTexture===null||B.isBatchedMesh&&ve.batchingColor===!1&&B.colorTexture!==null||B.isInstancedMesh&&ve.instancing===!1||!B.isInstancedMesh&&ve.instancing===!0||B.isSkinnedMesh&&ve.skinning===!1||!B.isSkinnedMesh&&ve.skinning===!0||B.isInstancedMesh&&ve.instancingColor===!0&&B.instanceColor===null||B.isInstancedMesh&&ve.instancingColor===!1&&B.instanceColor!==null||B.isInstancedMesh&&ve.instancingMorph===!0&&B.morphTexture===null||B.isInstancedMesh&&ve.instancingMorph===!1&&B.morphTexture!==null||ve.envMap!==Ae||z.fog===!0&&ve.fog!==pe||ve.numClippingPlanes!==void 0&&(ve.numClippingPlanes!==Ce.numPlanes||ve.numIntersection!==Ce.numIntersection)||ve.vertexAlphas!==ke||ve.vertexTangents!==He||ve.morphTargets!==Te||ve.morphNormals!==tt||ve.morphColors!==xt||ve.toneMapping!==vt||ve.morphTargetsCount!==Ot||!!ve.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Ze=!0):(Ze=!0,ve.__version=z.version);let sn=ve.currentProgram;Ze===!0&&(sn=_r(z,N,B),L&&z.isNodeMaterial&&L.onUpdateProgram(z,sn,ve));let En=!1,ei=!1,Yi=!1;const st=sn.getUniforms(),Mt=ve.uniforms;if(v.useProgram(sn.program)&&(En=!0,ei=!0,Yi=!0),z.id!==te&&(te=z.id,ei=!0),ve.needsLights){const lt=tf(b.state.lightProbeGridArray,B);ve.lightProbeGrid!==lt&&(ve.lightProbeGrid=lt,ei=!0)}if(En||ee!==y){v.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),st.setValue(I,"projectionMatrix",y.projectionMatrix),st.setValue(I,"viewMatrix",y.matrixWorldInverse);const ni=st.map.cameraPosition;ni!==void 0&&ni.setValue(I,Je.setFromMatrixPosition(y.matrixWorld)),A.logarithmicDepthBuffer&&st.setValue(I,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(z.isMeshPhongMaterial||z.isMeshToonMaterial||z.isMeshLambertMaterial||z.isMeshBasicMaterial||z.isMeshStandardMaterial||z.isShaderMaterial)&&st.setValue(I,"isOrthographic",y.isOrthographicCamera===!0),ee!==y&&(ee=y,ei=!0,Yi=!0)}if(ve.needsLights&&($t.state.directionalShadowMap.length>0&&st.setValue(I,"directionalShadowMap",$t.state.directionalShadowMap,Y),$t.state.spotShadowMap.length>0&&st.setValue(I,"spotShadowMap",$t.state.spotShadowMap,Y),$t.state.pointShadowMap.length>0&&st.setValue(I,"pointShadowMap",$t.state.pointShadowMap,Y)),B.isSkinnedMesh){st.setOptional(I,B,"bindMatrix"),st.setOptional(I,B,"bindMatrixInverse");const lt=B.skeleton;lt&&(lt.boneTexture===null&<.computeBoneTexture(),st.setValue(I,"boneTexture",lt.boneTexture,Y))}B.isBatchedMesh&&(st.setOptional(I,B,"batchingTexture"),st.setValue(I,"batchingTexture",B._matricesTexture,Y),st.setOptional(I,B,"batchingIdTexture"),st.setValue(I,"batchingIdTexture",B._indirectTexture,Y),st.setOptional(I,B,"batchingColorTexture"),B._colorsTexture!==null&&st.setValue(I,"batchingColorTexture",B._colorsTexture,Y));const ti=H.morphAttributes;if((ti.position!==void 0||ti.normal!==void 0||ti.color!==void 0)&&P.update(B,H,sn),(ei||ve.receiveShadow!==B.receiveShadow)&&(ve.receiveShadow=B.receiveShadow,st.setValue(I,"receiveShadow",B.receiveShadow)),(z.isMeshStandardMaterial||z.isMeshLambertMaterial||z.isMeshPhongMaterial)&&z.envMap===null&&N.environment!==null&&(Mt.envMapIntensity.value=N.environmentIntensity),Mt.dfgLUT!==void 0&&(Mt.dfgLUT.value=f2()),ei){if(st.setValue(I,"toneMappingExposure",D.toneMappingExposure),ve.needsLights&&sf(Mt,Yi),pe&&z.fog===!0&&we.refreshFogUniforms(Mt,pe),we.refreshMaterialUniforms(Mt,z,ne,re,b.state.transmissionRenderTarget[y.id]),ve.needsLights&&ve.lightProbeGrid){const lt=ve.lightProbeGrid;Mt.probesSH.value=lt.texture,Mt.probesMin.value.copy(lt.boundingBox.min),Mt.probesMax.value.copy(lt.boundingBox.max),Mt.probesResolution.value.copy(lt.resolution)}Ma.upload(I,ih(ve),Mt,Y)}if(z.isShaderMaterial&&z.uniformsNeedUpdate===!0&&(Ma.upload(I,ih(ve),Mt,Y),z.uniformsNeedUpdate=!1),z.isSpriteMaterial&&st.setValue(I,"center",B.center),st.setValue(I,"modelViewMatrix",B.modelViewMatrix),st.setValue(I,"normalMatrix",B.normalMatrix),st.setValue(I,"modelMatrix",B.matrixWorld),z.uniformsGroups!==void 0){const lt=z.uniformsGroups;for(let ni=0,Ki=lt.length;ni<Ki;ni++){const rh=lt[ni];j.update(rh,sn),j.bind(rh,sn)}}return sn}function sf(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function rf(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 V},this.getRenderTarget=function(){return Q},this.setRenderTargetTextures=function(y,N,H){const z=G.get(y);z.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,z.__autoAllocateDepthBuffer===!1&&(z.__useRenderToTexture=!1),G.get(y.texture).__webglTexture=N,G.get(y.depthTexture).__webglTexture=z.__autoAllocateDepthBuffer?void 0:H,z.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){const H=G.get(y);H.__webglFramebuffer=N,H.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,H=0){Q=y,W=N,V=H;let z=null,B=!1,pe=!1;if(y){const fe=G.get(y);if(fe.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(I.FRAMEBUFFER,fe.__webglFramebuffer),se.copy(y.viewport),ge.copy(y.scissor),Ve=y.scissorTest,v.viewport(se),v.scissor(ge),v.setScissorTest(Ve),te=-1;return}else if(fe.__webglFramebuffer===void 0)Y.setupRenderTarget(y);else if(fe.__hasExternalTextures)Y.rebindTextures(y,G.get(y.texture).__webglTexture,G.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const ke=y.depthTexture;if(fe.__boundDepthTexture!==ke){if(ke!==null&&G.has(ke)&&(y.width!==ke.image.width||y.height!==ke.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");Y.setupDepthRenderbuffer(y)}}const Ee=y.texture;(Ee.isData3DTexture||Ee.isDataArrayTexture||Ee.isCompressedArrayTexture)&&(pe=!0);const Ae=G.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Ae[N])?z=Ae[N][H]:z=Ae[N],B=!0):y.samples>0&&Y.useMultisampledRTT(y)===!1?z=G.get(y).__webglMultisampledFramebuffer:Array.isArray(Ae)?z=Ae[H]:z=Ae,se.copy(y.viewport),ge.copy(y.scissor),Ve=y.scissorTest}else se.copy(Pe).multiplyScalar(ne).floor(),ge.copy(Re).multiplyScalar(ne).floor(),Ve=Me;if(H!==0&&(z=X),v.bindFramebuffer(I.FRAMEBUFFER,z)&&v.drawBuffers(y,z),v.viewport(se),v.scissor(ge),v.setScissorTest(Ve),B){const fe=G.get(y.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_CUBE_MAP_POSITIVE_X+N,fe.__webglTexture,H)}else if(pe){const fe=N;for(let Ee=0;Ee<y.textures.length;Ee++){const Ae=G.get(y.textures[Ee]);I.framebufferTextureLayer(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0+Ee,Ae.__webglTexture,H,fe)}}else if(y!==null&&H!==0){const fe=G.get(y.texture);I.framebufferTexture2D(I.FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,fe.__webglTexture,H)}te=-1},this.readRenderTargetPixels=function(y,N,H,z,B,pe,_e,fe=0){if(!(y&&y.isWebGLRenderTarget)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Ee=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(Ee=Ee[_e]),Ee){v.bindFramebuffer(I.FRAMEBUFFER,Ee);try{const Ae=y.textures[fe],ke=Ae.format,He=Ae.type;if(y.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+fe),!A.textureFormatReadable(ke)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!A.textureTypeReadable(He)){qe("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=y.width-z&&H>=0&&H<=y.height-B&&I.readPixels(N,H,z,B,he.convert(ke),he.convert(He),pe)}finally{const Ae=Q!==null?G.get(Q).__webglFramebuffer:null;v.bindFramebuffer(I.FRAMEBUFFER,Ae)}}},this.readRenderTargetPixelsAsync=async function(y,N,H,z,B,pe,_e,fe=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Ee=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&_e!==void 0&&(Ee=Ee[_e]),Ee)if(N>=0&&N<=y.width-z&&H>=0&&H<=y.height-B){v.bindFramebuffer(I.FRAMEBUFFER,Ee);const Ae=y.textures[fe],ke=Ae.format,He=Ae.type;if(y.textures.length>1&&I.readBuffer(I.COLOR_ATTACHMENT0+fe),!A.textureFormatReadable(ke))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!A.textureTypeReadable(He))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Te=I.createBuffer();I.bindBuffer(I.PIXEL_PACK_BUFFER,Te),I.bufferData(I.PIXEL_PACK_BUFFER,pe.byteLength,I.STREAM_READ),I.readPixels(N,H,z,B,he.convert(ke),he.convert(He),0);const tt=Q!==null?G.get(Q).__webglFramebuffer:null;v.bindFramebuffer(I.FRAMEBUFFER,tt);const xt=I.fenceSync(I.SYNC_GPU_COMMANDS_COMPLETE,0);return I.flush(),await Ip(I,xt,4),I.bindBuffer(I.PIXEL_PACK_BUFFER,Te),I.getBufferSubData(I.PIXEL_PACK_BUFFER,0,pe),I.deleteBuffer(Te),I.deleteSync(xt),pe}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,H=0){const z=Math.pow(2,-H),B=Math.floor(y.image.width*z),pe=Math.floor(y.image.height*z),_e=N!==null?N.x:0,fe=N!==null?N.y:0;Y.setTexture2D(y,0),I.copyTexSubImage2D(I.TEXTURE_2D,H,0,0,_e,fe,B,pe),v.unbindTexture()},this.copyTextureToTexture=function(y,N,H=null,z=null,B=0,pe=0){let _e,fe,Ee,Ae,ke,He,Te,tt,xt;const vt=y.isCompressedTexture?y.mipmaps[pe]:y.image;if(H!==null)_e=H.max.x-H.min.x,fe=H.max.y-H.min.y,Ee=H.isBox3?H.max.z-H.min.z:1,Ae=H.min.x,ke=H.min.y,He=H.isBox3?H.min.z:0;else{const Mt=Math.pow(2,-B);_e=Math.floor(vt.width*Mt),fe=Math.floor(vt.height*Mt),y.isDataArrayTexture?Ee=vt.depth:y.isData3DTexture?Ee=Math.floor(vt.depth*Mt):Ee=1,Ae=0,ke=0,He=0}z!==null?(Te=z.x,tt=z.y,xt=z.z):(Te=0,tt=0,xt=0);const it=he.convert(N.format),Ot=he.convert(N.type);let ve;N.isData3DTexture?(Y.setTexture3D(N,0),ve=I.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(Y.setTexture2DArray(N,0),ve=I.TEXTURE_2D_ARRAY):(Y.setTexture2D(N,0),ve=I.TEXTURE_2D),v.activeTexture(I.TEXTURE0),v.pixelStorei(I.UNPACK_FLIP_Y_WEBGL,N.flipY),v.pixelStorei(I.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),v.pixelStorei(I.UNPACK_ALIGNMENT,N.unpackAlignment);const $t=v.getParameter(I.UNPACK_ROW_LENGTH),Ze=v.getParameter(I.UNPACK_IMAGE_HEIGHT),sn=v.getParameter(I.UNPACK_SKIP_PIXELS),En=v.getParameter(I.UNPACK_SKIP_ROWS),ei=v.getParameter(I.UNPACK_SKIP_IMAGES);v.pixelStorei(I.UNPACK_ROW_LENGTH,vt.width),v.pixelStorei(I.UNPACK_IMAGE_HEIGHT,vt.height),v.pixelStorei(I.UNPACK_SKIP_PIXELS,Ae),v.pixelStorei(I.UNPACK_SKIP_ROWS,ke),v.pixelStorei(I.UNPACK_SKIP_IMAGES,He);const Yi=y.isDataArrayTexture||y.isData3DTexture,st=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){const Mt=G.get(y),ti=G.get(N),lt=G.get(Mt.__renderTarget),ni=G.get(ti.__renderTarget);v.bindFramebuffer(I.READ_FRAMEBUFFER,lt.__webglFramebuffer),v.bindFramebuffer(I.DRAW_FRAMEBUFFER,ni.__webglFramebuffer);for(let Ki=0;Ki<Ee;Ki++)Yi&&(I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(y).__webglTexture,B,He+Ki),I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,G.get(N).__webglTexture,pe,xt+Ki)),I.blitFramebuffer(Ae,ke,_e,fe,Te,tt,_e,fe,I.DEPTH_BUFFER_BIT,I.NEAREST);v.bindFramebuffer(I.READ_FRAMEBUFFER,null),v.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else if(B!==0||y.isRenderTargetTexture||G.has(y)){const Mt=G.get(y),ti=G.get(N);v.bindFramebuffer(I.READ_FRAMEBUFFER,q),v.bindFramebuffer(I.DRAW_FRAMEBUFFER,F);for(let lt=0;lt<Ee;lt++)Yi?I.framebufferTextureLayer(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,Mt.__webglTexture,B,He+lt):I.framebufferTexture2D(I.READ_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,Mt.__webglTexture,B),st?I.framebufferTextureLayer(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,ti.__webglTexture,pe,xt+lt):I.framebufferTexture2D(I.DRAW_FRAMEBUFFER,I.COLOR_ATTACHMENT0,I.TEXTURE_2D,ti.__webglTexture,pe),B!==0?I.blitFramebuffer(Ae,ke,_e,fe,Te,tt,_e,fe,I.COLOR_BUFFER_BIT,I.NEAREST):st?I.copyTexSubImage3D(ve,pe,Te,tt,xt+lt,Ae,ke,_e,fe):I.copyTexSubImage2D(ve,pe,Te,tt,Ae,ke,_e,fe);v.bindFramebuffer(I.READ_FRAMEBUFFER,null),v.bindFramebuffer(I.DRAW_FRAMEBUFFER,null)}else st?y.isDataTexture||y.isData3DTexture?I.texSubImage3D(ve,pe,Te,tt,xt,_e,fe,Ee,it,Ot,vt.data):N.isCompressedArrayTexture?I.compressedTexSubImage3D(ve,pe,Te,tt,xt,_e,fe,Ee,it,vt.data):I.texSubImage3D(ve,pe,Te,tt,xt,_e,fe,Ee,it,Ot,vt):y.isDataTexture?I.texSubImage2D(I.TEXTURE_2D,pe,Te,tt,_e,fe,it,Ot,vt.data):y.isCompressedTexture?I.compressedTexSubImage2D(I.TEXTURE_2D,pe,Te,tt,vt.width,vt.height,it,vt.data):I.texSubImage2D(I.TEXTURE_2D,pe,Te,tt,_e,fe,it,Ot,vt);v.pixelStorei(I.UNPACK_ROW_LENGTH,$t),v.pixelStorei(I.UNPACK_IMAGE_HEIGHT,Ze),v.pixelStorei(I.UNPACK_SKIP_PIXELS,sn),v.pixelStorei(I.UNPACK_SKIP_ROWS,En),v.pixelStorei(I.UNPACK_SKIP_IMAGES,ei),pe===0&&N.generateMipmaps&&I.generateMipmap(ve),v.unbindTexture()},this.initRenderTarget=function(y){G.get(y).__webglFramebuffer===void 0&&Y.setupRenderTarget(y)},this.initTexture=function(y){y.isCubeTexture?Y.setTextureCube(y,0):y.isData3DTexture?Y.setTexture3D(y,0):y.isDataArrayTexture||y.isCompressedArrayTexture?Y.setTexture2DArray(y,0):Y.setTexture2D(y,0),v.unbindTexture()},this.resetState=function(){W=0,V=0,Q=null,v.reset(),me.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Nn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(e){this._outputColorSpace=e;const t=this.getContext();t.drawingBufferColorSpace=Ye._getDrawingBufferColorSpace(e),t.unpackColorSpace=Ye._getUnpackColorSpace()}}const jl=Math.PI/180,yu=180/Math.PI;function mr(i,e,t){return Math.max(e,Math.min(t,i))}const ci=[{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 Fo(i,e,t){return i+(e-i)*t}function Pa(i,e,t){return[Fo(i[0],e[0],t),Fo(i[1],e[1],t),Fo(i[2],e[2],t)]}function c0(i){const e=Math.max(ci[0].altitudeDeg,Math.min(ci[ci.length-1].altitudeDeg,i));for(let n=0;n<ci.length-1;n++){const s=ci[n],r=ci[n+1];if(e>=s.altitudeDeg&&e<=r.altitudeDeg){const a=(e-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Pa(s.zenith,r.zenith,a),horizon:Pa(s.horizon,r.horizon,a)}}}const t=ci[ci.length-1];return{zenith:t.zenith,horizon:t.horizon}}const Su=-18,Eu=-4,m2=1.8;function bu(i){if(i<=Su)return ya;if(i>=0)return Eu;const e=i/Su;return ya-(ya-Eu)*(1-e)**m2}const g2=-1.5,ya=6.5,wu=ya,v2=1.6;function Oo(i){const e=(wu-i)/(wu-g2);return mr(e,0,1)**v2}function cn(i,e,t){const n=i*jl,s=e*jl,r=t*Math.cos(n);return{x:r*Math.sin(s),y:t*Math.sin(n),z:-r*Math.cos(s)}}function _2(i,e,t){const n=Math.sqrt(i*i+e*e+t*t),s=n===0?0:Math.asin(mr(e/n,-1,1))*yu,r=(Math.atan2(i,-t)*yu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function x2(i,e){const t=Math.abs(i-e)%360;return t>180?360-t:t}function M2(i,e,t){const n=Math.max(0,1-x2(i,e)/90),s=Math.max(0,1-Math.abs(t)/18);return n*s}function y2(i,e,t,n){const{zenith:s,horizon:r}=c0(n),a=mr((i+90)/180,0,1),o=Pa(r,s,a),l=M2(e,t,n);return l<=0?o:Pa(o,r,l*(1-a)*.8)}function zo(i){return .12+.88*i}const S2=-4;function E2(i){return Math.max(0,S2-i)}const b2=6,w2=60;function A2(i){return Math.min(w2,b2*Math.sqrt(i))}const T2=3,R2=.55;function C2(i){return R2*mr(i/T2,0,1)}function D2(i){const e=Math.max(i,-4),t=Math.sin(e*jl)+.50572*Math.pow(e+6.07995,-1.6364);return mr(1/t,1,40)}function fs(i){const e=D2(i)-1;return[1,Math.exp(-.022*e),Math.exp(-.062*e)]}const h0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function P2(i){return h0.findIndex(e=>i<=e.maxBrightness)}const I2=.25,Au=.3,L2=2.2;function N2(i,{phase:e,speedFactor:t},n){const r=1+I2*(Au+(1-Au)*i)*Math.sin(n*L2*t+e);return Math.min(1,Math.max(0,r))}/**
|
|
4678
|
+
}`;class A_{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(t,e){if(this.texture===null){const n=new f0(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 Be({vertexShader:b_,fragmentShader:w_,uniforms:{depthColor:{value:this.texture},depthWidth:{value:e.z},depthHeight:{value:e.w}}});this.mesh=new se(new qs(20,20),n)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class T_ extends ts{constructor(t,e){super();const n=this;let s=null,r=1,a=null,o="local-floor",c=1,l=null,h=null,u=null,d=null,f=null,g=null;const x=typeof XRWebGLBinding<"u",m=new A_,p={},w=e.getContextAttributes();let A=null,M=null;const S=[],b=[],R=new Ft;let _=null;const E=new cn;E.viewport=new pe;const D=new cn;D.viewport=new pe;const C=[E,D],I=new Om;let W=null,X=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Eo,S[Y]=rt),rt.getTargetRaySpace()},this.getControllerGrip=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Eo,S[Y]=rt),rt.getGripSpace()},this.getHand=function(Y){let rt=S[Y];return rt===void 0&&(rt=new Eo,S[Y]=rt),rt.getHandSpace()};function U(Y){const rt=b.indexOf(Y.inputSource);if(rt===-1)return;const nt=S[rt];nt!==void 0&&(nt.update(Y.inputSource,Y.frame,l||a),nt.dispatchEvent({type:Y.type,data:Y.inputSource}))}function q(){s.removeEventListener("select",U),s.removeEventListener("selectstart",U),s.removeEventListener("selectend",U),s.removeEventListener("squeeze",U),s.removeEventListener("squeezestart",U),s.removeEventListener("squeezeend",U),s.removeEventListener("end",q),s.removeEventListener("inputsourceschange",H);for(let Y=0;Y<S.length;Y++){const rt=b[Y];rt!==null&&(b[Y]=null,S[Y].disconnect(rt))}W=null,X=null,m.reset();for(const Y in p)delete p[Y];t.setRenderTarget(A),f=null,d=null,u=null,s=null,M=null,Bt.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&&Ot("WebXRManager: Cannot change framebuffer scale while presenting.")},this.setReferenceSpaceType=function(Y){o=Y,n.isPresenting===!0&&Ot("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&&x&&(u=new XRWebGLBinding(s,e)),u},this.getFrame=function(){return g},this.getSession=function(){return s},this.setSession=async function(Y){if(s=Y,s!==null){if(A=t.getRenderTarget(),s.addEventListener("select",U),s.addEventListener("selectstart",U),s.addEventListener("selectend",U),s.addEventListener("squeeze",U),s.addEventListener("squeezestart",U),s.addEventListener("squeezeend",U),s.addEventListener("end",q),s.addEventListener("inputsourceschange",H),w.xrCompatible!==!0&&await e.makeXRCompatible(),_=t.getPixelRatio(),t.getSize(R),x&&"createProjectionLayer"in XRWebGLBinding.prototype){let nt=null,z=null,bt=null;w.depth&&(bt=w.stencil?e.DEPTH24_STENCIL8:e.DEPTH_COMPONENT24,nt=w.stencil?qi:ai,z=w.stencil?Sr:Kn);const Dt={colorFormat:e.RGBA8,depthFormat:bt,scaleFactor:r};u=this.getBinding(),d=u.createProjectionLayer(Dt),s.updateRenderState({layers:[d]}),t.setPixelRatio(1),t.setSize(d.textureWidth,d.textureHeight,!1),M=new Rn(d.textureWidth,d.textureHeight,{format:un,type:ln,depthTexture:new Hs(d.textureWidth,d.textureHeight,z,void 0,void 0,void 0,void 0,void 0,void 0,nt),stencilBuffer:w.stencil,colorSpace:t.outputColorSpace,samples:w.antialias?4:0,resolveDepthBuffer:d.ignoreDepthValues===!1,resolveStencilBuffer:d.ignoreDepthValues===!1})}else{const nt={antialias:w.antialias,alpha:!0,depth:w.depth,stencil:w.stencil,framebufferScaleFactor:r};f=new XRWebGLLayer(s,e,nt),s.updateRenderState({baseLayer:f}),t.setPixelRatio(1),t.setSize(f.framebufferWidth,f.framebufferHeight,!1),M=new Rn(f.framebufferWidth,f.framebufferHeight,{format:un,type:ln,colorSpace:t.outputColorSpace,stencilBuffer:w.stencil,resolveDepthBuffer:f.ignoreDepthValues===!1,resolveStencilBuffer:f.ignoreDepthValues===!1})}M.isXRRenderTarget=!0,this.setFoveation(c),l=null,a=await s.requestReferenceSpace(o),Bt.setContext(s),Bt.start(),n.isPresenting=!0,n.dispatchEvent({type:"sessionstart"})}},this.getEnvironmentBlendMode=function(){if(s!==null)return s.environmentBlendMode},this.getDepthTexture=function(){return m.getDepthTexture()};function H(Y){for(let rt=0;rt<Y.removed.length;rt++){const nt=Y.removed[rt],z=b.indexOf(nt);z>=0&&(b[z]=null,S[z].disconnect(nt))}for(let rt=0;rt<Y.added.length;rt++){const nt=Y.added[rt];let z=b.indexOf(nt);if(z===-1){for(let Dt=0;Dt<S.length;Dt++)if(Dt>=b.length){b.push(nt),z=Dt;break}else if(b[Dt]===null){b[Dt]=nt,z=Dt;break}if(z===-1)break}const bt=S[z];bt&&bt.connect(nt)}}const $=new F,et=new F;function j(Y,rt,nt){$.setFromMatrixPosition(rt.matrixWorld),et.setFromMatrixPosition(nt.matrixWorld);const z=$.distanceTo(et),bt=rt.projectionMatrix.elements,Dt=nt.projectionMatrix.elements,At=bt[14]/(bt[10]-1),_t=bt[14]/(bt[10]+1),It=(bt[9]+1)/bt[5],Lt=(bt[9]-1)/bt[5],Nt=(bt[8]-1)/bt[0],Jt=(Dt[8]+1)/Dt[0],Qt=At*Nt,me=At*Jt,de=z/(-Nt+Jt),ge=de*-Nt;if(rt.matrixWorld.decompose(Y.position,Y.quaternion,Y.scale),Y.translateX(ge),Y.translateZ(de),Y.matrixWorld.compose(Y.position,Y.quaternion,Y.scale),Y.matrixWorldInverse.copy(Y.matrixWorld).invert(),bt[10]===-1)Y.projectionMatrix.copy(rt.projectionMatrix),Y.projectionMatrixInverse.copy(rt.projectionMatrixInverse);else{const be=At+de,L=_t+de,Je=Qt-ge,jt=me+(z-ge),T=It*_t/L*be,v=Lt*_t/L*be;Y.projectionMatrix.makePerspective(Je,jt,T,v,be,L),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(s===null)return;let rt=Y.near,nt=Y.far;m.texture!==null&&(m.depthNear>0&&(rt=m.depthNear),m.depthFar>0&&(nt=m.depthFar)),I.near=D.near=E.near=rt,I.far=D.far=E.far=nt,(W!==I.near||X!==I.far)&&(s.updateRenderState({depthNear:I.near,depthFar:I.far}),W=I.near,X=I.far),I.layers.mask=Y.layers.mask|6,E.layers.mask=I.layers.mask&-5,D.layers.mask=I.layers.mask&-3;const z=Y.parent,bt=I.cameras;it(I,z);for(let Dt=0;Dt<bt.length;Dt++)it(bt[Dt],z);bt.length===2?j(I,E,D):I.projectionMatrix.copy(E.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=ol*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 m.texture!==null},this.getDepthSensingMesh=function(){return m.getMesh(I)},this.getCameraTexture=function(Y){return p[Y]};let kt=null;function qt(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 It=nt[_t];let Lt=null;if(f!==null)Lt=f.getViewport(It);else{const Jt=u.getViewSubImage(d,It);Lt=Jt.viewport,_t===0&&(t.setRenderTargetTextures(M,Jt.colorTexture,Jt.depthStencilTexture),t.setRenderTarget(M))}let Nt=C[_t];Nt===void 0&&(Nt=new cn,Nt.layers.enable(_t),Nt.viewport=new pe,C[_t]=Nt),Nt.matrix.fromArray(It.transform.matrix),Nt.matrix.decompose(Nt.position,Nt.quaternion,Nt.scale),Nt.projectionMatrix.fromArray(It.projectionMatrix),Nt.projectionMatrixInverse.copy(Nt.projectionMatrix).invert(),Nt.viewport.set(Lt.x,Lt.y,Lt.width,Lt.height),_t===0&&(I.matrix.copy(Nt.matrix),I.matrix.decompose(I.position,I.quaternion,I.scale)),z===!0&&I.cameras.push(Nt)}const bt=s.enabledFeatures;if(bt&&bt.includes("depth-sensing")&&s.depthUsage=="gpu-optimized"&&x){u=n.getBinding();const _t=u.getDepthInformation(nt[0]);_t&&_t.isValid&&_t.texture&&m.init(_t,s.renderState)}if(bt&&bt.includes("camera-access")&&x){t.state.unbindTexture(),u=n.getBinding();for(let _t=0;_t<nt.length;_t++){const It=nt[_t].camera;if(It){let Lt=p[It];Lt||(Lt=new f0,p[It]=Lt);const Nt=u.getCameraImage(It);Lt.sourceTexture=Nt}}}}for(let nt=0;nt<S.length;nt++){const z=b[nt],bt=S[nt];z!==null&&bt!==void 0&&bt.update(z,rt,l||a)}kt&&kt(Y,rt),rt.detectedPlanes&&n.dispatchEvent({type:"planesdetected",data:rt}),g=null}const Bt=new _0;Bt.setAnimationLoop(qt),this.setAnimationLoop=function(Y){kt=Y},this.dispose=function(){}}}const R_=new he,w0=new zt;w0.set(-1,0,0,0,1,0,0,0,1);function C_(i,t){function e(m,p){m.matrixAutoUpdate===!0&&m.updateMatrix(),p.value.copy(m.matrix)}function n(m,p){p.color.getRGB(m.fogColor.value,p0(i)),p.isFog?(m.fogNear.value=p.near,m.fogFar.value=p.far):p.isFogExp2&&(m.fogDensity.value=p.density)}function s(m,p,w,A,M){p.isNodeMaterial?p.uniformsNeedUpdate=!1:p.isMeshBasicMaterial?r(m,p):p.isMeshLambertMaterial?(r(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshToonMaterial?(r(m,p),u(m,p)):p.isMeshPhongMaterial?(r(m,p),h(m,p),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)):p.isMeshStandardMaterial?(r(m,p),d(m,p),p.isMeshPhysicalMaterial&&f(m,p,M)):p.isMeshMatcapMaterial?(r(m,p),g(m,p)):p.isMeshDepthMaterial?r(m,p):p.isMeshDistanceMaterial?(r(m,p),x(m,p)):p.isMeshNormalMaterial?r(m,p):p.isLineBasicMaterial?(a(m,p),p.isLineDashedMaterial&&o(m,p)):p.isPointsMaterial?c(m,p,w,A):p.isSpriteMaterial?l(m,p):p.isShadowMaterial?(m.color.value.copy(p.color),m.opacity.value=p.opacity):p.isShaderMaterial&&(p.uniformsNeedUpdate=!1)}function r(m,p){m.opacity.value=p.opacity,p.color&&m.diffuse.value.copy(p.color),p.emissive&&m.emissive.value.copy(p.emissive).multiplyScalar(p.emissiveIntensity),p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.bumpMap&&(m.bumpMap.value=p.bumpMap,e(p.bumpMap,m.bumpMapTransform),m.bumpScale.value=p.bumpScale,p.side===Ce&&(m.bumpScale.value*=-1)),p.normalMap&&(m.normalMap.value=p.normalMap,e(p.normalMap,m.normalMapTransform),m.normalScale.value.copy(p.normalScale),p.side===Ce&&m.normalScale.value.negate()),p.displacementMap&&(m.displacementMap.value=p.displacementMap,e(p.displacementMap,m.displacementMapTransform),m.displacementScale.value=p.displacementScale,m.displacementBias.value=p.displacementBias),p.emissiveMap&&(m.emissiveMap.value=p.emissiveMap,e(p.emissiveMap,m.emissiveMapTransform)),p.specularMap&&(m.specularMap.value=p.specularMap,e(p.specularMap,m.specularMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest);const w=t.get(p),A=w.envMap,M=w.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(R_.makeRotationFromEuler(M)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(w0),m.reflectivity.value=p.reflectivity,m.ior.value=p.ior,m.refractionRatio.value=p.refractionRatio),p.lightMap&&(m.lightMap.value=p.lightMap,m.lightMapIntensity.value=p.lightMapIntensity,e(p.lightMap,m.lightMapTransform)),p.aoMap&&(m.aoMap.value=p.aoMap,m.aoMapIntensity.value=p.aoMapIntensity,e(p.aoMap,m.aoMapTransform))}function a(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform))}function o(m,p){m.dashSize.value=p.dashSize,m.totalSize.value=p.dashSize+p.gapSize,m.scale.value=p.scale}function c(m,p,w,A){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.size.value=p.size*w,m.scale.value=A*.5,p.map&&(m.map.value=p.map,e(p.map,m.uvTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function l(m,p){m.diffuse.value.copy(p.color),m.opacity.value=p.opacity,m.rotation.value=p.rotation,p.map&&(m.map.value=p.map,e(p.map,m.mapTransform)),p.alphaMap&&(m.alphaMap.value=p.alphaMap,e(p.alphaMap,m.alphaMapTransform)),p.alphaTest>0&&(m.alphaTest.value=p.alphaTest)}function h(m,p){m.specular.value.copy(p.specular),m.shininess.value=Math.max(p.shininess,1e-4)}function u(m,p){p.gradientMap&&(m.gradientMap.value=p.gradientMap)}function d(m,p){m.metalness.value=p.metalness,p.metalnessMap&&(m.metalnessMap.value=p.metalnessMap,e(p.metalnessMap,m.metalnessMapTransform)),m.roughness.value=p.roughness,p.roughnessMap&&(m.roughnessMap.value=p.roughnessMap,e(p.roughnessMap,m.roughnessMapTransform)),p.envMap&&(m.envMapIntensity.value=p.envMapIntensity)}function f(m,p,w){m.ior.value=p.ior,p.sheen>0&&(m.sheenColor.value.copy(p.sheenColor).multiplyScalar(p.sheen),m.sheenRoughness.value=p.sheenRoughness,p.sheenColorMap&&(m.sheenColorMap.value=p.sheenColorMap,e(p.sheenColorMap,m.sheenColorMapTransform)),p.sheenRoughnessMap&&(m.sheenRoughnessMap.value=p.sheenRoughnessMap,e(p.sheenRoughnessMap,m.sheenRoughnessMapTransform))),p.clearcoat>0&&(m.clearcoat.value=p.clearcoat,m.clearcoatRoughness.value=p.clearcoatRoughness,p.clearcoatMap&&(m.clearcoatMap.value=p.clearcoatMap,e(p.clearcoatMap,m.clearcoatMapTransform)),p.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=p.clearcoatRoughnessMap,e(p.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),p.clearcoatNormalMap&&(m.clearcoatNormalMap.value=p.clearcoatNormalMap,e(p.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(p.clearcoatNormalScale),p.side===Ce&&m.clearcoatNormalScale.value.negate())),p.dispersion>0&&(m.dispersion.value=p.dispersion),p.iridescence>0&&(m.iridescence.value=p.iridescence,m.iridescenceIOR.value=p.iridescenceIOR,m.iridescenceThicknessMinimum.value=p.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=p.iridescenceThicknessRange[1],p.iridescenceMap&&(m.iridescenceMap.value=p.iridescenceMap,e(p.iridescenceMap,m.iridescenceMapTransform)),p.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=p.iridescenceThicknessMap,e(p.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),p.transmission>0&&(m.transmission.value=p.transmission,m.transmissionSamplerMap.value=w.texture,m.transmissionSamplerSize.value.set(w.width,w.height),p.transmissionMap&&(m.transmissionMap.value=p.transmissionMap,e(p.transmissionMap,m.transmissionMapTransform)),m.thickness.value=p.thickness,p.thicknessMap&&(m.thicknessMap.value=p.thicknessMap,e(p.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=p.attenuationDistance,m.attenuationColor.value.copy(p.attenuationColor)),p.anisotropy>0&&(m.anisotropyVector.value.set(p.anisotropy*Math.cos(p.anisotropyRotation),p.anisotropy*Math.sin(p.anisotropyRotation)),p.anisotropyMap&&(m.anisotropyMap.value=p.anisotropyMap,e(p.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=p.specularIntensity,m.specularColor.value.copy(p.specularColor),p.specularColorMap&&(m.specularColorMap.value=p.specularColorMap,e(p.specularColorMap,m.specularColorMapTransform)),p.specularIntensityMap&&(m.specularIntensityMap.value=p.specularIntensityMap,e(p.specularIntensityMap,m.specularIntensityMapTransform))}function g(m,p){p.matcap&&(m.matcap.value=p.matcap)}function x(m,p){const w=t.get(p).light;m.referencePosition.value.setFromMatrixPosition(w.matrixWorld),m.nearDistance.value=w.shadow.camera.near,m.farDistance.value=w.shadow.camera.far}return{refreshFogUniforms:n,refreshMaterialUniforms:s}}function D_(i,t,e,n){let s={},r={},a=[];const o=i.getParameter(i.MAX_UNIFORM_BUFFER_BINDINGS);function c(M,S){const b=S.program;n.uniformBlockBinding(M,b)}function l(M,S){let b=s[M.id];b===void 0&&(m(M),b=h(M),s[M.id]=b,M.addEventListener("dispose",w));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 b=i.createBuffer(),R=M.__size,_=M.usage;return i.bindBuffer(i.UNIFORM_BUFFER,b),i.bufferData(i.UNIFORM_BUFFER,R,_),i.bindBuffer(i.UNIFORM_BUFFER,null),i.bindBufferBase(i.UNIFORM_BUFFER,S,b),b}function u(){for(let M=0;M<o;M++)if(a.indexOf(M)===-1)return a.push(M),M;return Yt("WebGLRenderer: Maximum number of simultaneously usable uniforms groups reached."),0}function d(M){const S=s[M.id],b=M.uniforms,R=M.__cache;i.bindBuffer(i.UNIFORM_BUFFER,S);for(let _=0,E=b.length;_<E;_++){const D=b[_];if(Array.isArray(D))for(let C=0,I=D.length;C<I;C++)f(D[C],_,C,R);else f(D,_,0,R)}i.bindBuffer(i.UNIFORM_BUFFER,null)}function f(M,S,b,R){if(x(M,S,b,R)===!0){const _=M.__offset,E=M.value;if(Array.isArray(E)){let D=0;for(let C=0;C<E.length;C++){const I=E[C],W=p(I);g(I,M.__data,D),typeof I!="number"&&typeof I!="boolean"&&!I.isMatrix3&&!ArrayBuffer.isView(I)&&(D+=W.storage/Float32Array.BYTES_PER_ELEMENT)}}else g(E,M.__data,0);i.bufferSubData(i.UNIFORM_BUFFER,_,M.__data)}}function g(M,S,b){typeof M=="number"||typeof M=="boolean"?S[0]=M:M.isMatrix3?(S[0]=M.elements[0],S[1]=M.elements[1],S[2]=M.elements[2],S[3]=0,S[4]=M.elements[3],S[5]=M.elements[4],S[6]=M.elements[5],S[7]=0,S[8]=M.elements[6],S[9]=M.elements[7],S[10]=M.elements[8],S[11]=0):ArrayBuffer.isView(M)?S.set(new M.constructor(M.buffer,M.byteOffset,S.length)):M.toArray(S,b)}function x(M,S,b,R){const _=M.value,E=S+"_"+b;if(R[E]===void 0)return typeof _=="number"||typeof _=="boolean"?R[E]=_:ArrayBuffer.isView(_)?R[E]=_.slice():R[E]=_.clone(),!0;{const D=R[E];if(typeof _=="number"||typeof _=="boolean"){if(D!==_)return R[E]=_,!0}else{if(ArrayBuffer.isView(_))return!0;if(D.equals(_)===!1)return D.copy(_),!0}}return!1}function m(M){const S=M.uniforms;let b=0;const R=16;for(let E=0,D=S.length;E<D;E++){const C=Array.isArray(S[E])?S[E]:[S[E]];for(let I=0,W=C.length;I<W;I++){const X=C[I],U=Array.isArray(X.value)?X.value:[X.value];for(let q=0,H=U.length;q<H;q++){const $=U[q],et=p($),j=b%R,it=j%et.boundary,ut=j+it;b+=it,ut!==0&&R-ut<et.storage&&(b+=R-ut),X.__data=new Float32Array(et.storage/Float32Array.BYTES_PER_ELEMENT),X.__offset=b,b+=et.storage}}}const _=b%R;return _>0&&(b+=R-_),M.__size=b,M.__cache={},this}function p(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?Ot("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(M)?(S.boundary=16,S.storage=M.byteLength):Ot("WebGLRenderer: Unsupported uniform value type.",M),S}function w(M){const S=M.target;S.removeEventListener("dispose",w);const b=a.indexOf(S.__bindingPointIndex);a.splice(b,1),i.deleteBuffer(s[S.id]),delete s[S.id],delete r[S.id]}function A(){for(const M in s)i.deleteBuffer(s[M]);a=[],s={},r={}}return{bind:c,update:l,dispose:A}}const P_=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 Nn=null;function I_(){return Nn===null&&(Nn=new jl(P_,16,16,$i,xn),Nn.name="DFG_LUT",Nn.minFilter=Te,Nn.magFilter=Te,Nn.wrapS=hn,Nn.wrapT=hn,Nn.generateMipmaps=!1,Nn.needsUpdate=!0),Nn}class L_{constructor(t={}){const{canvas:e=Kp(),context:n=null,depth:s=!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=ln}=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 x=f,m=new Set([ql,Xl,Wl]),p=new Set([ln,Kn,yr,Sr,Hl,Vl]),w=new Uint32Array(4),A=new Int32Array(4),M=new F;let S=null,b=null;const R=[],_=[];let E=null;this.domElement=e,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=qn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const D=this;let C=!1,I=null,W=null,X=null,U=null;this._outputColorSpace=vn;let q=0,H=0,$=null,et=-1,j=null;const it=new pe,ut=new pe;let kt=null;const qt=new Mt(0);let Bt=0,Y=e.width,rt=e.height,nt=1,z=null,bt=null;const Dt=new pe(0,0,Y,rt),At=new pe(0,0,Y,rt);let _t=!1;const It=new th;let Lt=!1,Nt=!1;const Jt=new he,Qt=new F,me=new pe,de={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ge=!1;function be(){return $===null?nt:1}let L=n;function Je(y,N){return e.getContext(y,N)}try{const y={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:c,preserveDrawingBuffer:l,powerPreference:h,failIfMajorPerformanceCaveat:u};if("setAttribute"in e&&e.setAttribute("data-engine",`three.js r${Bl}`),e.addEventListener("webglcontextlost",ve,!1),e.addEventListener("webglcontextrestored",oe,!1),e.addEventListener("webglcontextcreationerror",Dn,!1),L===null){const N="webgl2";if(L=Je(N,y),L===null)throw Je(N)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(y){throw Yt("WebGLRenderer: "+y.message),y}let jt,T,v,O,G,K,st,ot,Z,Q,ct,Tt,dt,lt,Pt,Ut,Gt,P,at,J,ht,gt,tt;function wt(){jt=new Iv(L),jt.init(),ht=new E_(L,jt),T=new bv(L,jt,t,ht),v=new y_(L,jt),T.reversedDepthBuffer&&d&&v.buffers.depth.setReversed(!0),W=L.createFramebuffer(),X=L.createFramebuffer(),U=L.createFramebuffer(),O=new Uv(L),G=new o_,K=new S_(L,jt,v,G,T,ht,O),st=new Pv(D),ot=new Bm(L),gt=new Sv(L,ot),Z=new Lv(L,ot,O,gt),Q=new Ov(L,Z,ot,gt,O),P=new Fv(L,T,K),Pt=new wv(G),ct=new a_(D,st,jt,T,gt,Pt),Tt=new C_(D,G),dt=new l_,lt=new m_(jt),Gt=new yv(D,st,v,Q,g,c),Ut=new M_(D,Q,T),tt=new D_(L,O,T,v),at=new Ev(L,jt,O),J=new Nv(L,jt,O),O.programs=ct.programs,D.capabilities=T,D.extensions=jt,D.properties=G,D.renderLists=dt,D.shadowMap=Ut,D.state=v,D.info=O}wt(),x!==ln&&(E=new Bv(x,e.width,e.height,o,s,r));const yt=new T_(D,L);this.xr=yt,this.getContext=function(){return L},this.getContextAttributes=function(){return L.getContextAttributes()},this.forceContextLoss=function(){const y=jt.get("WEBGL_lose_context");y&&y.loseContext()},this.forceContextRestore=function(){const y=jt.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,N,V=!0){if(yt.isPresenting){Ot("WebGLRenderer: Can't change size while VR device is presenting.");return}Y=y,rt=N,e.width=Math.floor(y*nt),e.height=Math.floor(N*nt),V===!0&&(e.style.width=y+"px",e.style.height=N+"px"),E!==null&&E.setSize(e.width,e.height),this.setViewport(0,0,y,N)},this.getDrawingBufferSize=function(y){return y.set(Y*nt,rt*nt).floor()},this.setDrawingBufferSize=function(y,N,V){Y=y,rt=N,nt=V,e.width=Math.floor(y*V),e.height=Math.floor(N*V),this.setViewport(0,0,y,N)},this.setEffects=function(y){if(x===ln){Yt("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(y){for(let N=0;N<y.length;N++)if(y[N].isOutputPass===!0){Ot("WebGLRenderer: OutputPass is not needed in setEffects(). Tone mapping and color space conversion are applied automatically.");break}}E.setEffects(y||[])},this.getCurrentViewport=function(y){return y.copy(it)},this.getViewport=function(y){return y.copy(Dt)},this.setViewport=function(y,N,V,B){y.isVector4?Dt.set(y.x,y.y,y.z,y.w):Dt.set(y,N,V,B),v.viewport(it.copy(Dt).multiplyScalar(nt).round())},this.getScissor=function(y){return y.copy(At)},this.setScissor=function(y,N,V,B){y.isVector4?At.set(y.x,y.y,y.z,y.w):At.set(y,N,V,B),v.scissor(ut.copy(At).multiplyScalar(nt).round())},this.getScissorTest=function(){return _t},this.setScissorTest=function(y){v.setScissorTest(_t=y)},this.setOpaqueSort=function(y){z=y},this.setTransparentSort=function(y){bt=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,N=!0,V=!0){let B=0;if(y){let k=!1;if($!==null){const mt=$.texture.format;k=m.has(mt)}if(k){const mt=$.texture.type,xt=p.has(mt),pt=Gt.getClearColor(),Et=Gt.getClearAlpha(),Rt=pt.r,Ht=pt.g,Wt=pt.b;xt?(w[0]=Rt,w[1]=Ht,w[2]=Wt,w[3]=Et,L.clearBufferuiv(L.COLOR,0,w)):(A[0]=Rt,A[1]=Ht,A[2]=Wt,A[3]=Et,L.clearBufferiv(L.COLOR,0,A))}else B|=L.COLOR_BUFFER_BIT}N&&(B|=L.DEPTH_BUFFER_BIT,this.state.buffers.depth.setMask(!0)),V&&(B|=L.STENCIL_BUFFER_BIT,this.state.buffers.stencil.setMask(4294967295)),B!==0&&L.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",ve,!1),e.removeEventListener("webglcontextrestored",oe,!1),e.removeEventListener("webglcontextcreationerror",Dn,!1),Gt.dispose(),dt.dispose(),lt.dispose(),G.dispose(),st.dispose(),Q.dispose(),gt.dispose(),tt.dispose(),ct.dispose(),yt.dispose(),yt.removeEventListener("sessionstart",dh),yt.removeEventListener("sessionend",fh),Ii.stop()};function ve(y){y.preventDefault(),Ga("WebGLRenderer: Context Lost."),C=!0}function oe(){Ga("WebGLRenderer: Context Restored."),C=!1;const y=O.autoReset,N=Ut.enabled,V=Ut.autoUpdate,B=Ut.needsUpdate,k=Ut.type;wt(),O.autoReset=y,Ut.enabled=N,Ut.autoUpdate=V,Ut.needsUpdate=B,Ut.type=k}function Dn(y){Yt("WebGLRenderer: A WebGL context could not be created. Reason: ",y.statusMessage)}function Pn(y){const N=y.target;N.removeEventListener("dispose",Pn),gf(N)}function gf(y){vf(y),G.remove(y)}function vf(y){const N=G.get(y).programs;N!==void 0&&(N.forEach(function(V){ct.releaseProgram(V)}),y.isShaderMaterial&&ct.releaseShaderCache(y))}this.renderBufferDirect=function(y,N,V,B,k,mt){N===null&&(N=de);const xt=k.isMesh&&k.matrixWorld.determinantAffine()<0,pt=Mf(y,N,V,B,k);v.setMaterial(B,xt);let Et=V.index,Rt=1;if(B.wireframe===!0){if(Et=Z.getWireframeAttribute(V),Et===void 0)return;Rt=2}const Ht=V.drawRange,Wt=V.attributes.position;let Ct=Ht.start*Rt,ne=(Ht.start+Ht.count)*Rt;mt!==null&&(Ct=Math.max(Ct,mt.start*Rt),ne=Math.min(ne,(mt.start+mt.count)*Rt)),Et!==null?(Ct=Math.max(Ct,0),ne=Math.min(ne,Et.count)):Wt!=null&&(Ct=Math.max(Ct,0),ne=Math.min(ne,Wt.count));const Me=ne-Ct;if(Me<0||Me===1/0)return;gt.setup(k,B,pt,V,Et);let _e,re=at;if(Et!==null&&(_e=ot.get(Et),re=J,re.setIndex(_e)),k.isMesh)B.wireframe===!0?(v.setLineWidth(B.wireframeLinewidth*be()),re.setMode(L.LINES)):re.setMode(L.TRIANGLES);else if(k.isLine){let Ge=B.linewidth;Ge===void 0&&(Ge=1),v.setLineWidth(Ge*be()),k.isLineSegments?re.setMode(L.LINES):k.isLineLoop?re.setMode(L.LINE_LOOP):re.setMode(L.LINE_STRIP)}else k.isPoints?re.setMode(L.POINTS):k.isSprite&&re.setMode(L.TRIANGLES);if(k.isBatchedMesh)if(jt.get("WEBGL_multi_draw"))re.renderMultiDraw(k._multiDrawStarts,k._multiDrawCounts,k._multiDrawCount);else{const Ge=k._multiDrawStarts,vt=k._multiDrawCounts,en=k._multiDrawCount,Zt=Et?ot.get(Et).bytesPerElement:1,dn=G.get(B).currentProgram.getUniforms();for(let In=0;In<en;In++)dn.setValue(L,"_gl_DrawID",In),re.render(Ge[In]/Zt,vt[In])}else if(k.isInstancedMesh)re.renderInstances(Ct,Me,k.count);else if(V.isInstancedBufferGeometry){const Ge=V._maxInstanceCount!==void 0?V._maxInstanceCount:1/0,vt=Math.min(V.instanceCount,Ge);re.renderInstances(Ct,Me,vt)}else re.render(Ct,Me)};function uh(y,N,V){y.transparent===!0&&y.side===wn&&y.forceSinglePass===!1?(y.side=Ce,y.needsUpdate=!0,Dr(y,N,V),y.side=Ti,y.needsUpdate=!0,Dr(y,N,V),y.side=wn):Dr(y,N,V)}this.compile=function(y,N,V=null){V===null&&(V=y),b=lt.get(V),b.init(N),_.push(b),V.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),y!==V&&y.traverseVisible(function(k){k.isLight&&k.layers.test(N.layers)&&(b.pushLight(k),k.castShadow&&b.pushShadow(k))}),b.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 xt=0;xt<mt.length;xt++){const pt=mt[xt];uh(pt,V,k),B.add(pt)}else uh(mt,V,k),B.add(mt)}),b=_.pop(),B},this.compileAsync=function(y,N,V=null){const B=this.compile(y,N,V);return new Promise(k=>{function mt(){if(B.forEach(function(xt){G.get(xt).currentProgram.isReady()&&B.delete(xt)}),B.size===0){k(y);return}setTimeout(mt,10)}jt.get("KHR_parallel_shader_compile")!==null?mt():setTimeout(mt,10)})};let lo=null;function _f(y){lo&&lo(y)}function dh(){Ii.stop()}function fh(){Ii.start()}const Ii=new _0;Ii.setAnimationLoop(_f),typeof self<"u"&&Ii.setContext(self),this.setAnimationLoop=function(y){lo=y,yt.setAnimationLoop(y),y===null?Ii.stop():Ii.start()},yt.addEventListener("sessionstart",dh),yt.addEventListener("sessionend",fh),this.render=function(y,N){if(N!==void 0&&N.isCamera!==!0){Yt("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(C===!0)return;I!==null&&I.renderStart(y,N);const V=yt.enabled===!0&&yt.isPresenting===!0,B=E!==null&&($===null||V)&&E.begin(D,$);if(y.matrixWorldAutoUpdate===!0&&y.updateMatrixWorld(),N.parent===null&&N.matrixWorldAutoUpdate===!0&&N.updateMatrixWorld(),yt.enabled===!0&&yt.isPresenting===!0&&(E===null||E.isCompositing()===!1)&&(yt.cameraAutoUpdate===!0&&yt.updateCamera(N),N=yt.getCamera()),y.isScene===!0&&y.onBeforeRender(D,y,N,$),b=lt.get(y,_.length),b.init(N),b.state.textureUnits=K.getTextureUnits(),_.push(b),Jt.multiplyMatrices(N.projectionMatrix,N.matrixWorldInverse),It.setFromProjectionMatrix(Jt,Wn,N.reversedDepth),Nt=this.localClippingEnabled,Lt=Pt.init(this.clippingPlanes,Nt),S=dt.get(y,R.length),S.init(),R.push(S),yt.enabled===!0&&yt.isPresenting===!0){const xt=D.xr.getDepthSensingMesh();xt!==null&&ho(xt,N,-1/0,D.sortObjects)}ho(y,N,0,D.sortObjects),S.finish(),D.sortObjects===!0&&S.sort(z,bt,N.reversedDepth),ge=yt.enabled===!1||yt.isPresenting===!1||yt.hasDepthSensing()===!1,ge&&Gt.addToRenderList(S,y),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Lt===!0&&Pt.beginShadows();const k=b.state.shadowsArray;if(Ut.render(k,y,N),Lt===!0&&Pt.endShadows(),(B&&E.hasRenderPass())===!1){const xt=S.opaque,pt=S.transmissive;if(b.setupLights(),N.isArrayCamera){const Et=N.cameras;if(pt.length>0)for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];mh(xt,pt,y,Wt)}ge&&Gt.render(y);for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt];ph(S,y,Wt,Wt.viewport)}}else pt.length>0&&mh(xt,pt,y,N),ge&&Gt.render(y),ph(S,y,N)}$!==null&&H===0&&(K.updateMultisampleRenderTarget($),K.updateRenderTargetMipmap($)),B&&E.end(D),y.isScene===!0&&y.onAfterRender(D,y,N),gt.resetDefaultState(),et=-1,j=null,_.pop(),_.length>0?(b=_[_.length-1],K.setTextureUnits(b.state.textureUnits),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,b.state.camera)):b=null,R.pop(),R.length>0?S=R[R.length-1]:S=null,I!==null&&I.renderEnd()};function ho(y,N,V,B){if(y.visible===!1)return;if(y.layers.test(N.layers)){if(y.isGroup)V=y.renderOrder;else if(y.isLOD)y.autoUpdate===!0&&y.update(N);else if(y.isLightProbeGrid)b.pushLightProbeGrid(y);else if(y.isLight)b.pushLight(y),y.castShadow&&b.pushShadow(y);else if(y.isSprite){if(!y.frustumCulled||It.intersectsSprite(y)){B&&me.setFromMatrixPosition(y.matrixWorld).applyMatrix4(Jt);const xt=Q.update(y),pt=y.material;pt.visible&&S.push(y,xt,pt,V,me.z,null)}}else if((y.isMesh||y.isLine||y.isPoints)&&(!y.frustumCulled||It.intersectsObject(y))){const xt=Q.update(y),pt=y.material;if(B&&(y.boundingSphere!==void 0?(y.boundingSphere===null&&y.computeBoundingSphere(),me.copy(y.boundingSphere.center)):(xt.boundingSphere===null&&xt.computeBoundingSphere(),me.copy(xt.boundingSphere.center)),me.applyMatrix4(y.matrixWorld).applyMatrix4(Jt)),Array.isArray(pt)){const Et=xt.groups;for(let Rt=0,Ht=Et.length;Rt<Ht;Rt++){const Wt=Et[Rt],Ct=pt[Wt.materialIndex];Ct&&Ct.visible&&S.push(y,xt,Ct,V,me.z,Wt)}}else pt.visible&&S.push(y,xt,pt,V,me.z,null)}}const mt=y.children;for(let xt=0,pt=mt.length;xt<pt;xt++)ho(mt[xt],N,V,B)}function ph(y,N,V,B){const{opaque:k,transmissive:mt,transparent:xt}=y;b.setupLightsView(V),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,V),B&&v.viewport(it.copy(B)),k.length>0&&Cr(k,N,V),mt.length>0&&Cr(mt,N,V),xt.length>0&&Cr(xt,N,V),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function mh(y,N,V,B){if((V.isScene===!0?V.overrideMaterial:null)!==null)return;if(b.state.transmissionRenderTarget[B.id]===void 0){const Ct=jt.has("EXT_color_buffer_half_float")||jt.has("EXT_color_buffer_float");b.state.transmissionRenderTarget[B.id]=new Rn(1,1,{generateMipmaps:!0,type:Ct?xn:ln,minFilter:Xi,samples:Math.max(4,T.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:Kt.workingColorSpace})}const mt=b.state.transmissionRenderTarget[B.id],xt=B.viewport||it;mt.setSize(xt.z*D.transmissionResolutionScale,xt.w*D.transmissionResolutionScale);const pt=D.getRenderTarget(),Et=D.getActiveCubeFace(),Rt=D.getActiveMipmapLevel();D.setRenderTarget(mt),D.getClearColor(qt),Bt=D.getClearAlpha(),Bt<1&&D.setClearColor(16777215,.5),D.clear(),ge&&Gt.render(V);const Ht=D.toneMapping;D.toneMapping=qn;const Wt=B.viewport;if(B.viewport!==void 0&&(B.viewport=void 0),b.setupLightsView(B),Lt===!0&&Pt.setGlobalState(D.clippingPlanes,B),Cr(y,V,B),K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt),jt.has("WEBGL_multisampled_render_to_texture")===!1){let Ct=!1;for(let ne=0,Me=N.length;ne<Me;ne++){const _e=N[ne],{object:re,geometry:Ge,material:vt,group:en}=_e;if(vt.side===wn&&re.layers.test(B.layers)){const Zt=vt.side;vt.side=Ce,vt.needsUpdate=!0,gh(re,V,B,Ge,vt,en),vt.side=Zt,vt.needsUpdate=!0,Ct=!0}}Ct===!0&&(K.updateMultisampleRenderTarget(mt),K.updateRenderTargetMipmap(mt))}D.setRenderTarget(pt,Et,Rt),D.setClearColor(qt,Bt),Wt!==void 0&&(B.viewport=Wt),D.toneMapping=Ht}function Cr(y,N,V){const B=N.isScene===!0?N.overrideMaterial:null;for(let k=0,mt=y.length;k<mt;k++){const xt=y[k],{object:pt,geometry:Et,group:Rt}=xt;let Ht=xt.material;Ht.allowOverride===!0&&B!==null&&(Ht=B),pt.layers.test(V.layers)&&gh(pt,N,V,Et,Ht,Rt)}}function gh(y,N,V,B,k,mt){y.onBeforeRender(D,N,V,B,k,mt),y.modelViewMatrix.multiplyMatrices(V.matrixWorldInverse,y.matrixWorld),y.normalMatrix.getNormalMatrix(y.modelViewMatrix),k.onBeforeRender(D,N,V,B,y,mt),k.transparent===!0&&k.side===wn&&k.forceSinglePass===!1?(k.side=Ce,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,mt),k.side=Ti,k.needsUpdate=!0,D.renderBufferDirect(V,N,B,k,y,mt),k.side=wn):D.renderBufferDirect(V,N,B,k,y,mt),y.onAfterRender(D,N,V,B,k,mt)}function Dr(y,N,V){N.isScene!==!0&&(N=de);const B=G.get(y),k=b.state.lights,mt=b.state.shadowsArray,xt=k.state.version,pt=ct.getParameters(y,k.state,mt,N,V,b.state.lightProbeGridArray),Et=ct.getProgramCacheKey(pt);let Rt=B.programs;B.environment=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?N.environment:null,B.fog=N.fog;const Ht=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap;B.envMap=st.get(y.envMap||B.environment,Ht),B.envMapRotation=B.environment!==null&&y.envMap===null?N.environmentRotation:y.envMapRotation,Rt===void 0&&(y.addEventListener("dispose",Pn),Rt=new Map,B.programs=Rt);let Wt=Rt.get(Et);if(Wt!==void 0){if(B.currentProgram===Wt&&B.lightsStateVersion===xt)return _h(y,pt),Wt}else pt.uniforms=ct.getUniforms(y),I!==null&&y.isNodeMaterial&&I.build(y,V,pt),y.onBeforeCompile(pt,D),Wt=ct.acquireProgram(pt,Et),Rt.set(Et,Wt),B.uniforms=pt.uniforms;const Ct=B.uniforms;return(!y.isShaderMaterial&&!y.isRawShaderMaterial||y.clipping===!0)&&(Ct.clippingPlanes=Pt.uniform),_h(y,pt),B.needsLights=Sf(y),B.lightsStateVersion=xt,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=b.state.lightProbeGridArray.length>0,B.currentProgram=Wt,B.uniformsList=null,Wt}function vh(y){if(y.uniformsList===null){const N=y.currentProgram.getUniforms();y.uniformsList=Ia.seqWithValue(N.seq,y.uniforms)}return y.uniformsList}function _h(y,N){const V=G.get(y);V.outputColorSpace=N.outputColorSpace,V.batching=N.batching,V.batchingColor=N.batchingColor,V.instancing=N.instancing,V.instancingColor=N.instancingColor,V.instancingMorph=N.instancingMorph,V.skinning=N.skinning,V.morphTargets=N.morphTargets,V.morphNormals=N.morphNormals,V.morphColors=N.morphColors,V.morphTargetsCount=N.morphTargetsCount,V.numClippingPlanes=N.numClippingPlanes,V.numIntersection=N.numClipIntersection,V.vertexAlphas=N.vertexAlphas,V.vertexTangents=N.vertexTangents,V.toneMapping=N.toneMapping}function xf(y,N){if(y.length===0)return null;if(y.length===1)return y[0].texture!==null?y[0]:null;M.setFromMatrixPosition(N.matrixWorld);for(let V=0,B=y.length;V<B;V++){const k=y[V];if(k.texture!==null&&k.boundingBox.containsPoint(M))return k}return null}function Mf(y,N,V,B,k){N.isScene!==!0&&(N=de),K.resetTextureUnits();const mt=N.fog,xt=B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial?N.environment:null,pt=$===null?D.outputColorSpace:$.isXRRenderTarget===!0?$.texture.colorSpace:Kt.workingColorSpace,Et=B.isMeshStandardMaterial||B.isMeshLambertMaterial&&!B.envMap||B.isMeshPhongMaterial&&!B.envMap,Rt=st.get(B.envMap||xt,Et),Ht=B.vertexColors===!0&&!!V.attributes.color&&V.attributes.color.itemSize===4,Wt=!!V.attributes.tangent&&(!!B.normalMap||B.anisotropy>0),Ct=!!V.morphAttributes.position,ne=!!V.morphAttributes.normal,Me=!!V.morphAttributes.color;let _e=qn;B.toneMapped&&($===null||$.isXRRenderTarget===!0)&&(_e=D.toneMapping);const re=V.morphAttributes.position||V.morphAttributes.normal||V.morphAttributes.color,Ge=re!==void 0?re.length:0,vt=G.get(B),en=b.state.lights;if(Lt===!0&&(Nt===!0||y!==j)){const ce=y===j&&B.id===et;Pt.setState(B,y,ce)}let Zt=!1;B.version===vt.__version?(vt.needsLights&&vt.lightsStateVersion!==en.state.version||vt.outputColorSpace!==pt||k.isBatchedMesh&&vt.batching===!1||!k.isBatchedMesh&&vt.batching===!0||k.isBatchedMesh&&vt.batchingColor===!0&&k.colorTexture===null||k.isBatchedMesh&&vt.batchingColor===!1&&k.colorTexture!==null||k.isInstancedMesh&&vt.instancing===!1||!k.isInstancedMesh&&vt.instancing===!0||k.isSkinnedMesh&&vt.skinning===!1||!k.isSkinnedMesh&&vt.skinning===!0||k.isInstancedMesh&&vt.instancingColor===!0&&k.instanceColor===null||k.isInstancedMesh&&vt.instancingColor===!1&&k.instanceColor!==null||k.isInstancedMesh&&vt.instancingMorph===!0&&k.morphTexture===null||k.isInstancedMesh&&vt.instancingMorph===!1&&k.morphTexture!==null||vt.envMap!==Rt||B.fog===!0&&vt.fog!==mt||vt.numClippingPlanes!==void 0&&(vt.numClippingPlanes!==Pt.numPlanes||vt.numIntersection!==Pt.numIntersection)||vt.vertexAlphas!==Ht||vt.vertexTangents!==Wt||vt.morphTargets!==Ct||vt.morphNormals!==ne||vt.morphColors!==Me||vt.toneMapping!==_e||vt.morphTargetsCount!==Ge||!!vt.lightProbeGrid!=b.state.lightProbeGridArray.length>0)&&(Zt=!0):(Zt=!0,vt.__version=B.version);let dn=vt.currentProgram;Zt===!0&&(dn=Dr(B,N,k),I&&B.isNodeMaterial&&I.onUpdateProgram(B,dn,vt));let In=!1,ci=!1,ns=!1;const ae=dn.getUniforms(),ye=vt.uniforms;if(v.useProgram(dn.program)&&(In=!0,ci=!0,ns=!0),B.id!==et&&(et=B.id,ci=!0),vt.needsLights){const ce=xf(b.state.lightProbeGridArray,k);vt.lightProbeGrid!==ce&&(vt.lightProbeGrid=ce,ci=!0)}if(In||j!==y){v.buffers.depth.getReversed()&&y.reversedDepth!==!0&&(y._reversedDepth=!0,y.updateProjectionMatrix()),ae.setValue(L,"projectionMatrix",y.projectionMatrix),ae.setValue(L,"viewMatrix",y.matrixWorldInverse);const hi=ae.map.cameraPosition;hi!==void 0&&hi.setValue(L,Qt.setFromMatrixPosition(y.matrixWorld)),T.logarithmicDepthBuffer&&ae.setValue(L,"logDepthBufFC",2/(Math.log(y.far+1)/Math.LN2)),(B.isMeshPhongMaterial||B.isMeshToonMaterial||B.isMeshLambertMaterial||B.isMeshBasicMaterial||B.isMeshStandardMaterial||B.isShaderMaterial)&&ae.setValue(L,"isOrthographic",y.isOrthographicCamera===!0),j!==y&&(j=y,ci=!0,ns=!0)}if(vt.needsLights&&(en.state.directionalShadowMap.length>0&&ae.setValue(L,"directionalShadowMap",en.state.directionalShadowMap,K),en.state.spotShadowMap.length>0&&ae.setValue(L,"spotShadowMap",en.state.spotShadowMap,K),en.state.pointShadowMap.length>0&&ae.setValue(L,"pointShadowMap",en.state.pointShadowMap,K)),k.isSkinnedMesh){ae.setOptional(L,k,"bindMatrix"),ae.setOptional(L,k,"bindMatrixInverse");const ce=k.skeleton;ce&&(ce.boneTexture===null&&ce.computeBoneTexture(),ae.setValue(L,"boneTexture",ce.boneTexture,K))}k.isBatchedMesh&&(ae.setOptional(L,k,"batchingTexture"),ae.setValue(L,"batchingTexture",k._matricesTexture,K),ae.setOptional(L,k,"batchingIdTexture"),ae.setValue(L,"batchingIdTexture",k._indirectTexture,K),ae.setOptional(L,k,"batchingColorTexture"),k._colorsTexture!==null&&ae.setValue(L,"batchingColorTexture",k._colorsTexture,K));const li=V.morphAttributes;if((li.position!==void 0||li.normal!==void 0||li.color!==void 0)&&P.update(k,V,dn),(ci||vt.receiveShadow!==k.receiveShadow)&&(vt.receiveShadow=k.receiveShadow,ae.setValue(L,"receiveShadow",k.receiveShadow)),(B.isMeshStandardMaterial||B.isMeshLambertMaterial||B.isMeshPhongMaterial)&&B.envMap===null&&N.environment!==null&&(ye.envMapIntensity.value=N.environmentIntensity),ye.dfgLUT!==void 0&&(ye.dfgLUT.value=I_()),ci){if(ae.setValue(L,"toneMappingExposure",D.toneMappingExposure),vt.needsLights&&yf(ye,ns),mt&&B.fog===!0&&Tt.refreshFogUniforms(ye,mt),Tt.refreshMaterialUniforms(ye,B,nt,rt,b.state.transmissionRenderTarget[y.id]),vt.needsLights&&vt.lightProbeGrid){const ce=vt.lightProbeGrid;ye.probesSH.value=ce.texture,ye.probesMin.value.copy(ce.boundingBox.min),ye.probesMax.value.copy(ce.boundingBox.max),ye.probesResolution.value.copy(ce.resolution)}Ia.upload(L,vh(vt),ye,K)}if(B.isShaderMaterial&&B.uniformsNeedUpdate===!0&&(Ia.upload(L,vh(vt),ye,K),B.uniformsNeedUpdate=!1),B.isSpriteMaterial&&ae.setValue(L,"center",k.center),ae.setValue(L,"modelViewMatrix",k.modelViewMatrix),ae.setValue(L,"normalMatrix",k.normalMatrix),ae.setValue(L,"modelMatrix",k.matrixWorld),B.uniformsGroups!==void 0){const ce=B.uniformsGroups;for(let hi=0,is=ce.length;hi<is;hi++){const xh=ce[hi];tt.update(xh,dn),tt.bind(xh,dn)}}return dn}function yf(y,N){y.ambientLightColor.needsUpdate=N,y.lightProbe.needsUpdate=N,y.directionalLights.needsUpdate=N,y.directionalLightShadows.needsUpdate=N,y.pointLights.needsUpdate=N,y.pointLightShadows.needsUpdate=N,y.spotLights.needsUpdate=N,y.spotLightShadows.needsUpdate=N,y.rectAreaLights.needsUpdate=N,y.hemisphereLights.needsUpdate=N}function Sf(y){return y.isMeshLambertMaterial||y.isMeshToonMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isShadowMaterial||y.isShaderMaterial&&y.lights===!0}this.getActiveCubeFace=function(){return q},this.getActiveMipmapLevel=function(){return H},this.getRenderTarget=function(){return $},this.setRenderTargetTextures=function(y,N,V){const B=G.get(y);B.__autoAllocateDepthBuffer=y.resolveDepthBuffer===!1,B.__autoAllocateDepthBuffer===!1&&(B.__useRenderToTexture=!1),G.get(y.texture).__webglTexture=N,G.get(y.depthTexture).__webglTexture=B.__autoAllocateDepthBuffer?void 0:V,B.__hasExternalTextures=!0},this.setRenderTargetFramebuffer=function(y,N){const V=G.get(y);V.__webglFramebuffer=N,V.__useDefaultFramebuffer=N===void 0},this.setRenderTarget=function(y,N=0,V=0){$=y,q=N,H=V;let B=null,k=!1,mt=!1;if(y){const pt=G.get(y);if(pt.__useDefaultFramebuffer!==void 0){v.bindFramebuffer(L.FRAMEBUFFER,pt.__webglFramebuffer),it.copy(y.viewport),ut.copy(y.scissor),kt=y.scissorTest,v.viewport(it),v.scissor(ut),v.setScissorTest(kt),et=-1;return}else if(pt.__webglFramebuffer===void 0)K.setupRenderTarget(y);else if(pt.__hasExternalTextures)K.rebindTextures(y,G.get(y.texture).__webglTexture,G.get(y.depthTexture).__webglTexture);else if(y.depthBuffer){const Ht=y.depthTexture;if(pt.__boundDepthTexture!==Ht){if(Ht!==null&&G.has(Ht)&&(y.width!==Ht.image.width||y.height!==Ht.image.height))throw new Error("THREE.WebGLRenderer: Attached DepthTexture is initialized to the incorrect size.");K.setupDepthRenderbuffer(y)}}const Et=y.texture;(Et.isData3DTexture||Et.isDataArrayTexture||Et.isCompressedArrayTexture)&&(mt=!0);const Rt=G.get(y).__webglFramebuffer;y.isWebGLCubeRenderTarget?(Array.isArray(Rt[N])?B=Rt[N][V]:B=Rt[N],k=!0):y.samples>0&&K.useMultisampledRTT(y)===!1?B=G.get(y).__webglMultisampledFramebuffer:Array.isArray(Rt)?B=Rt[V]:B=Rt,it.copy(y.viewport),ut.copy(y.scissor),kt=y.scissorTest}else it.copy(Dt).multiplyScalar(nt).floor(),ut.copy(At).multiplyScalar(nt).floor(),kt=_t;if(V!==0&&(B=W),v.bindFramebuffer(L.FRAMEBUFFER,B)&&v.drawBuffers(y,B),v.viewport(it),v.scissor(ut),v.setScissorTest(kt),k){const pt=G.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_CUBE_MAP_POSITIVE_X+N,pt.__webglTexture,V)}else if(mt){const pt=N;for(let Et=0;Et<y.textures.length;Et++){const Rt=G.get(y.textures[Et]);L.framebufferTextureLayer(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0+Et,Rt.__webglTexture,V,pt)}}else if(y!==null&&V!==0){const pt=G.get(y.texture);L.framebufferTexture2D(L.FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,pt.__webglTexture,V)}et=-1},this.readRenderTargetPixels=function(y,N,V,B,k,mt,xt,pt=0){if(!(y&&y.isWebGLRenderTarget)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");return}let Et=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et){v.bindFramebuffer(L.FRAMEBUFFER,Et);try{const Rt=y.textures[pt],Ht=Rt.format,Wt=Rt.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Ht)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!T.textureTypeReadable(Wt)){Yt("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k&&L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),mt)}finally{const Rt=$!==null?G.get($).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,Rt)}}},this.readRenderTargetPixelsAsync=async function(y,N,V,B,k,mt,xt,pt=0){if(!(y&&y.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let Et=G.get(y).__webglFramebuffer;if(y.isWebGLCubeRenderTarget&&xt!==void 0&&(Et=Et[xt]),Et)if(N>=0&&N<=y.width-B&&V>=0&&V<=y.height-k){v.bindFramebuffer(L.FRAMEBUFFER,Et);const Rt=y.textures[pt],Ht=Rt.format,Wt=Rt.type;if(y.textures.length>1&&L.readBuffer(L.COLOR_ATTACHMENT0+pt),!T.textureFormatReadable(Ht))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!T.textureTypeReadable(Wt))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const Ct=L.createBuffer();L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.bufferData(L.PIXEL_PACK_BUFFER,mt.byteLength,L.STREAM_READ),L.readPixels(N,V,B,k,ht.convert(Ht),ht.convert(Wt),0);const ne=$!==null?G.get($).__webglFramebuffer:null;v.bindFramebuffer(L.FRAMEBUFFER,ne);const Me=L.fenceSync(L.SYNC_GPU_COMMANDS_COMPLETE,0);return L.flush(),await Zp(L,Me,4),L.bindBuffer(L.PIXEL_PACK_BUFFER,Ct),L.getBufferSubData(L.PIXEL_PACK_BUFFER,0,mt),L.deleteBuffer(Ct),L.deleteSync(Me),mt}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(y,N=null,V=0){const B=Math.pow(2,-V),k=Math.floor(y.image.width*B),mt=Math.floor(y.image.height*B),xt=N!==null?N.x:0,pt=N!==null?N.y:0;K.setTexture2D(y,0),L.copyTexSubImage2D(L.TEXTURE_2D,V,0,0,xt,pt,k,mt),v.unbindTexture()},this.copyTextureToTexture=function(y,N,V=null,B=null,k=0,mt=0){let xt,pt,Et,Rt,Ht,Wt,Ct,ne,Me;const _e=y.isCompressedTexture?y.mipmaps[mt]:y.image;if(V!==null)xt=V.max.x-V.min.x,pt=V.max.y-V.min.y,Et=V.isBox3?V.max.z-V.min.z:1,Rt=V.min.x,Ht=V.min.y,Wt=V.isBox3?V.min.z:0;else{const ye=Math.pow(2,-k);xt=Math.floor(_e.width*ye),pt=Math.floor(_e.height*ye),y.isDataArrayTexture?Et=_e.depth:y.isData3DTexture?Et=Math.floor(_e.depth*ye):Et=1,Rt=0,Ht=0,Wt=0}B!==null?(Ct=B.x,ne=B.y,Me=B.z):(Ct=0,ne=0,Me=0);const re=ht.convert(N.format),Ge=ht.convert(N.type);let vt;N.isData3DTexture?(K.setTexture3D(N,0),vt=L.TEXTURE_3D):N.isDataArrayTexture||N.isCompressedArrayTexture?(K.setTexture2DArray(N,0),vt=L.TEXTURE_2D_ARRAY):(K.setTexture2D(N,0),vt=L.TEXTURE_2D),v.activeTexture(L.TEXTURE0),v.pixelStorei(L.UNPACK_FLIP_Y_WEBGL,N.flipY),v.pixelStorei(L.UNPACK_PREMULTIPLY_ALPHA_WEBGL,N.premultiplyAlpha),v.pixelStorei(L.UNPACK_ALIGNMENT,N.unpackAlignment);const en=v.getParameter(L.UNPACK_ROW_LENGTH),Zt=v.getParameter(L.UNPACK_IMAGE_HEIGHT),dn=v.getParameter(L.UNPACK_SKIP_PIXELS),In=v.getParameter(L.UNPACK_SKIP_ROWS),ci=v.getParameter(L.UNPACK_SKIP_IMAGES);v.pixelStorei(L.UNPACK_ROW_LENGTH,_e.width),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,_e.height),v.pixelStorei(L.UNPACK_SKIP_PIXELS,Rt),v.pixelStorei(L.UNPACK_SKIP_ROWS,Ht),v.pixelStorei(L.UNPACK_SKIP_IMAGES,Wt);const ns=y.isDataArrayTexture||y.isData3DTexture,ae=N.isDataArrayTexture||N.isData3DTexture;if(y.isDepthTexture){const ye=G.get(y),li=G.get(N),ce=G.get(ye.__renderTarget),hi=G.get(li.__renderTarget);v.bindFramebuffer(L.READ_FRAMEBUFFER,ce.__webglFramebuffer),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,hi.__webglFramebuffer);for(let is=0;is<Et;is++)ns&&(L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(y).__webglTexture,k,Wt+is),L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,G.get(N).__webglTexture,mt,Me+is)),L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ne,xt,pt,L.DEPTH_BUFFER_BIT,L.NEAREST);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else if(k!==0||y.isRenderTargetTexture||G.has(y)){const ye=G.get(y),li=G.get(N);v.bindFramebuffer(L.READ_FRAMEBUFFER,X),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,U);for(let ce=0;ce<Et;ce++)ns?L.framebufferTextureLayer(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,ye.__webglTexture,k,Wt+ce):L.framebufferTexture2D(L.READ_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,ye.__webglTexture,k),ae?L.framebufferTextureLayer(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,li.__webglTexture,mt,Me+ce):L.framebufferTexture2D(L.DRAW_FRAMEBUFFER,L.COLOR_ATTACHMENT0,L.TEXTURE_2D,li.__webglTexture,mt),k!==0?L.blitFramebuffer(Rt,Ht,xt,pt,Ct,ne,xt,pt,L.COLOR_BUFFER_BIT,L.NEAREST):ae?L.copyTexSubImage3D(vt,mt,Ct,ne,Me+ce,Rt,Ht,xt,pt):L.copyTexSubImage2D(vt,mt,Ct,ne,Rt,Ht,xt,pt);v.bindFramebuffer(L.READ_FRAMEBUFFER,null),v.bindFramebuffer(L.DRAW_FRAMEBUFFER,null)}else ae?y.isDataTexture||y.isData3DTexture?L.texSubImage3D(vt,mt,Ct,ne,Me,xt,pt,Et,re,Ge,_e.data):N.isCompressedArrayTexture?L.compressedTexSubImage3D(vt,mt,Ct,ne,Me,xt,pt,Et,re,_e.data):L.texSubImage3D(vt,mt,Ct,ne,Me,xt,pt,Et,re,Ge,_e):y.isDataTexture?L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ne,xt,pt,re,Ge,_e.data):y.isCompressedTexture?L.compressedTexSubImage2D(L.TEXTURE_2D,mt,Ct,ne,_e.width,_e.height,re,_e.data):L.texSubImage2D(L.TEXTURE_2D,mt,Ct,ne,xt,pt,re,Ge,_e);v.pixelStorei(L.UNPACK_ROW_LENGTH,en),v.pixelStorei(L.UNPACK_IMAGE_HEIGHT,Zt),v.pixelStorei(L.UNPACK_SKIP_PIXELS,dn),v.pixelStorei(L.UNPACK_SKIP_ROWS,In),v.pixelStorei(L.UNPACK_SKIP_IMAGES,ci),mt===0&&N.generateMipmaps&&L.generateMipmap(vt),v.unbindTexture()},this.initRenderTarget=function(y){G.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),v.unbindTexture()},this.resetState=function(){q=0,H=0,$=null,v.reset(),gt.reset()},typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("observe",{detail:this}))}get coordinateSystem(){return Wn}get outputColorSpace(){return this._outputColorSpace}set outputColorSpace(t){this._outputColorSpace=t;const e=this.getContext();e.drawingBufferColorSpace=Kt._getDrawingBufferColorSpace(t),e.unpackColorSpace=Kt._getUnpackColorSpace()}}const dl=Math.PI/180,Uu=180/Math.PI;function Tr(i,t,e){return Math.max(t,Math.min(e,i))}const _i=[{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 Zo(i,t,e){return i+(t-i)*e}function Va(i,t,e){return[Zo(i[0],t[0],e),Zo(i[1],t[1],e),Zo(i[2],t[2],e)]}function fl(i){const t=Math.max(_i[0].altitudeDeg,Math.min(_i[_i.length-1].altitudeDeg,i));for(let n=0;n<_i.length-1;n++){const s=_i[n],r=_i[n+1];if(t>=s.altitudeDeg&&t<=r.altitudeDeg){const a=(t-s.altitudeDeg)/(r.altitudeDeg-s.altitudeDeg);return{zenith:Va(s.zenith,r.zenith,a),horizon:Va(s.horizon,r.horizon,a)}}}const e=_i[_i.length-1];return{zenith:e.zenith,horizon:e.horizon}}const Fu=-18,Ou=-4,N_=1.8;function zu(i){if(i<=Fu)return La;if(i>=0)return Ou;const t=i/Fu;return La-(La-Ou)*(1-t)**N_}const U_=-1.5,La=6.5,Bu=La,F_=1.6;function $o(i){const t=(Bu-i)/(Bu-U_);return Tr(t,0,1)**F_}function an(i,t,e){const n=i*dl,s=t*dl,r=e*Math.cos(n);return{x:r*Math.sin(s),y:e*Math.sin(n),z:-r*Math.cos(s)}}function O_(i,t,e){const n=Math.sqrt(i*i+t*t+e*e),s=n===0?0:Math.asin(Tr(t/n,-1,1))*Uu,r=(Math.atan2(i,-e)*Uu+360)%360;return{altitudeDeg:s,azimuthDeg:r}}function z_(i,t){const e=Math.abs(i-t)%360;return e>180?360-e:e}function B_(i,t,e,n){const s=Math.max(0,1-z_(i,e)/k_),r=Math.exp(-Math.max(0,t)/G_),a=n>0?Math.max(0,1-n/H_):Math.max(0,1-Math.abs(n+V_)/W_);return s*r*a}const k_=90,G_=12,H_=8,V_=2,W_=12;function X_(i,t,e,n){const{zenith:s,horizon:r}=fl(n),a=Tr((i+90)/180,0,1),o=Va(r,s,a),c=B_(t,i,e,n);if(c<=0)return o;const l=fl(n+q_).horizon,h=[Math.max(r[0],l[0]),Math.max(r[1],l[1]),Math.max(r[2],l[2])];return Va(o,h,c)}const q_=6;function Jo(i){return .12+.88*i}const Y_=-4;function K_(i){return Math.max(0,Y_-i)}const Z_=6,$_=60;function J_(i){return Math.min($_,Z_*Math.sqrt(i))}const Q_=3,j_=.55;function tx(i){return j_*Tr(i/Q_,0,1)}function A0(i){const t=Math.max(i,-4),e=Math.sin(t*dl)+.50572*Math.pow(t+6.07995,-1.6364);return Tr(1/e,1,40)}function Oi(i){const t=A0(i)-1;return[1,Math.exp(-.022*t),Math.exp(-.062*t)]}function ex(i){return ix*(A0(Math.max(i,0))-1)}function nx(i){return Math.pow(10,-.4*ex(i))}const ix=5/37,T0=[{maxBrightness:.35,size:1.2},{maxBrightness:.7,size:2},{maxBrightness:1/0,size:3.2}];function sx(i){return T0.findIndex(t=>i<=t.maxBrightness)}const rx=.25,ku=.3,ax=2.2;function ox(i,{phase:t,speedFactor:e},n){const r=1+rx*(ku+(1-ku)*i)*Math.sin(n*ax*e+t);return Math.min(1,Math.max(0,r))}/**
|
|
4679
4679
|
@preserve
|
|
4680
4680
|
|
|
4681
4681
|
Astronomy library for JavaScript (browser and Node.js).
|
|
@@ -4706,11 +4706,11 @@ void main() {
|
|
|
4706
4706
|
* @fileoverview Astronomy calculation library for browser scripting and Node.js.
|
|
4707
4707
|
* @author Don Cross <cosinekitty@gmail.com>
|
|
4708
4708
|
* @license MIT
|
|
4709
|
-
*/const Hc=173.1446326846693,Li=14959787069098932e-8,et=.017453292519943295,Tu=.26179938779914946,On=57.29577951308232,u0=3.819718634205488,U2=365.24217,Ru=new Date("2000-01-01T12:00:00Z"),Xn=2*Math.PI,hi=3600*(180/Math.PI),Ms=484813681109536e-20,d0=10800*60,F2=2*d0,Cu=7292115e-11,O2=d0/Math.PI,z2=-.17-5*Math.log10(O2),ec=.996647180302104,B2=ec*ec,tc=6378.1366,k2=tc/Li,f0=81.30056,Vc=.0002959122082855911,nc=2825345909524226e-22,ic=8459715185680659e-23,sc=1292024916781969e-23,rc=1524358900784276e-23;function Ia(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function Lt(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function ps(i){return i-Math.floor(i)}function G2(i,e){const t=i.x*i.x+i.y*i.y+i.z*i.z;if(Math.abs(t)<1e-8)throw"AngleBetween: first vector is too short.";const n=e.x*e.x+e.y*e.y+e.z*e.z;if(Math.abs(n)<1e-8)throw"AngleBetween: second vector is too short.";const s=(i.x*e.x+i.y*e.y+i.z*e.z)/Math.sqrt(t*n);return s<=-1?180:s>=1?0:On*Math.acos(s)}var Se;(function(i){i.Sun="Sun",i.Moon="Moon",i.Mercury="Mercury",i.Venus="Venus",i.Earth="Earth",i.Mars="Mars",i.Jupiter="Jupiter",i.Saturn="Saturn",i.Uranus="Uranus",i.Neptune="Neptune",i.Pluto="Pluto",i.SSB="SSB",i.EMB="EMB",i.Star1="Star1",i.Star2="Star2",i.Star3="Star3",i.Star4="Star4",i.Star5="Star5",i.Star6="Star6",i.Star7="Star7",i.Star8="Star8"})(Se||(Se={}));const H2=[Se.Star1,Se.Star2,Se.Star3,Se.Star4,Se.Star5,Se.Star6,Se.Star7,Se.Star8],V2=[{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 W2(i){const e=H2.indexOf(i);return e>=0?V2[e]:null}function Wc(i){const e=W2(i);return e&&e.dist>0?e:null}var Yt;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})(Yt||(Yt={}));const Un={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 X2(i){var e,t,n,s,r,a,o;const l=2e3+(i-14)/U2;return l<-500?(e=(l-1820)/100,-20+32*e*e):l<500?(e=l/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,10583.6-1014.41*e+33.78311*t-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):l<1600?(e=(l-1e3)/100,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,1574.2-556.01*e+71.23472*t+.319781*n-.8503463*s-.005050998*r+.0083572073*a):l<1700?(e=l-1600,t=e*e,n=e*t,120-.9808*e-.01532*t+n/7129):l<1800?(e=l-1700,t=e*e,n=e*t,s=t*t,8.83+.1603*e-.0059285*t+13336e-8*n-s/1174e3):l<1860?(e=l-1800,t=e*e,n=e*t,s=t*t,r=t*n,a=n*n,o=n*s,13.72-.332447*e+.0068612*t+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):l<1900?(e=l-1860,t=e*e,n=e*t,s=t*t,r=t*n,7.62+.5737*e-.251754*t+.01680668*n-.0004473624*s+r/233174):l<1920?(e=l-1900,t=e*e,n=e*t,s=t*t,-2.79+1.494119*e-.0598939*t+.0061966*n-197e-6*s):l<1941?(e=l-1920,t=e*e,n=e*t,21.2+.84493*e-.0761*t+.0020936*n):l<1961?(e=l-1950,t=e*e,n=e*t,29.07+.407*e-t/233+n/2547):l<1986?(e=l-1975,t=e*e,n=e*t,45.45+1.067*e-t/260-n/718):l<2005?(e=l-2e3,t=e*e,n=e*t,s=t*t,r=t*n,63.86+.3345*e-.060374*t+.0017275*n+651814e-9*s+2373599e-11*r):l<2050?(e=l-2e3,62.92+.32217*e+.005589*e*e):l<2150?(e=(l-1820)/100,-20+32*e*e-.5628*(2150-l)):(e=(l-1820)/100,-20+32*e*e)}let q2=X2;function Du(i){return i+q2(i)/86400}class Ts{constructor(e){if(e instanceof Ts){this.date=e.date,this.ut=e.ut,this.tt=e.tt;return}const t=1e3*3600*24;if(e instanceof Date&&Number.isFinite(e.getTime())){this.date=e,this.ut=(e.getTime()-Ru.getTime())/t,this.tt=Du(this.ut);return}if(Number.isFinite(e)){this.date=new Date(Ru.getTime()+e*t),this.ut=e,this.tt=Du(this.ut);return}throw"Argument must be a Date object, an AstroTime object, or a numeric UTC Julian date."}static FromTerrestrialTime(e){let t=new Ts(e);for(;;){const n=e-t.tt;if(Math.abs(n)<1e-12)return t;t=t.AddDays(n)}}toString(){return this.date.toISOString()}AddDays(e){return new Ts(this.ut+e)}}function Ct(i){return i instanceof Ts?i:new Ts(i)}function Y2(i){function e(d){return d%F2*Ms}const t=i.tt/36525,n=e(128710479305e-5+t*1295965810481e-4),s=e(335779.526232+t*17395272628478e-4),r=e(107226070369e-5+t*1602961601209e-3),a=e(450160.398036-t*69628905431e-4);let o=Math.sin(a),l=Math.cos(a),c=(-172064161-174666*t)*o+33386*l,h=(92052331+9086*t)*l+15377*o,u=2*(s-r+a);return o=Math.sin(u),l=Math.cos(u),c+=(-13170906-1675*t)*o-13696*l,h+=(5730336-3015*t)*l-4587*o,u=2*(s+a),o=Math.sin(u),l=Math.cos(u),c+=(-2276413-234*t)*o+2796*l,h+=(978459-485*t)*l+1374*o,u=2*a,o=Math.sin(u),l=Math.cos(u),c+=(2074554+207*t)*o-698*l,h+=(-897492+470*t)*l-291*o,o=Math.sin(n),l=Math.cos(n),c+=(1475877-3633*t)*o+11817*l,h+=(73871-184*t)*l-1924*o,{dpsi:-135e-6+c*1e-7,deps:388e-6+h*1e-7}}function p0(i){var e=i.tt/36525,t=((((-434e-10*e-576e-9)*e+.0020034)*e-1831e-7)*e-46.836769)*e+84381.406;return t/3600}var Qr;function gr(i){if(!Qr||Math.abs(Qr.tt-i.tt)>1e-6){const e=Y2(i),t=p0(i),n=t+e.deps/3600;Qr={tt:i.tt,dpsi:e.dpsi,deps:e.deps,ee:e.dpsi*Math.cos(t*et)/15,mobl:t,tobl:n}}return Qr}function K2(i,e){const t=i*et,n=Math.cos(t),s=Math.sin(t);return[e[0],e[1]*n-e[2]*s,e[1]*s+e[2]*n]}function Z2(i,e){return K2(p0(i),e)}function $2(i){const e=i.tt/36525;function t(Re,Me){const Ue=[];let Ie;for(Ie=0;Ie<=Me-Re;++Ie)Ue.push(0);return{min:Re,array:Ue}}function n(Re,Me,Ue,Ie){const Le=[];for(let $e=0;$e<=Me-Re;++$e)Le.push(t(Ue,Ie));return{min:Re,array:Le}}function s(Re,Me,Ue){const Ie=Re.array[Me-Re.min];return Ie.array[Ue-Ie.min]}function r(Re,Me,Ue,Ie){const Le=Re.array[Me-Re.min];Le.array[Ue-Le.min]=Ie}let a,o,l,c,h,u,d,p,g,x,m,f,w,T,M,S,b,R,_,E,D,C,L,X=n(-6,6,1,4),q=n(-6,6,1,4);function F(Re,Me){return s(X,Re,Me)}function W(Re,Me){return s(q,Re,Me)}function V(Re,Me,Ue){return r(X,Re,Me,Ue)}function Q(Re,Me,Ue){return r(q,Re,Me,Ue)}function te(Re,Me,Ue,Ie,Le){Le(Re*Ue-Me*Ie,Me*Ue+Re*Ie)}function ee(Re){return Math.sin(Xn*Re)}d=e*e,g=0,L=0,m=0,f=3422.7;var se=ee(.19833+.05611*e),ge=ee(.27869+.04508*e),Ve=ee(.16827-.36903*e),at=ee(.34734-5.37261*e),We=ee(.10498-5.37899*e),Z=ee(.42681-.41855*e),re=ee(.14943-5.37511*e);for(R=.84*se+.31*ge+14.27*Ve+7.26*at+.28*We+.24*Z,_=2.94*se+.31*ge+14.27*Ve+9.34*at+1.12*We+.83*Z,E=-6.4*se-1.89*Z,D=.21*se+.31*ge+14.27*Ve-88.7*at-15.3*We+.24*Z-1.86*re,C=R-E,p=-3332e-9*ee(.59734-5.37261*e)-539e-9*ee(.35498-5.37899*e)-64e-9*ee(.39943-5.37511*e),w=Xn*ps(.60643382+1336.85522467*e-313e-8*d)+R/hi,T=Xn*ps(.37489701+1325.55240982*e+2565e-8*d)+_/hi,M=Xn*ps(.99312619+99.99735956*e-44e-8*d)+E/hi,S=Xn*ps(.25909118+1342.2278298*e-892e-8*d)+D/hi,b=Xn*ps(.82736186+1236.85308708*e-397e-8*d)+C/hi,h=1;h<=4;++h){switch(h){case 1:l=T,o=4,c=1.000002208;break;case 2:l=M,o=3,c=.997504612-.002495388*e;break;case 3:l=S,o=4,c=1.000002708+139.978*p;break;case 4:l=b,o=6,c=1;break;default:throw`Internal error: I = ${h}`}for(V(0,h,1),V(1,h,Math.cos(l)*c),Q(0,h,0),Q(1,h,Math.sin(l)*c),u=2;u<=o;++u)te(F(u-1,h),W(u-1,h),F(1,h),W(1,h),(Re,Me)=>(V(u,h,Re),Q(u,h,Me)));for(u=1;u<=o;++u)V(-u,h,F(u,h)),Q(-u,h,-W(u,h))}function ne(Re,Me,Ue,Ie){for(var Le={x:1,y:0},$e=[0,Re,Me,Ue,Ie],Je=1;Je<=4;++Je)$e[Je]!==0&&te(Le.x,Le.y,F($e[Je],Je),W($e[Je],Je),(pt,dt)=>(Le.x=pt,Le.y=dt));return Le}function k(Re,Me,Ue,Ie,Le,$e,Je,pt){var dt=ne(Le,$e,Je,pt);g+=Re*dt.y,L+=Me*dt.y,m+=Ue*dt.x,f+=Ie*dt.x}k(13.902,14.06,-.001,.2607,0,0,0,4),k(.403,-4.01,.394,.0023,0,0,0,3),k(2369.912,2373.36,.601,28.2333,0,0,0,2),k(-125.154,-112.79,-.725,-.9781,0,0,0,1),k(1.979,6.98,-.445,.0433,1,0,0,4),k(191.953,192.72,.029,3.0861,1,0,0,2),k(-8.466,-13.51,.455,-.1093,1,0,0,1),k(22639.5,22609.07,.079,186.5398,1,0,0,0),k(18.609,3.59,-.094,.0118,1,0,0,-1),k(-4586.465,-4578.13,-.077,34.3117,1,0,0,-2),k(3.215,5.44,.192,-.0386,1,0,0,-3),k(-38.428,-38.64,.001,.6008,1,0,0,-4),k(-.393,-1.43,-.092,.0086,1,0,0,-6),k(-.289,-1.59,.123,-.0053,0,1,0,4),k(-24.42,-25.1,.04,-.3,0,1,0,2),k(18.023,17.93,.007,.1494,0,1,0,1),k(-668.146,-126.98,-1.302,-.3997,0,1,0,0),k(.56,.32,-.001,-.0037,0,1,0,-1),k(-165.145,-165.06,.054,1.9178,0,1,0,-2),k(-1.877,-6.46,-.416,.0339,0,1,0,-4),k(.213,1.02,-.074,.0054,2,0,0,4),k(14.387,14.78,-.017,.2833,2,0,0,2),k(-.586,-1.2,.054,-.01,2,0,0,1),k(769.016,767.96,.107,10.1657,2,0,0,0),k(1.75,2.01,-.018,.0155,2,0,0,-1),k(-211.656,-152.53,5.679,-.3039,2,0,0,-2),k(1.225,.91,-.03,-.0088,2,0,0,-3),k(-30.773,-34.07,-.308,.3722,2,0,0,-4),k(-.57,-1.4,-.074,.0109,2,0,0,-6),k(-2.921,-11.75,.787,-.0484,1,1,0,2),k(1.267,1.52,-.022,.0164,1,1,0,1),k(-109.673,-115.18,.461,-.949,1,1,0,0),k(-205.962,-182.36,2.056,1.4437,1,1,0,-2),k(.233,.36,.012,-.0025,1,1,0,-3),k(-4.391,-9.66,-.471,.0673,1,1,0,-4),k(.283,1.53,-.111,.006,1,-1,0,4),k(14.577,31.7,-1.54,.2302,1,-1,0,2),k(147.687,138.76,.679,1.1528,1,-1,0,0),k(-1.089,.55,.021,0,1,-1,0,-1),k(28.475,23.59,-.443,-.2257,1,-1,0,-2),k(-.276,-.38,-.006,-.0036,1,-1,0,-3),k(.636,2.27,.146,-.0102,1,-1,0,-4),k(-.189,-1.68,.131,-.0028,0,2,0,2),k(-7.486,-.66,-.037,-.0086,0,2,0,0),k(-8.096,-16.35,-.74,.0918,0,2,0,-2),k(-5.741,-.04,0,-9e-4,0,0,2,2),k(.255,0,0,0,0,0,2,1),k(-411.608,-.2,0,-.0124,0,0,2,0),k(.584,.84,0,.0071,0,0,2,-1),k(-55.173,-52.14,0,-.1052,0,0,2,-2),k(.254,.25,0,-.0017,0,0,2,-3),k(.025,-1.67,0,.0031,0,0,2,-4),k(1.06,2.96,-.166,.0243,3,0,0,2),k(36.124,50.64,-1.3,.6215,3,0,0,0),k(-13.193,-16.4,.258,-.1187,3,0,0,-2),k(-1.187,-.74,.042,.0074,3,0,0,-4),k(-.293,-.31,-.002,.0046,3,0,0,-6),k(-.29,-1.45,.116,-.0051,2,1,0,2),k(-7.649,-10.56,.259,-.1038,2,1,0,0),k(-8.627,-7.59,.078,-.0192,2,1,0,-2),k(-2.74,-2.54,.022,.0324,2,1,0,-4),k(1.181,3.32,-.212,.0213,2,-1,0,2),k(9.703,11.67,-.151,.1268,2,-1,0,0),k(-.352,-.37,.001,-.0028,2,-1,0,-1),k(-2.494,-1.17,-.003,-.0017,2,-1,0,-2),k(.36,.2,-.012,-.0043,2,-1,0,-4),k(-1.167,-1.25,.008,-.0106,1,2,0,0),k(-7.412,-6.12,.117,.0484,1,2,0,-2),k(-.311,-.65,-.032,.0044,1,2,0,-4),k(.757,1.82,-.105,.0112,1,-2,0,2),k(2.58,2.32,.027,.0196,1,-2,0,0),k(2.533,2.4,-.014,-.0212,1,-2,0,-2),k(-.344,-.57,-.025,.0036,0,3,0,-2),k(-.992,-.02,0,0,1,0,2,2),k(-45.099,-.02,0,-.001,1,0,2,0),k(-.179,-9.52,0,-.0833,1,0,2,-2),k(-.301,-.33,0,.0014,1,0,2,-4),k(-6.382,-3.37,0,-.0481,1,0,-2,2),k(39.528,85.13,0,-.7136,1,0,-2,0),k(9.366,.71,0,-.0112,1,0,-2,-2),k(.202,.02,0,0,1,0,-2,-4),k(.415,.1,0,.0013,0,1,2,0),k(-2.152,-2.26,0,-.0066,0,1,2,-2),k(-1.44,-1.3,0,.0014,0,1,-2,2),k(.384,-.04,0,0,0,1,-2,-2),k(1.938,3.6,-.145,.0401,4,0,0,0),k(-.952,-1.58,.052,-.013,4,0,0,-2),k(-.551,-.94,.032,-.0097,3,1,0,0),k(-.482,-.57,.005,-.0045,3,1,0,-2),k(.681,.96,-.026,.0115,3,-1,0,0),k(-.297,-.27,.002,-9e-4,2,2,0,-2),k(.254,.21,-.003,0,2,-2,0,-2),k(-.25,-.22,.004,.0014,1,3,0,-2),k(-3.996,0,0,4e-4,2,0,2,0),k(.557,-.75,0,-.009,2,0,2,-2),k(-.459,-.38,0,-.0053,2,0,-2,2),k(-1.298,.74,0,4e-4,2,0,-2,0),k(.538,1.14,0,-.0141,2,0,-2,-2),k(.263,.02,0,0,1,1,2,0),k(.426,.07,0,-6e-4,1,1,-2,-2),k(-.304,.03,0,3e-4,1,-1,2,0),k(-.372,-.19,0,-.0027,1,-1,-2,2),k(.418,0,0,0,0,0,4,0),k(-.33,-.04,0,0,3,0,2,0);function De(Re,Me,Ue,Ie,Le){return Re*ne(Me,Ue,Ie,Le).y}x=0,x+=De(-526.069,0,0,1,-2),x+=De(-3.352,0,0,1,-4),x+=De(44.297,1,0,1,-2),x+=De(-6,1,0,1,-4),x+=De(20.599,-1,0,1,0),x+=De(-30.598,-1,0,1,-2),x+=De(-24.649,-2,0,1,0),x+=De(-2,-2,0,1,-2),x+=De(-22.571,0,1,1,-2),x+=De(10.985,0,-1,1,-2),g+=.82*ee(.7736-62.5512*e)+.31*ee(.0466-125.1025*e)+.35*ee(.5785-25.1042*e)+.66*ee(.4591+1335.8075*e)+.64*ee(.313-91.568*e)+1.14*ee(.148+1331.2898*e)+.21*ee(.5918+1056.5859*e)+.44*ee(.5784+1322.8595*e)+.24*ee(.2275-5.7374*e)+.28*ee(.2965+2.6929*e)+.33*ee(.3132+6.3368*e),a=S+L/hi;let Pe=(1.000002708+139.978*p)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:Xn*ps((w+g/hi)/Xn),geo_eclip_lat:Math.PI/(180*3600)*Pe,distance_au:hi*k2/(.999953253*f)}}function m0(i,e){return[i.rot[0][0]*e[0]+i.rot[1][0]*e[1]+i.rot[2][0]*e[2],i.rot[0][1]*e[0]+i.rot[1][1]*e[1]+i.rot[2][1]*e[2],i.rot[0][2]*e[0]+i.rot[1][2]*e[1]+i.rot[2][2]*e[2]]}function La(i,e,t){const n=g0(e,t);return m0(n,i)}function g0(i,e){const t=i.tt/36525;let n=84381.406,s=((((-951e-10*t+132851e-9)*t-.00114045)*t-1.0790069)*t+5038.481507)*t,r=((((3337e-10*t-467e-9)*t-.00772503)*t+.0512623)*t-.025754)*t+n,a=((((-56e-9*t+170663e-9)*t-.00121197)*t-2.3814292)*t+10.556403)*t;n*=Ms,s*=Ms,r*=Ms,a*=Ms;const o=Math.sin(n),l=Math.cos(n),c=Math.sin(-s),h=Math.cos(-s),u=Math.sin(-r),d=Math.cos(-r),p=Math.sin(a),g=Math.cos(a),x=g*h-c*p*d,m=g*c*l+p*d*h*l-o*p*u,f=g*c*o+p*d*h*o+l*p*u,w=-p*h-c*g*d,T=-p*c*l+g*d*h*l-o*g*u,M=-p*c*o+g*d*h*o+l*g*u,S=c*u,b=-u*h*l-o*d,R=-u*h*o+d*l;if(e===Yt.Into2000)return new Mi([[x,m,f],[w,T,M],[S,b,R]]);if(e===Yt.From2000)return new Mi([[x,w,S],[m,T,b],[f,M,R]]);throw"Invalid precess direction"}function J2(i){const e=.779057273264+.00273781191135448*i.ut,t=i.ut%1;let n=360*((e+t)%1);return n<0&&(n+=360),n}let jr;function Xc(i){if(!jr||jr.tt!==i.tt){const e=i.tt/36525;let t=15*gr(i).ee;const n=J2(i);let r=((t+.014506+((((-368e-10*e-29956e-9)*e-44e-8)*e+1.3915817)*e+4612.156534)*e)/3600+n)%360/15;r<0&&(r+=24),jr={tt:i.tt,st:r}}return jr.st}function v0(i,e){const t=i.latitude*et,n=Math.sin(t),s=Math.cos(t),r=1/Math.hypot(s,ec*n),a=B2*r,o=i.height/1e3,l=tc*r+o,c=tc*a+o,h=(15*e+i.longitude)*et,u=Math.sin(h),d=Math.cos(h);return{pos:[l*s*d/Li,l*s*u/Li,c*n/Li],vel:[-Cu*l*s*u*86400/Li,Cu*l*s*d*86400/Li,0]}}function ac(i,e,t){const n=_0(e,t);return m0(n,i)}function _0(i,e){const t=gr(i),n=t.mobl*et,s=t.tobl*et,r=t.dpsi*Ms,a=Math.cos(n),o=Math.sin(n),l=Math.cos(s),c=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,p=-u*a,g=-u*o,x=u*l,m=h*a*l+o*c,f=h*o*l-a*c,w=u*c,T=h*a*c-o*l,M=h*o*c+a*l;if(e===Yt.From2000)return new Mi([[d,x,w],[p,m,T],[g,f,M]]);if(e===Yt.Into2000)return new Mi([[d,p,g],[x,m,f],[w,T,M]]);throw"Invalid precess direction"}function qc(i,e,t){return t===Yt.Into2000?La(ac(i,e,t),e,t):ac(La(i,e,t),e,t)}function Q2(i,e){const t=Xc(i),n=v0(e,t).pos;return qc(n,i,Yt.Into2000)}class ut{constructor(e,t,n,s){this.x=e,this.y=t,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class mi{constructor(e,t,n,s,r,a,o){this.x=e,this.y=t,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class Yc{constructor(e,t,n){this.lat=Lt(e),this.lon=Lt(t),this.dist=Lt(n)}}class oc{constructor(e,t,n,s){this.ra=Lt(e),this.dec=Lt(t),this.dist=Lt(n),this.vec=s}}class Mi{constructor(e){this.rot=e}}class j2{constructor(e,t,n,s){this.azimuth=Lt(e),this.altitude=Lt(t),this.ra=Lt(n),this.dec=Lt(s)}}class ex{constructor(e,t,n){this.vec=e,this.elat=Lt(t),this.elon=Lt(n)}}function x0(i,e){return new ut(i[0],i[1],i[2],e)}function tx(i,e){const t=x0(i,e),n=t.x*t.x+t.y*t.y,s=Math.sqrt(n+t.z*t.z);if(n===0){if(t.z===0)throw"Indeterminate sky coordinates";return new oc(0,t.z<0?-90:90,s,t)}let r=u0*Math.atan2(t.y,t.x);r<0&&(r+=24);const a=On*Math.atan2(i[2],Math.sqrt(n));return new oc(r,a,s,t)}function Bo(i,e){const t=i*et,n=Math.cos(t),s=Math.sin(t);return[n*e[0]+s*e[1],n*e[1]-s*e[0],e[2]]}function M0(i,e,t,n,s){let r=Ct(i);Kc(e),Lt(t),Lt(n);const a=Math.sin(e.latitude*et),o=Math.cos(e.latitude*et),l=Math.sin(e.longitude*et),c=Math.cos(e.longitude*et),h=Math.sin(n*et),u=Math.cos(n*et),d=Math.sin(t*Tu),p=Math.cos(t*Tu);let g=[o*c,o*l,a],x=[-a*c,-a*l,o],m=[l,-c,0];const f=-15*Xc(r);let w=Bo(f,g),T=Bo(f,x),M=Bo(f,m),S=[u*p,u*d,h];const b=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],R=S[0]*T[0]+S[1]*T[1]+S[2]*T[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let E=Math.hypot(R,_),D;E>0?(D=-On*Math.atan2(_,R),D<0&&(D+=360)):D=0;let C=On*Math.atan2(E,b),L=t,X=n;{let q=C,F=wx(s,90-C);if(C-=F,F>0&&C>3e-4){const W=Math.sin(C*et),V=Math.cos(C*et),Q=Math.sin(q*et),te=Math.cos(q*et),ee=[];for(let se=0;se<3;++se)ee.push((S[se]-te*w[se])/Q*W+w[se]*V);E=Math.hypot(ee[0],ee[1]),E>0?(L=u0*Math.atan2(ee[1],ee[0]),L<0&&(L+=24)):L=0,X=On*Math.atan2(ee[2],E)}}return new j2(D,90-C,L,X)}function Kc(i){if(!(i instanceof Zc))throw`Not an instance of the Observer class: ${i}`;if(Lt(i.latitude),Lt(i.longitude),Lt(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class Zc{constructor(e,t,n){this.latitude=e,this.longitude=t,this.height=n,Kc(this)}}function nx(i){const e=Ct(i).AddDays(-1/Hc),t=Cs(Un.Earth,e),n=[-t.x,-t.y,-t.z],[s,r,a]=qc(n,e,Yt.From2000),o=et*gr(e).tobl,l=Math.cos(o),c=Math.sin(o),h=new ut(s,r,a,e);return y0(h,l,c)}function ix(i,e,t,n,s){Kc(t),Ia(n),Ia(s);const r=Ct(e),a=Q2(r,t),o=vc(i,r,s),l=[o.x-a[0],o.y-a[1],o.z-a[2]],c=qc(l,r,Yt.From2000);return tx(c,r)}function sx(i,e,t){const n=Ct(i),s=Xc(n);let r=v0(e,s).pos;return x0(r,n)}function y0(i,e,t){const n=i.x,s=i.y*e+i.z*t,r=-i.y*t+i.z*e,a=Math.hypot(n,s);let o=0;a>0&&(o=On*Math.atan2(s,n),o<0&&(o+=360));let l=On*Math.atan2(r,a),c=new ut(n,s,r,i.t);return new ex(c,l,o)}function lc(i){const e=gr(i.t),t=[i.x,i.y,i.z],n=La(t,i.t,Yt.From2000),[s,r,a]=ac(n,i.t,Yt.From2000),o=new ut(s,r,a,i.t),l=e.tobl*et;return y0(o,Math.cos(l),Math.sin(l))}function Ns(i){const e=Ct(i),t=$2(e),n=t.distance_au*Math.cos(t.geo_eclip_lat),s=[n*Math.cos(t.geo_eclip_lon),n*Math.sin(t.geo_eclip_lon),t.distance_au*Math.sin(t.geo_eclip_lat)],r=Z2(e,s),a=La(r,e,Yt.Into2000);return new ut(a[0],a[1],a[2],e)}function S0(i){const e=Ct(i),t=1e-5,n=e.AddDays(-t),s=e.AddDays(+t),r=Ns(n),a=Ns(s);return new mi((r.x+a.x)/2,(r.y+a.y)/2,(r.z+a.z)/2,(a.x-r.x)/(2*t),(a.y-r.y)/(2*t),(a.z-r.z)/(2*t),e)}function rx(i){const e=Ct(i),t=S0(e),n=1+f0;return new mi(t.x/n,t.y/n,t.z/n,t.vx/n,t.vy/n,t.vz/n,e)}function Rs(i,e,t){let n=1,s=0;for(let r of i){let a=0;for(let[l,c,h]of r)a+=l*Math.cos(c+e*h);let o=n*a;t&&(o%=Xn),s+=o,n*=e}return s}function ko(i,e){let t=1,n=0,s=0,r=0;for(let a of i){let o=0,l=0;for(let[c,h,u]of a){let d=h+e*u;o+=c*u*Math.sin(d),r>0&&(l+=c*Math.cos(d))}s+=r*n*l-t*o,n=t,t*=e,++r}return s}const nr=365250,cc=0,hc=1,uc=2;function dc(i){return new kt(i[0]+44036e-11*i[1]-190919e-12*i[2],-479966e-12*i[0]+.917482137087*i[1]-.397776982902*i[2],.397776982902*i[1]+.917482137087*i[2])}function E0(i,e,t){const n=t*Math.cos(e),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,t*Math.sin(e)]}function Cs(i,e){const t=e.tt/nr,n=Rs(i[cc],t,!0),s=Rs(i[hc],t,!1),r=Rs(i[uc],t,!1),a=E0(n,s,r);return dc(a).ToAstroVector(e)}function fc(i,e){const t=e/nr,n=Rs(i[cc],t,!0),s=Rs(i[hc],t,!1),r=Rs(i[uc],t,!1),a=ko(i[cc],t),o=ko(i[hc],t),l=ko(i[uc],t),c=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),p=+(l*u*c)-r*d*c*o-r*u*h*a,g=+(l*u*h)-r*d*h*o+r*u*c*a,x=+(l*d)+r*u*o,m=E0(n,s,r),f=[p/nr,g/nr,x/nr],w=dc(m),T=dc(f);return new Vi(e,w,T)}function ea(i,e,t,n){const s=n/(n+Vc),r=Cs(Un[t],e);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function ax(i){const e=new ut(0,0,0,i);return ea(e,i,Se.Jupiter,nc),ea(e,i,Se.Saturn,ic),ea(e,i,Se.Uranus,sc),ea(e,i,Se.Neptune,rc),e}const pc=51,ox=29200,ys=146,qn=201,Oi=[[-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 kt{constructor(e,t,n){this.x=e,this.y=t,this.z=n}clone(){return new kt(this.x,this.y,this.z)}ToAstroVector(e){return new ut(this.x,this.y,this.z,e)}static zero(){return new kt(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(e){return new kt(this.x+e.x,this.y+e.y,this.z+e.z)}sub(e){return new kt(this.x-e.x,this.y-e.y,this.z-e.z)}incr(e){this.x+=e.x,this.y+=e.y,this.z+=e.z}decr(e){this.x-=e.x,this.y-=e.y,this.z-=e.z}mul(e){return new kt(e*this.x,e*this.y,e*this.z)}div(e){return new kt(this.x/e,this.y/e,this.z/e)}mean(e){return new kt((this.x+e.x)/2,(this.y+e.y)/2,(this.z+e.z)/2)}neg(){return new kt(-this.x,-this.y,-this.z)}}class Vi{constructor(e,t,n){this.tt=e,this.r=t,this.v=n}clone(){return new Vi(this.tt,this.r,this.v)}sub(e){return new Vi(this.tt,this.r.sub(e.r),this.v.sub(e.v))}}function lx(i){let[e,[t,n,s],[r,a,o]]=i;return new Vi(e,new kt(t,n,s),new kt(r,a,o))}function ta(i,e,t,n){const s=n/(n+Vc),r=fc(Un[t],e);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function Zs(i,e,t){const n=t.sub(i),s=n.quadrature();return n.mul(e/(s*Math.sqrt(s)))}class Ya{constructor(e){let t=new Vi(e,new kt(0,0,0),new kt(0,0,0));this.Jupiter=ta(t,e,Se.Jupiter,nc),this.Saturn=ta(t,e,Se.Saturn,ic),this.Uranus=ta(t,e,Se.Uranus,sc),this.Neptune=ta(t,e,Se.Neptune,rc),this.Jupiter.r.decr(t.r),this.Jupiter.v.decr(t.v),this.Saturn.r.decr(t.r),this.Saturn.v.decr(t.v),this.Uranus.r.decr(t.r),this.Uranus.v.decr(t.v),this.Neptune.r.decr(t.r),this.Neptune.v.decr(t.v),this.Sun=new Vi(e,t.r.mul(-1),t.v.mul(-1))}Acceleration(e){let t=Zs(e,Vc,this.Sun.r);return t.incr(Zs(e,nc,this.Jupiter.r)),t.incr(Zs(e,ic,this.Saturn.r)),t.incr(Zs(e,sc,this.Uranus.r)),t.incr(Zs(e,rc,this.Neptune.r)),t}}class Ka{constructor(e,t,n,s){this.tt=e,this.r=t,this.v=n,this.a=s}clone(){return new Ka(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class b0{constructor(e,t){this.bary=e,this.grav=t}}function Na(i,e,t,n){return new kt(e.x+i*(t.x+i*n.x/2),e.y+i*(t.y+i*n.y/2),e.z+i*(t.z+i*n.z/2))}function Pu(i,e,t){return new kt(e.x+i*t.x,e.y+i*t.y,e.z+i*t.z)}function mc(i,e){const t=i-e.tt,n=new Ya(i),s=Na(t,e.r,e.v,e.a),r=n.Acceleration(s).mean(e.a),a=Na(t,e.r,e.v,r),o=e.v.add(r.mul(t)),l=n.Acceleration(a),c=new Ka(i,a,o,l);return new b0(n,c)}const cx=[];function w0(i,e){const t=Math.floor(i);return t<0?0:t>=e?e-1:t}function gc(i){const e=lx(i),t=new Ya(e.tt),n=e.r.add(t.Sun.r),s=e.v.add(t.Sun.v),r=t.Acceleration(n),a=new Ka(e.tt,n,s,r);return new b0(t,a)}function hx(i,e){const t=Oi[0][0];if(e<t||e>Oi[pc-1][0])return null;const n=w0((e-t)/ox,pc-1);if(!i[n]){const r=i[n]=[];r[0]=gc(Oi[n]).grav,r[qn-1]=gc(Oi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<qn-1;++a)r[a]=mc(o+=ys,r[a-1]).grav;o=r[qn-1].tt;var s=[];for(s[qn-1]=r[qn-1],a=qn-2;a>0;--a)s[a]=mc(o-=ys,s[a+1]).grav;for(a=qn-2;a>0;--a){const l=a/(qn-1);r[a].r=r[a].r.mul(1-l).add(s[a].r.mul(l)),r[a].v=r[a].v.mul(1-l).add(s[a].v.mul(l)),r[a].a=r[a].a.mul(1-l).add(s[a].a.mul(l))}}return i[n]}function Iu(i,e,t){let n=gc(i);const s=Math.ceil((e-n.grav.tt)/t);for(let r=0;r<s;++r)n=mc(r+1===s?e:n.grav.tt+t,n.grav);return n}function A0(i,e){let t,n,s;const r=hx(cx,i.tt);if(r){const a=w0((i.tt-r[0].tt)/ys,qn-1),o=r[a],l=r[a+1],c=o.a.mean(l.a),h=Na(i.tt-o.tt,o.r,o.v,c),u=Pu(i.tt-o.tt,o.v,c),d=Na(i.tt-l.tt,l.r,l.v,c),p=Pu(i.tt-l.tt,l.v,c),g=(i.tt-o.tt)/ys;t=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(p.mul(g))}else{let a;i.tt<Oi[0][0]?a=Iu(Oi[0],i.tt,-ys):a=Iu(Oi[pc-1],i.tt,+ys),t=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new Ya(i.tt)),t=t.sub(s.Sun.r),n=n.sub(s.Sun.v),new mi(t.x,t.y,t.z,n.x,n.y,n.z,i)}function vi(i,e){var t=Ct(e);if(i in Un)return Cs(Un[i],t);if(i===Se.Pluto){const a=A0(t);return new ut(a.x,a.y,a.z,t)}if(i===Se.Sun)return new ut(0,0,0,t);if(i===Se.Moon){var n=Cs(Un.Earth,t),s=Ns(t);return new ut(n.x+s.x,n.y+s.y,n.z+s.z,t)}if(i===Se.EMB){const a=Cs(Un.Earth,t),o=Ns(t),l=1+f0;return new ut(a.x+o.x/l,a.y+o.y/l,a.z+o.z/l,t)}if(i===Se.SSB)return ax(t);const r=Wc(i);if(r){const a=new Yc(r.dec,15*r.ra,r.dist);return R0(a,t)}throw`HelioVector: Unknown body "${i}"`}function ux(i,e){let t=e,n=0;for(let s=0;s<10;++s){const r=i(t),a=r.Length()/Hc;if(a>1)throw"Object is too distant for light-travel solver.";const o=e.AddDays(-a);if(n=Math.abs(o.tt-t.tt),n<1e-9)return r;t=o}throw`Light-travel time solver did not converge: dt = ${n}`}class dx{constructor(e,t,n,s){this.observerBody=e,this.targetBody=t,this.aberration=n,this.observerPos=s}Position(e){this.aberration&&(this.observerPos=vi(this.observerBody,e));const t=vi(this.targetBody,e);return new ut(t.x-this.observerPos.x,t.y-this.observerPos.y,t.z-this.observerPos.z,e)}}function fx(i,e,t,n){Ia(n);const s=Ct(i);if(Wc(t)){const o=vi(t,s);if(n){const c=mx(e,s),h=new ut(o.x-c.x,o.y-c.y,o.z-c.z,s),u=Hc/h.Length();return new ut(h.x+c.vx/u,h.y+c.vy/u,h.z+c.vz/u,s)}const l=vi(e,s);return new ut(o.x-l.x,o.y-l.y,o.z-l.z,s)}let r;n?r=new ut(0,0,0,s):r=vi(e,s);const a=new dx(e,t,n,r);return ux(o=>a.Position(o),s)}function vc(i,e,t){Ia(t);const n=Ct(e);switch(i){case Se.Earth:return new ut(0,0,0,n);case Se.Moon:return Ns(n);default:const s=fx(n,Se.Earth,i,t);return s.t=n,s}}function px(i,e){return new mi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,e)}function mx(i,e){const t=Ct(e);switch(i){case Se.Sun:return new mi(0,0,0,0,0,0,t);case Se.SSB:const n=new Ya(t.tt);return new mi(-n.Sun.r.x,-n.Sun.r.y,-n.Sun.r.z,-n.Sun.v.x,-n.Sun.v.y,-n.Sun.v.z,t);case Se.Mercury:case Se.Venus:case Se.Earth:case Se.Mars:case Se.Jupiter:case Se.Saturn:case Se.Uranus:case Se.Neptune:const s=fc(Un[i],t.tt);return px(s,t);case Se.Pluto:return A0(t);case Se.Moon:case Se.EMB:const r=fc(Un.Earth,t.tt),a=i==Se.Moon?S0(t):rx(t);return new mi(a.x+r.r.x,a.y+r.r.y,a.z+r.r.z,a.vx+r.v.x,a.vy+r.v.y,a.vz+r.v.z,t);default:if(Wc(i)){const o=vi(i,t);return new mi(o.x,o.y,o.z,0,0,0,t)}throw`HelioState: Unsupported body "${i}"`}}function gx(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function vx(i,e,t){if(i===Se.Earth||e===Se.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Ct(t),s=vc(i,n,!1),r=lc(s),a=vc(e,n,!1),o=lc(a);return gx(r.elon-o.elon)}function _x(i,e,t,n){let s,r=0,a=0,o=0;switch(i){case Se.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case Se.Venus:e<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case Se.Mars:s=-1.52,r=1.6;break;case Se.Jupiter:s=-9.4,r=.5;break;case Se.Uranus:s=-7.19,r=.25;break;case Se.Neptune:s=-6.87;break;case Se.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const l=e/100;let c=s+l*(r+l*(a+l*o));return c+=5*Math.log10(t*n),c}function xx(i,e,t,n,s){const r=lc(n),a=et*28.06,o=et*(169.51+382e-7*s.tt),l=et*r.elat,c=et*r.elon,h=Math.asin(Math.sin(l)*Math.cos(a)-Math.cos(l)*Math.sin(a)*Math.sin(c-o)),u=Math.sin(Math.abs(h));let d=-9+.044*i;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(e*t),{mag:d,ring_tilt:On*h}}function Mx(i,e,t){let n=i*et,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Li;let l=t/o;return a+=5*Math.log10(e*l),a}class yx{constructor(e,t,n,s,r,a,o,l){this.time=e,this.mag=t,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=l,this.phase_fraction=(1+Math.cos(et*n))/2}}function T0(i,e){if(i===Se.Earth)throw"The illumination of the Earth is not defined.";const t=Ct(e),n=Cs(Un.Earth,t);let s,r,a,o;i===Se.Sun?(a=new ut(-n.x,-n.y,-n.z,t),r=new ut(0,0,0,t),s=0):(i===Se.Moon?(a=Ns(t),r=new ut(n.x+a.x,n.y+a.y,n.z+a.z,t)):(r=vi(i,e),a=new ut(r.x-n.x,r.y-n.y,r.z-n.z,t)),s=G2(a,r));let l=a.Length(),c=r.Length(),h;if(i===Se.Sun)o=z2+5*Math.log10(l);else if(i===Se.Moon)o=Mx(s,c,l);else if(i===Se.Saturn){const u=xx(s,c,l,a,t);o=u.mag,h=u.ring_tilt}else o=_x(i,s,c,l);return new yx(t,o,s,c,l,a,r,h)}function Sx(i){return vx(Se.Moon,Se.Sun,i)}var Lu;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Lu||(Lu={}));function Ex(i,e){return new Mi([[e.rot[0][0]*i.rot[0][0]+e.rot[1][0]*i.rot[0][1]+e.rot[2][0]*i.rot[0][2],e.rot[0][1]*i.rot[0][0]+e.rot[1][1]*i.rot[0][1]+e.rot[2][1]*i.rot[0][2],e.rot[0][2]*i.rot[0][0]+e.rot[1][2]*i.rot[0][1]+e.rot[2][2]*i.rot[0][2]],[e.rot[0][0]*i.rot[1][0]+e.rot[1][0]*i.rot[1][1]+e.rot[2][0]*i.rot[1][2],e.rot[0][1]*i.rot[1][0]+e.rot[1][1]*i.rot[1][1]+e.rot[2][1]*i.rot[1][2],e.rot[0][2]*i.rot[1][0]+e.rot[1][2]*i.rot[1][1]+e.rot[2][2]*i.rot[1][2]],[e.rot[0][0]*i.rot[2][0]+e.rot[1][0]*i.rot[2][1]+e.rot[2][0]*i.rot[2][2],e.rot[0][1]*i.rot[2][0]+e.rot[1][1]*i.rot[2][1]+e.rot[2][1]*i.rot[2][2],e.rot[0][2]*i.rot[2][0]+e.rot[1][2]*i.rot[2][1]+e.rot[2][2]*i.rot[2][2]]])}function R0(i,e){e=Ct(e);const t=i.lat*et,n=i.lon*et,s=i.dist*Math.cos(t);return new ut(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(t),e)}function C0(i){const e=bx(i);return new oc(e.lon/15,e.lat,e.dist,i)}function bx(i){const e=i.x*i.x+i.y*i.y,t=Math.sqrt(e+i.z*i.z);let n,s;if(e===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=On*Math.atan2(i.y,i.x),s<0&&(s+=360),n=On*Math.atan2(i.z,Math.sqrt(e));return new Yc(n,s,t)}function wx(i,e){let t;if(Lt(e),e<-90||e>90)return 0;{let n=e;n<-1&&(n=-1),t=1.02/Math.tan((n+10.3/(n+5.11))*et)/60,e<-1&&(t*=(e+90)/89)}return t}function Sa(i,e){return new ut(i.rot[0][0]*e.x+i.rot[1][0]*e.y+i.rot[2][0]*e.z,i.rot[0][1]*e.x+i.rot[1][1]*e.y+i.rot[2][1]*e.z,i.rot[0][2]*e.x+i.rot[1][2]*e.y+i.rot[2][2]*e.z,e.t)}function Ax(){return new Mi([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function Tx(){return new Mi([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function Rx(i){i=Ct(i);const e=g0(i,Yt.From2000),t=_0(i,Yt.From2000);return Ex(e,t)}function Cx(i){const t=gr(Ct(i)).tobl*et,n=Math.cos(t),s=Math.sin(t);return new Mi([[1,0,0],[0,+n,+s],[0,-s,+n]])}var Nu;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Nu||(Nu={}));var Uu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(Uu||(Uu={}));const Dx=["Venus","Mars","Jupiter","Saturn"];function D0(i){return new Zc(i.lat,i.lng,i.elevationM)}function Za(i,e,t,n){const s=M0(t,D0(n),i,e,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function Go(i,e,t){const n=D0(t),s=ix(Se[i],e,n,!0,!0),r=M0(e,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function Ho(i,e){return T0(Se[i],e).mag}function Px(i){const e=Sx(i),t=T0(Se.Moon,i);return{phaseFraction:e/360,illuminatedFraction:t.phase_fraction}}const Ix=2e3,Lx=3,Nx=20;function _c(i,e,t){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const n=i.year!==void 0,s=i.year??Ix,r=i.month??(n?1:Lx),a=i.day??(n?1:Nx),o=t??Math.round(e/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class Ni{static ANCHOR="vec4 diffuseColor = vec4( diffuse, opacity );";static CORE=.18;static RIM=.5;static apply(e){e.transparent=!0,e.depthWrite=!1,e.onBeforeCompile=t=>{t.fragmentShader=Ni.patch(t.fragmentShader)}}static patch(e){return e.replace(Ni.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
4709
|
+
*/const ih=173.1446326846693,Vi=14959787069098932e-8,ee=.017453292519943295,Gu=.26179938779914946,Yn=57.29577951308232,R0=3.819718634205488,cx=365.24217,Hu=new Date("2000-01-01T12:00:00Z"),ti=2*Math.PI,xi=3600*(180/Math.PI),Rs=484813681109536e-20,C0=10800*60,lx=2*C0,Vu=7292115e-11,hx=C0/Math.PI,ux=-.17-5*Math.log10(hx),pl=.996647180302104,dx=pl*pl,ml=6378.1366,fx=ml/Vi,D0=81.30056,sh=.0002959122082855911,gl=2825345909524226e-22,vl=8459715185680659e-23,_l=1292024916781969e-23,xl=1524358900784276e-23;function Wa(i){if(i!==!0&&i!==!1)throw console.trace(),`Value is not boolean: ${i}`;return i}function ze(i){if(!Number.isFinite(i))throw console.trace(),`Value is not a finite number: ${i}`;return i}function Ss(i){return i-Math.floor(i)}function px(i,t){const e=i.x*i.x+i.y*i.y+i.z*i.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 s=(i.x*t.x+i.y*t.y+i.z*t.z)/Math.sqrt(e*n);return s<=-1?180:s>=1?0:Yn*Math.acos(s)}var St;(function(i){i.Sun="Sun",i.Moon="Moon",i.Mercury="Mercury",i.Venus="Venus",i.Earth="Earth",i.Mars="Mars",i.Jupiter="Jupiter",i.Saturn="Saturn",i.Uranus="Uranus",i.Neptune="Neptune",i.Pluto="Pluto",i.SSB="SSB",i.EMB="EMB",i.Star1="Star1",i.Star2="Star2",i.Star3="Star3",i.Star4="Star4",i.Star5="Star5",i.Star6="Star6",i.Star7="Star7",i.Star8="Star8"})(St||(St={}));const mx=[St.Star1,St.Star2,St.Star3,St.Star4,St.Star5,St.Star6,St.Star7,St.Star8],gx=[{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 vx(i){const t=mx.indexOf(i);return t>=0?gx[t]:null}function rh(i){const t=vx(i);return t&&t.dist>0?t:null}var $e;(function(i){i[i.From2000=0]="From2000",i[i.Into2000=1]="Into2000"})($e||($e={}));const Xn={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 _x(i){var t,e,n,s,r,a,o;const c=2e3+(i-14)/cx;return c<-500?(t=(c-1820)/100,-20+32*t*t):c<500?(t=c/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,10583.6-1014.41*t+33.78311*e-5.952053*n-.1798452*s+.022174192*r+.0090316521*a):c<1600?(t=(c-1e3)/100,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,1574.2-556.01*t+71.23472*e+.319781*n-.8503463*s-.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,s=e*e,8.83+.1603*t-.0059285*e+13336e-8*n-s/1174e3):c<1860?(t=c-1800,e=t*t,n=t*e,s=e*e,r=e*n,a=n*n,o=n*s,13.72-.332447*t+.0068612*e+.0041116*n-37436e-8*s+121272e-10*r-1699e-10*a+875e-12*o):c<1900?(t=c-1860,e=t*t,n=t*e,s=e*e,r=e*n,7.62+.5737*t-.251754*e+.01680668*n-.0004473624*s+r/233174):c<1920?(t=c-1900,e=t*t,n=t*e,s=e*e,-2.79+1.494119*t-.0598939*e+.0061966*n-197e-6*s):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,s=e*e,r=e*n,63.86+.3345*t-.060374*e+.0017275*n+651814e-9*s+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 xx=_x;function Wu(i){return i+xx(i)/86400}class Fs{constructor(t){if(t instanceof Fs){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()-Hu.getTime())/e,this.tt=Wu(this.ut);return}if(Number.isFinite(t)){this.date=new Date(Hu.getTime()+t*e),this.ut=t,this.tt=Wu(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 Fs(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 Fs(this.ut+t)}}function Le(i){return i instanceof Fs?i:new Fs(i)}function Mx(i){function t(d){return d%lx*Rs}const e=i.tt/36525,n=t(128710479305e-5+e*1295965810481e-4),s=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*(s-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*(s+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 P0(i){var t=i.tt/36525,e=((((-434e-10*t-576e-9)*t+.0020034)*t-1831e-7)*t-46.836769)*t+84381.406;return e/3600}var ha;function Rr(i){if(!ha||Math.abs(ha.tt-i.tt)>1e-6){const t=Mx(i),e=P0(i),n=e+t.deps/3600;ha={tt:i.tt,dpsi:t.dpsi,deps:t.deps,ee:t.dpsi*Math.cos(e*ee)/15,mobl:e,tobl:n}}return ha}function yx(i,t){const e=i*ee,n=Math.cos(e),s=Math.sin(e);return[t[0],t[1]*n-t[2]*s,t[1]*s+t[2]*n]}function Sx(i,t){return yx(P0(i),t)}function Ex(i){const t=i.tt/36525;function e(At,_t){const It=[];let Lt;for(Lt=0;Lt<=_t-At;++Lt)It.push(0);return{min:At,array:It}}function n(At,_t,It,Lt){const Nt=[];for(let Jt=0;Jt<=_t-At;++Jt)Nt.push(e(It,Lt));return{min:At,array:Nt}}function s(At,_t,It){const Lt=At.array[_t-At.min];return Lt.array[It-Lt.min]}function r(At,_t,It,Lt){const Nt=At.array[_t-At.min];Nt.array[It-Nt.min]=Lt}let a,o,c,l,h,u,d,f,g,x,m,p,w,A,M,S,b,R,_,E,D,C,I,W=n(-6,6,1,4),X=n(-6,6,1,4);function U(At,_t){return s(W,At,_t)}function q(At,_t){return s(X,At,_t)}function H(At,_t,It){return r(W,At,_t,It)}function $(At,_t,It){return r(X,At,_t,It)}function et(At,_t,It,Lt,Nt){Nt(At*It-_t*Lt,_t*It+At*Lt)}function j(At){return Math.sin(ti*At)}d=t*t,g=0,I=0,m=0,p=3422.7;var it=j(.19833+.05611*t),ut=j(.27869+.04508*t),kt=j(.16827-.36903*t),qt=j(.34734-5.37261*t),Bt=j(.10498-5.37899*t),Y=j(.42681-.41855*t),rt=j(.14943-5.37511*t);for(R=.84*it+.31*ut+14.27*kt+7.26*qt+.28*Bt+.24*Y,_=2.94*it+.31*ut+14.27*kt+9.34*qt+1.12*Bt+.83*Y,E=-6.4*it-1.89*Y,D=.21*it+.31*ut+14.27*kt-88.7*qt-15.3*Bt+.24*Y-1.86*rt,C=R-E,f=-3332e-9*j(.59734-5.37261*t)-539e-9*j(.35498-5.37899*t)-64e-9*j(.39943-5.37511*t),w=ti*Ss(.60643382+1336.85522467*t-313e-8*d)+R/xi,A=ti*Ss(.37489701+1325.55240982*t+2565e-8*d)+_/xi,M=ti*Ss(.99312619+99.99735956*t-44e-8*d)+E/xi,S=ti*Ss(.25909118+1342.2278298*t-892e-8*d)+D/xi,b=ti*Ss(.82736186+1236.85308708*t-397e-8*d)+C/xi,h=1;h<=4;++h){switch(h){case 1:c=A,o=4,l=1.000002208;break;case 2:c=M,o=3,l=.997504612-.002495388*t;break;case 3:c=S,o=4,l=1.000002708+139.978*f;break;case 4:c=b,o=6,l=1;break;default:throw`Internal error: I = ${h}`}for(H(0,h,1),H(1,h,Math.cos(c)*l),$(0,h,0),$(1,h,Math.sin(c)*l),u=2;u<=o;++u)et(U(u-1,h),q(u-1,h),U(1,h),q(1,h),(At,_t)=>(H(u,h,At),$(u,h,_t)));for(u=1;u<=o;++u)H(-u,h,U(u,h)),$(-u,h,-q(u,h))}function nt(At,_t,It,Lt){for(var Nt={x:1,y:0},Jt=[0,At,_t,It,Lt],Qt=1;Qt<=4;++Qt)Jt[Qt]!==0&&et(Nt.x,Nt.y,U(Jt[Qt],Qt),q(Jt[Qt],Qt),(me,de)=>(Nt.x=me,Nt.y=de));return Nt}function z(At,_t,It,Lt,Nt,Jt,Qt,me){var de=nt(Nt,Jt,Qt,me);g+=At*de.y,I+=_t*de.y,m+=It*de.x,p+=Lt*de.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 bt(At,_t,It,Lt,Nt){return At*nt(_t,It,Lt,Nt).y}x=0,x+=bt(-526.069,0,0,1,-2),x+=bt(-3.352,0,0,1,-4),x+=bt(44.297,1,0,1,-2),x+=bt(-6,1,0,1,-4),x+=bt(20.599,-1,0,1,0),x+=bt(-30.598,-1,0,1,-2),x+=bt(-24.649,-2,0,1,0),x+=bt(-2,-2,0,1,-2),x+=bt(-22.571,0,1,1,-2),x+=bt(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/xi;let Dt=(1.000002708+139.978*f)*(18518.511+1.189+m)*Math.sin(a)-6.24*Math.sin(3*a)+x;return{geo_eclip_lon:ti*Ss((w+g/xi)/ti),geo_eclip_lat:Math.PI/(180*3600)*Dt,distance_au:xi*fx/(.999953253*p)}}function I0(i,t){return[i.rot[0][0]*t[0]+i.rot[1][0]*t[1]+i.rot[2][0]*t[2],i.rot[0][1]*t[0]+i.rot[1][1]*t[1]+i.rot[2][1]*t[2],i.rot[0][2]*t[0]+i.rot[1][2]*t[1]+i.rot[2][2]*t[2]]}function Xa(i,t,e){const n=L0(t,e);return I0(n,i)}function L0(i,t){const e=i.tt/36525;let n=84381.406,s=((((-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*=Rs,s*=Rs,r*=Rs,a*=Rs;const o=Math.sin(n),c=Math.cos(n),l=Math.sin(-s),h=Math.cos(-s),u=Math.sin(-r),d=Math.cos(-r),f=Math.sin(a),g=Math.cos(a),x=g*h-l*f*d,m=g*l*c+f*d*h*c-o*f*u,p=g*l*o+f*d*h*o+c*f*u,w=-f*h-l*g*d,A=-f*l*c+g*d*h*c-o*g*u,M=-f*l*o+g*d*h*o+c*g*u,S=l*u,b=-u*h*c-o*d,R=-u*h*o+d*c;if(t===$e.Into2000)return new Di([[x,m,p],[w,A,M],[S,b,R]]);if(t===$e.From2000)return new Di([[x,w,S],[m,A,b],[p,M,R]]);throw"Invalid precess direction"}function bx(i){const t=.779057273264+.00273781191135448*i.ut,e=i.ut%1;let n=360*((t+e)%1);return n<0&&(n+=360),n}let ua;function ah(i){if(!ua||ua.tt!==i.tt){const t=i.tt/36525;let e=15*Rr(i).ee;const n=bx(i);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),ua={tt:i.tt,st:r}}return ua.st}function N0(i,t){const e=i.latitude*ee,n=Math.sin(e),s=Math.cos(e),r=1/Math.hypot(s,pl*n),a=dx*r,o=i.height/1e3,c=ml*r+o,l=ml*a+o,h=(15*t+i.longitude)*ee,u=Math.sin(h),d=Math.cos(h);return{pos:[c*s*d/Vi,c*s*u/Vi,l*n/Vi],vel:[-Vu*c*s*u*86400/Vi,Vu*c*s*d*86400/Vi,0]}}function Ml(i,t,e){const n=U0(t,e);return I0(n,i)}function U0(i,t){const e=Rr(i),n=e.mobl*ee,s=e.tobl*ee,r=e.dpsi*Rs,a=Math.cos(n),o=Math.sin(n),c=Math.cos(s),l=Math.sin(s),h=Math.cos(r),u=Math.sin(r),d=h,f=-u*a,g=-u*o,x=u*c,m=h*a*c+o*l,p=h*o*c-a*l,w=u*l,A=h*a*l-o*c,M=h*o*l+a*c;if(t===$e.From2000)return new Di([[d,x,w],[f,m,A],[g,p,M]]);if(t===$e.Into2000)return new Di([[d,f,g],[x,m,p],[w,A,M]]);throw"Invalid precess direction"}function oh(i,t,e){return e===$e.Into2000?Xa(Ml(i,t,e),t,e):Ml(Xa(i,t,e),t,e)}function wx(i,t){const e=ah(i),n=N0(t,e).pos;return oh(n,i,$e.Into2000)}class ue{constructor(t,e,n,s){this.x=t,this.y=e,this.z=n,this.t=s}Length(){return Math.hypot(this.x,this.y,this.z)}}class bi{constructor(t,e,n,s,r,a,o){this.x=t,this.y=e,this.z=n,this.vx=s,this.vy=r,this.vz=a,this.t=o}}class ch{constructor(t,e,n){this.lat=ze(t),this.lon=ze(e),this.dist=ze(n)}}class yl{constructor(t,e,n,s){this.ra=ze(t),this.dec=ze(e),this.dist=ze(n),this.vec=s}}class Di{constructor(t){this.rot=t}}class Ax{constructor(t,e,n,s){this.azimuth=ze(t),this.altitude=ze(e),this.ra=ze(n),this.dec=ze(s)}}class Tx{constructor(t,e,n){this.vec=t,this.elat=ze(e),this.elon=ze(n)}}function F0(i,t){return new ue(i[0],i[1],i[2],t)}function Rx(i,t){const e=F0(i,t),n=e.x*e.x+e.y*e.y,s=Math.sqrt(n+e.z*e.z);if(n===0){if(e.z===0)throw"Indeterminate sky coordinates";return new yl(0,e.z<0?-90:90,s,e)}let r=R0*Math.atan2(e.y,e.x);r<0&&(r+=24);const a=Yn*Math.atan2(i[2],Math.sqrt(n));return new yl(r,a,s,e)}function Qo(i,t){const e=i*ee,n=Math.cos(e),s=Math.sin(e);return[n*t[0]+s*t[1],n*t[1]-s*t[0],t[2]]}function O0(i,t,e,n,s){let r=Le(i);lh(t),ze(e),ze(n);const a=Math.sin(t.latitude*ee),o=Math.cos(t.latitude*ee),c=Math.sin(t.longitude*ee),l=Math.cos(t.longitude*ee),h=Math.sin(n*ee),u=Math.cos(n*ee),d=Math.sin(e*Gu),f=Math.cos(e*Gu);let g=[o*l,o*c,a],x=[-a*l,-a*c,o],m=[c,-l,0];const p=-15*ah(r);let w=Qo(p,g),A=Qo(p,x),M=Qo(p,m),S=[u*f,u*d,h];const b=S[0]*w[0]+S[1]*w[1]+S[2]*w[2],R=S[0]*A[0]+S[1]*A[1]+S[2]*A[2],_=S[0]*M[0]+S[1]*M[1]+S[2]*M[2];let E=Math.hypot(R,_),D;E>0?(D=-Yn*Math.atan2(_,R),D<0&&(D+=360)):D=0;let C=Yn*Math.atan2(E,b),I=e,W=n;{let X=C,U=Qx(s,90-C);if(C-=U,U>0&&C>3e-4){const q=Math.sin(C*ee),H=Math.cos(C*ee),$=Math.sin(X*ee),et=Math.cos(X*ee),j=[];for(let it=0;it<3;++it)j.push((S[it]-et*w[it])/$*q+w[it]*H);E=Math.hypot(j[0],j[1]),E>0?(I=R0*Math.atan2(j[1],j[0]),I<0&&(I+=24)):I=0,W=Yn*Math.atan2(j[2],E)}}return new Ax(D,90-C,I,W)}function lh(i){if(!(i instanceof hh))throw`Not an instance of the Observer class: ${i}`;if(ze(i.latitude),ze(i.longitude),ze(i.height),i.latitude<-90||i.latitude>90)throw`Latitude ${i.latitude} is out of range. Must be -90..+90.`;return i}class hh{constructor(t,e,n){this.latitude=t,this.longitude=e,this.height=n,lh(this)}}function Cx(i){const t=Le(i).AddDays(-1/ih),e=zs(Xn.Earth,t),n=[-e.x,-e.y,-e.z],[s,r,a]=oh(n,t,$e.From2000),o=ee*Rr(t).tobl,c=Math.cos(o),l=Math.sin(o),h=new ue(s,r,a,t);return z0(h,c,l)}function Dx(i,t,e,n,s){lh(e),Wa(n),Wa(s);const r=Le(t),a=wx(r,e),o=Pl(i,r,s),c=[o.x-a[0],o.y-a[1],o.z-a[2]],l=oh(c,r,$e.From2000);return Rx(l,r)}function Px(i,t,e){const n=Le(i),s=ah(n);let r=N0(t,s).pos;return F0(r,n)}function z0(i,t,e){const n=i.x,s=i.y*t+i.z*e,r=-i.y*e+i.z*t,a=Math.hypot(n,s);let o=0;a>0&&(o=Yn*Math.atan2(s,n),o<0&&(o+=360));let c=Yn*Math.atan2(r,a),l=new ue(n,s,r,i.t);return new Tx(l,c,o)}function Sl(i){const t=Rr(i.t),e=[i.x,i.y,i.z],n=Xa(e,i.t,$e.From2000),[s,r,a]=Ml(n,i.t,$e.From2000),o=new ue(s,r,a,i.t),c=t.tobl*ee;return z0(o,Math.cos(c),Math.sin(c))}function Ws(i){const t=Le(i),e=Ex(t),n=e.distance_au*Math.cos(e.geo_eclip_lat),s=[n*Math.cos(e.geo_eclip_lon),n*Math.sin(e.geo_eclip_lon),e.distance_au*Math.sin(e.geo_eclip_lat)],r=Sx(t,s),a=Xa(r,t,$e.Into2000);return new ue(a[0],a[1],a[2],t)}function B0(i){const t=Le(i),e=1e-5,n=t.AddDays(-e),s=t.AddDays(+e),r=Ws(n),a=Ws(s);return new bi((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 Ix(i){const t=Le(i),e=B0(t),n=1+D0;return new bi(e.x/n,e.y/n,e.z/n,e.vx/n,e.vy/n,e.vz/n,t)}function Os(i,t,e){let n=1,s=0;for(let r of i){let a=0;for(let[c,l,h]of r)a+=c*Math.cos(l+t*h);let o=n*a;e&&(o%=ti),s+=o,n*=t}return s}function jo(i,t){let e=1,n=0,s=0,r=0;for(let a of i){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))}s+=r*n*c-e*o,n=e,e*=t,++r}return s}const dr=365250,El=0,bl=1,wl=2;function Al(i){return new We(i[0]+44036e-11*i[1]-190919e-12*i[2],-479966e-12*i[0]+.917482137087*i[1]-.397776982902*i[2],.397776982902*i[1]+.917482137087*i[2])}function k0(i,t,e){const n=e*Math.cos(t),s=Math.cos(i),r=Math.sin(i);return[n*s,n*r,e*Math.sin(t)]}function zs(i,t){const e=t.tt/dr,n=Os(i[El],e,!0),s=Os(i[bl],e,!1),r=Os(i[wl],e,!1),a=k0(n,s,r);return Al(a).ToAstroVector(t)}function Tl(i,t){const e=t/dr,n=Os(i[El],e,!0),s=Os(i[bl],e,!1),r=Os(i[wl],e,!1),a=jo(i[El],e),o=jo(i[bl],e),c=jo(i[wl],e),l=Math.cos(n),h=Math.sin(n),u=Math.cos(s),d=Math.sin(s),f=+(c*u*l)-r*d*l*o-r*u*h*a,g=+(c*u*h)-r*d*h*o+r*u*l*a,x=+(c*d)+r*u*o,m=k0(n,s,r),p=[f/dr,g/dr,x/dr],w=Al(m),A=Al(p);return new Qi(t,w,A)}function da(i,t,e,n){const s=n/(n+sh),r=zs(Xn[e],t);i.x+=s*r.x,i.y+=s*r.y,i.z+=s*r.z}function Lx(i){const t=new ue(0,0,0,i);return da(t,i,St.Jupiter,gl),da(t,i,St.Saturn,vl),da(t,i,St.Uranus,_l),da(t,i,St.Neptune,xl),t}const Rl=51,Nx=29200,Cs=146,ei=201,Yi=[[-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 We{constructor(t,e,n){this.x=t,this.y=e,this.z=n}clone(){return new We(this.x,this.y,this.z)}ToAstroVector(t){return new ue(this.x,this.y,this.z,t)}static zero(){return new We(0,0,0)}quadrature(){return this.x*this.x+this.y*this.y+this.z*this.z}add(t){return new We(this.x+t.x,this.y+t.y,this.z+t.z)}sub(t){return new We(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 We(t*this.x,t*this.y,t*this.z)}div(t){return new We(this.x/t,this.y/t,this.z/t)}mean(t){return new We((this.x+t.x)/2,(this.y+t.y)/2,(this.z+t.z)/2)}neg(){return new We(-this.x,-this.y,-this.z)}}class Qi{constructor(t,e,n){this.tt=t,this.r=e,this.v=n}clone(){return new Qi(this.tt,this.r,this.v)}sub(t){return new Qi(this.tt,this.r.sub(t.r),this.v.sub(t.v))}}function Ux(i){let[t,[e,n,s],[r,a,o]]=i;return new Qi(t,new We(e,n,s),new We(r,a,o))}function fa(i,t,e,n){const s=n/(n+sh),r=Tl(Xn[e],t);return i.r.incr(r.r.mul(s)),i.v.incr(r.v.mul(s)),r}function rr(i,t,e){const n=e.sub(i),s=n.quadrature();return n.mul(t/(s*Math.sqrt(s)))}class ao{constructor(t){let e=new Qi(t,new We(0,0,0),new We(0,0,0));this.Jupiter=fa(e,t,St.Jupiter,gl),this.Saturn=fa(e,t,St.Saturn,vl),this.Uranus=fa(e,t,St.Uranus,_l),this.Neptune=fa(e,t,St.Neptune,xl),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 Qi(t,e.r.mul(-1),e.v.mul(-1))}Acceleration(t){let e=rr(t,sh,this.Sun.r);return e.incr(rr(t,gl,this.Jupiter.r)),e.incr(rr(t,vl,this.Saturn.r)),e.incr(rr(t,_l,this.Uranus.r)),e.incr(rr(t,xl,this.Neptune.r)),e}}class oo{constructor(t,e,n,s){this.tt=t,this.r=e,this.v=n,this.a=s}clone(){return new oo(this.tt,this.r.clone(),this.v.clone(),this.a.clone())}}class G0{constructor(t,e){this.bary=t,this.grav=e}}function qa(i,t,e,n){return new We(t.x+i*(e.x+i*n.x/2),t.y+i*(e.y+i*n.y/2),t.z+i*(e.z+i*n.z/2))}function Xu(i,t,e){return new We(t.x+i*e.x,t.y+i*e.y,t.z+i*e.z)}function Cl(i,t){const e=i-t.tt,n=new ao(i),s=qa(e,t.r,t.v,t.a),r=n.Acceleration(s).mean(t.a),a=qa(e,t.r,t.v,r),o=t.v.add(r.mul(e)),c=n.Acceleration(a),l=new oo(i,a,o,c);return new G0(n,l)}const Fx=[];function H0(i,t){const e=Math.floor(i);return e<0?0:e>=t?t-1:e}function Dl(i){const t=Ux(i),e=new ao(t.tt),n=t.r.add(e.Sun.r),s=t.v.add(e.Sun.v),r=e.Acceleration(n),a=new oo(t.tt,n,s,r);return new G0(e,a)}function Ox(i,t){const e=Yi[0][0];if(t<e||t>Yi[Rl-1][0])return null;const n=H0((t-e)/Nx,Rl-1);if(!i[n]){const r=i[n]=[];r[0]=Dl(Yi[n]).grav,r[ei-1]=Dl(Yi[n+1]).grav;let a,o=r[0].tt;for(a=1;a<ei-1;++a)r[a]=Cl(o+=Cs,r[a-1]).grav;o=r[ei-1].tt;var s=[];for(s[ei-1]=r[ei-1],a=ei-2;a>0;--a)s[a]=Cl(o-=Cs,s[a+1]).grav;for(a=ei-2;a>0;--a){const c=a/(ei-1);r[a].r=r[a].r.mul(1-c).add(s[a].r.mul(c)),r[a].v=r[a].v.mul(1-c).add(s[a].v.mul(c)),r[a].a=r[a].a.mul(1-c).add(s[a].a.mul(c))}}return i[n]}function qu(i,t,e){let n=Dl(i);const s=Math.ceil((t-n.grav.tt)/e);for(let r=0;r<s;++r)n=Cl(r+1===s?t:n.grav.tt+e,n.grav);return n}function V0(i,t){let e,n,s;const r=Ox(Fx,i.tt);if(r){const a=H0((i.tt-r[0].tt)/Cs,ei-1),o=r[a],c=r[a+1],l=o.a.mean(c.a),h=qa(i.tt-o.tt,o.r,o.v,l),u=Xu(i.tt-o.tt,o.v,l),d=qa(i.tt-c.tt,c.r,c.v,l),f=Xu(i.tt-c.tt,c.v,l),g=(i.tt-o.tt)/Cs;e=h.mul(1-g).add(d.mul(g)),n=u.mul(1-g).add(f.mul(g))}else{let a;i.tt<Yi[0][0]?a=qu(Yi[0],i.tt,-Cs):a=qu(Yi[Rl-1],i.tt,+Cs),e=a.grav.r,n=a.grav.v,s=a.bary}return s||(s=new ao(i.tt)),e=e.sub(s.Sun.r),n=n.sub(s.Sun.v),new bi(e.x,e.y,e.z,n.x,n.y,n.z,i)}function Ai(i,t){var e=Le(t);if(i in Xn)return zs(Xn[i],e);if(i===St.Pluto){const a=V0(e);return new ue(a.x,a.y,a.z,e)}if(i===St.Sun)return new ue(0,0,0,e);if(i===St.Moon){var n=zs(Xn.Earth,e),s=Ws(e);return new ue(n.x+s.x,n.y+s.y,n.z+s.z,e)}if(i===St.EMB){const a=zs(Xn.Earth,e),o=Ws(e),c=1+D0;return new ue(a.x+o.x/c,a.y+o.y/c,a.z+o.z/c,e)}if(i===St.SSB)return Lx(e);const r=rh(i);if(r){const a=new ch(r.dec,15*r.ra,r.dist);return X0(a,e)}throw`HelioVector: Unknown body "${i}"`}function zx(i,t){let e=t,n=0;for(let s=0;s<10;++s){const r=i(e),a=r.Length()/ih;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 Bx{constructor(t,e,n,s){this.observerBody=t,this.targetBody=e,this.aberration=n,this.observerPos=s}Position(t){this.aberration&&(this.observerPos=Ai(this.observerBody,t));const e=Ai(this.targetBody,t);return new ue(e.x-this.observerPos.x,e.y-this.observerPos.y,e.z-this.observerPos.z,t)}}function kx(i,t,e,n){Wa(n);const s=Le(i);if(rh(e)){const o=Ai(e,s);if(n){const l=Hx(t,s),h=new ue(o.x-l.x,o.y-l.y,o.z-l.z,s),u=ih/h.Length();return new ue(h.x+l.vx/u,h.y+l.vy/u,h.z+l.vz/u,s)}const c=Ai(t,s);return new ue(o.x-c.x,o.y-c.y,o.z-c.z,s)}let r;n?r=new ue(0,0,0,s):r=Ai(t,s);const a=new Bx(t,e,n,r);return zx(o=>a.Position(o),s)}function Pl(i,t,e){Wa(e);const n=Le(t);switch(i){case St.Earth:return new ue(0,0,0,n);case St.Moon:return Ws(n);default:const s=kx(n,St.Earth,i,e);return s.t=n,s}}function Gx(i,t){return new bi(i.r.x,i.r.y,i.r.z,i.v.x,i.v.y,i.v.z,t)}function Hx(i,t){const e=Le(t);switch(i){case St.Sun:return new bi(0,0,0,0,0,0,e);case St.SSB:const n=new ao(e.tt);return new bi(-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 s=Tl(Xn[i],e.tt);return Gx(s,e);case St.Pluto:return V0(e);case St.Moon:case St.EMB:const r=Tl(Xn.Earth,e.tt),a=i==St.Moon?B0(e):Ix(e);return new bi(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(rh(i)){const o=Ai(i,e);return new bi(o.x,o.y,o.z,0,0,0,e)}throw`HelioState: Unsupported body "${i}"`}}function Vx(i){for(;i<0;)i+=360;for(;i>=360;)i-=360;return i}function Wx(i,t,e){if(i===St.Earth||t===St.Earth)throw"The Earth does not have a longitude as seen from itself.";const n=Le(e),s=Pl(i,n,!1),r=Sl(s),a=Pl(t,n,!1),o=Sl(a);return Vx(r.elon-o.elon)}function Xx(i,t,e,n){let s,r=0,a=0,o=0;switch(i){case St.Mercury:s=-.6,r=4.98,a=-4.88,o=3.02;break;case St.Venus:t<163.6?(s=-4.47,r=1.03,a=.57,o=.13):(s=.98,r=-1.02);break;case St.Mars:s=-1.52,r=1.6;break;case St.Jupiter:s=-9.4,r=.5;break;case St.Uranus:s=-7.19,r=.25;break;case St.Neptune:s=-6.87;break;case St.Pluto:s=-1,r=4;break;default:throw`VisualMagnitude: unsupported body ${i}`}const c=t/100;let l=s+c*(r+c*(a+c*o));return l+=5*Math.log10(e*n),l}function qx(i,t,e,n,s){const r=Sl(n),a=ee*28.06,o=ee*(169.51+382e-7*s.tt),c=ee*r.elat,l=ee*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*i;return d+=u*(-2.6+1.2*u),d+=5*Math.log10(t*e),{mag:d,ring_tilt:Yn*h}}function Yx(i,t,e){let n=i*ee,s=n*n,r=s*s,a=-12.717+1.49*Math.abs(n)+.0431*r;const o=385000.6/Vi;let c=e/o;return a+=5*Math.log10(t*c),a}class Kx{constructor(t,e,n,s,r,a,o,c){this.time=t,this.mag=e,this.phase_angle=n,this.helio_dist=s,this.geo_dist=r,this.gc=a,this.hc=o,this.ring_tilt=c,this.phase_fraction=(1+Math.cos(ee*n))/2}}function W0(i,t){if(i===St.Earth)throw"The illumination of the Earth is not defined.";const e=Le(t),n=zs(Xn.Earth,e);let s,r,a,o;i===St.Sun?(a=new ue(-n.x,-n.y,-n.z,e),r=new ue(0,0,0,e),s=0):(i===St.Moon?(a=Ws(e),r=new ue(n.x+a.x,n.y+a.y,n.z+a.z,e)):(r=Ai(i,t),a=new ue(r.x-n.x,r.y-n.y,r.z-n.z,e)),s=px(a,r));let c=a.Length(),l=r.Length(),h;if(i===St.Sun)o=ux+5*Math.log10(c);else if(i===St.Moon)o=Yx(s,l,c);else if(i===St.Saturn){const u=qx(s,l,c,a,e);o=u.mag,h=u.ring_tilt}else o=Xx(i,s,l,c);return new Kx(e,o,s,l,c,a,r,h)}function Zx(i){return Wx(St.Moon,St.Sun,i)}var Yu;(function(i){i[i.Pericenter=0]="Pericenter",i[i.Apocenter=1]="Apocenter"})(Yu||(Yu={}));function $x(i,t){return new Di([[t.rot[0][0]*i.rot[0][0]+t.rot[1][0]*i.rot[0][1]+t.rot[2][0]*i.rot[0][2],t.rot[0][1]*i.rot[0][0]+t.rot[1][1]*i.rot[0][1]+t.rot[2][1]*i.rot[0][2],t.rot[0][2]*i.rot[0][0]+t.rot[1][2]*i.rot[0][1]+t.rot[2][2]*i.rot[0][2]],[t.rot[0][0]*i.rot[1][0]+t.rot[1][0]*i.rot[1][1]+t.rot[2][0]*i.rot[1][2],t.rot[0][1]*i.rot[1][0]+t.rot[1][1]*i.rot[1][1]+t.rot[2][1]*i.rot[1][2],t.rot[0][2]*i.rot[1][0]+t.rot[1][2]*i.rot[1][1]+t.rot[2][2]*i.rot[1][2]],[t.rot[0][0]*i.rot[2][0]+t.rot[1][0]*i.rot[2][1]+t.rot[2][0]*i.rot[2][2],t.rot[0][1]*i.rot[2][0]+t.rot[1][1]*i.rot[2][1]+t.rot[2][1]*i.rot[2][2],t.rot[0][2]*i.rot[2][0]+t.rot[1][2]*i.rot[2][1]+t.rot[2][2]*i.rot[2][2]]])}function X0(i,t){t=Le(t);const e=i.lat*ee,n=i.lon*ee,s=i.dist*Math.cos(e);return new ue(s*Math.cos(n),s*Math.sin(n),i.dist*Math.sin(e),t)}function q0(i){const t=Jx(i);return new yl(t.lon/15,t.lat,t.dist,i)}function Jx(i){const t=i.x*i.x+i.y*i.y,e=Math.sqrt(t+i.z*i.z);let n,s;if(t===0){if(i.z===0)throw"Zero-length vector not allowed.";s=0,n=i.z<0?-90:90}else s=Yn*Math.atan2(i.y,i.x),s<0&&(s+=360),n=Yn*Math.atan2(i.z,Math.sqrt(t));return new ch(n,s,e)}function Qx(i,t){let e;if(ze(t),t<-90||t>90)return 0;{let n=t;n<-1&&(n=-1),e=1.02/Math.tan((n+10.3/(n+5.11))*ee)/60,t<-1&&(e*=(t+90)/89)}return e}function Na(i,t){return new ue(i.rot[0][0]*t.x+i.rot[1][0]*t.y+i.rot[2][0]*t.z,i.rot[0][1]*t.x+i.rot[1][1]*t.y+i.rot[2][1]*t.z,i.rot[0][2]*t.x+i.rot[1][2]*t.y+i.rot[2][2]*t.z,t.t)}function jx(){return new Di([[1,0,0],[0,.9174821430670688,-.3977769691083922],[0,.3977769691083922,.9174821430670688]])}function t3(){return new Di([[1,0,0],[0,.9174821430670688,.3977769691083922],[0,-.3977769691083922,.9174821430670688]])}function e3(i){i=Le(i);const t=L0(i,$e.From2000),e=U0(i,$e.From2000);return $x(t,e)}function n3(i){const e=Rr(Le(i)).tobl*ee,n=Math.cos(e),s=Math.sin(e);return new Di([[1,0,0],[0,+n,+s],[0,-s,+n]])}var Ku;(function(i){i.Penumbral="penumbral",i.Partial="partial",i.Annular="annular",i.Total="total"})(Ku||(Ku={}));var Zu;(function(i){i[i.Invalid=0]="Invalid",i[i.Ascending=1]="Ascending",i[i.Descending=-1]="Descending"})(Zu||(Zu={}));const i3=["Venus","Mars","Jupiter","Saturn"];function Y0(i){return new hh(i.lat,i.lng,i.elevationM)}function co(i,t,e,n){const s=O0(e,Y0(n),i,t,"normal");return{altitudeDeg:s.altitude,azimuthDeg:s.azimuth}}function tc(i,t,e){const n=Y0(e),s=Dx(St[i],t,n,!0,!0),r=O0(t,n,s.ra,s.dec,"normal");return{altitudeDeg:r.altitude,azimuthDeg:r.azimuth}}function ec(i,t){return W0(St[i],t).mag}function s3(i){const t=Zx(i),e=W0(St.Moon,i);return{phaseFraction:t/360,illuminatedFraction:e.phase_fraction}}const r3=2e3,a3=3,o3=20;function Il(i,t,e){if(i.year===void 0&&i.month===void 0&&i.day===void 0&&i.hour===void 0)return;const n=i.year!==void 0,s=i.year??r3,r=i.month??(n?1:a3),a=i.day??(n?1:o3),o=e??Math.round(t/15);return new Date(Date.UTC(s,r-1,a,(i.hour??12)-o,i.minute??0,i.second??0))}class Wi{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=Wi.patch(e.fragmentShader)}}static patch(t){return t.replace(Wi.ANCHOR,`float distanceFromCentre = length( gl_PointCoord - vec2( 0.5 ) );
|
|
4710
4710
|
// Outside the inscribed circle there is no star at all — this is what kills the corners.
|
|
4711
|
-
if ( distanceFromCentre > ${
|
|
4712
|
-
float glare = 1.0 - smoothstep( ${
|
|
4713
|
-
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const
|
|
4711
|
+
if ( distanceFromCentre > ${Wi.RIM.toFixed(2)} ) discard;
|
|
4712
|
+
float glare = 1.0 - smoothstep( ${Wi.CORE.toFixed(2)}, ${Wi.RIM.toFixed(2)}, distanceFromCentre );
|
|
4713
|
+
vec4 diffuseColor = vec4( diffuse, opacity * glare );`)}}const K0=Math.PI/180,c3=180/Math.PI,l3=256,h3=19;function u3(i,t){return 156543.03392*Math.cos(i*K0)/2**t}function d3(i,t){return u3(i,t)*l3}function Z0(i,t){let e=0;for(;e<h3&&d3(i,e+1)>=t;)e++;return e}function $0(i,t,e){const n=2**e,s=(i+180)/360*n,r=t*K0,a=(1-Math.log(Math.tan(r)+1/Math.cos(r))/Math.PI)/2*n;return{x:s,y:a}}function f3(i,t,e){const{x:n,y:s}=$0(i,t,e);return{x:Math.floor(n),y:Math.floor(s),z:e}}function p3(i){const t=2**i.z,e=i.x/t*360-180,n=(i.x+1)/t*360-180,s=$u(i.y,t);return{south:$u(i.y+1,t),north:s,west:e,east:n}}function $u(i,t){const e=i/t;return Math.atan(Math.sinh(Math.PI*(1-2*e)))*c3}function J0(i,t,e,n){const s=f3(i,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:s.x+h,y:s.y+l,z:e});const o=a.map(p3),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}}const Q0=Math.PI/180,Ya=111320;function ji(i,t,e,n){const s=Ya*Math.cos(e*Q0),r=(i-e)*Ya;return{x:(t-n)*s,z:-r}}function pa(i,t,e,n){const s=Ya*Math.cos(e*Q0),r=-t,a=i;return{lat:e+r/Ya,lng:n+a/s}}const pn=256,Ju=3,m3=32768;class g3{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,s=(t.west+t.east)/2,r=Math.abs(ji(n,t.east,n,t.west).x),a=Math.abs(ji(t.north,s,t.south,s).z),o=Z0(n,Math.max(r,a)),{tiles:c}=J0(s,n,o,Ju),l=Ju*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 x=0;x<e.width;x++){const m=t.west+(t.east-t.west)*(x/(e.width-1));d[f*e.width+x]=this.sampleAt(g,m,o,u,h,l)}}return{heights:d,width:e.width,height:e.height,bounds:t}}async decodeTileInto(t,e,n,s){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 x=(f*pn+g)*4,m=h[x]*256+h[x+1]+h[x+2]/256-m3,p=u+g,w=d+f;n[w*s+p]=m}}sampleAt(t,e,n,s,r,a){const{x:o,y:c}=$0(e,t,n),l=(o-s.x)*pn,h=(c-s.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),x=l-u,m=h-d,p=r[d*a+u],w=r[d*a+f],A=r[g*a+u],M=r[g*a+f],S=p+(w-p)*x,b=A+(M-A)*x;return S+(b-S)*m}}const nc=256,Qu=3;async function v3(i,t,e,n){const s=(i.south+i.north)/2,r=(i.west+i.east)/2,a=Math.abs(ji(s,i.east,s,i.west).x),o=Math.abs(ji(i.north,r,i.south,r).z),c=Z0(s,Math.max(a,o)),{tiles:l}=J0(r,s,c,Qu),h=Qu*nc,u=document.createElement("canvas");u.width=h,u.height=h;const d=u.getContext("2d");if(!d)throw new Error("2D canvas context unavailable");const f=l[0];await Promise.all(l.map(async m=>{const p=e(m),w=await n(p);if(!w.ok)throw new Error(`Imagery tile fetch failed (${w.status}): ${p}`);const A=await createImageBitmap(await w.blob());d.drawImage(A,(m.x-f.x)*nc,(m.y-f.y)*nc)}));const g=document.createElement("canvas");g.width=t.width,g.height=t.height;const x=g.getContext("2d");if(!x)throw new Error("2D canvas context unavailable");return x.drawImage(u,0,0,h,h,0,0,t.width,t.height),g}class _3{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{source:await v3(t,e,s=>this.tileUrlTemplate.replace("{z}",String(s.z)).replace("{y}",String(s.y)).replace("{x}",String(s.x)),this.fetchImpl),width:e.width,height:e.height}}}function x3(){return{elevation:new g3,imagery:new _3}}const fr=64,Ue=fr+1,ju=512,M3=900,y3=700/900,S3=0,E3=.01;function b3(i,t,e){return{north:pa(0,-e,i,t).lat,south:pa(0,e,i,t).lat,east:pa(e,0,i,t).lng,west:pa(-e,0,i,t).lng}}async function w3(i,t,e,n=M3){const s=n,r=n*y3,a=b3(i,t,s),o={width:Ue,height:Ue},[c,l]=await Promise.all([e.elevation.getElevationGrid(a,o),e.imagery.getImageryTexture(a,{width:ju,height:ju})]),h=Math.floor(Ue/2),u=c.heights[h*Ue+h],d=new Float32Array(Ue*Ue*3),f=new Float32Array(Ue*Ue*2),g=new Float32Array(Ue*Ue*4);for(let S=0;S<Ue;S++){const b=S/(Ue-1),R=a.north+(a.south-a.north)*b;for(let _=0;_<Ue;_++){const E=_/(Ue-1),D=a.west+(a.east-a.west)*E,{x:C,z:I}=ji(R,D,i,t),W=c.heights[S*Ue+_],X=S3+E3+(W-u),U=S*Ue+_;d[U*3]=C,d[U*3+1]=X,d[U*3+2]=I,f[U*2]=E,f[U*2+1]=b;const q=Math.max(Math.abs(C),Math.abs(I)),H=1-A3((q-r)/(s-r),0,1);g[U*4]=1,g[U*4+1]=1,g[U*4+2]=1,g[U*4+3]=H}}const x=new Uint16Array(fr*fr*6);let m=0;for(let S=0;S<fr;S++)for(let b=0;b<fr;b++){const R=S*Ue+b,_=R+1,E=R+Ue,D=E+1;x[m++]=R,x[m++]=E,x[m++]=_,x[m++]=_,x[m++]=E,x[m++]=D}const p=new Ee;p.setAttribute("position",new le(d,3)),p.setAttribute("uv",new le(f,2)),p.setAttribute("color",new le(g,4)),p.setIndex(new le(x,1)),p.computeVertexNormals();const w=new oi(l.source);w.flipY=!1;const A=new Ar({map:w,color:new Mt(1,1,1),vertexColors:!0,transparent:!0,fog:!0,depthTest:!1}),M=new se(p,A);return M.receiveShadow=!0,M.castShadow=!0,{mesh:M,attribution:e.imagery.attribution}}function A3(i,t,e){return Math.max(t,Math.min(e,i))}const T3=18,R3=.55,C3=.5,D3=`
|
|
4714
4714
|
attribute float aSpeed;
|
|
4715
4715
|
uniform float uTime;
|
|
4716
4716
|
uniform float uOverallSpeed;
|
|
@@ -4747,9 +4747,9 @@ void main() {
|
|
|
4747
4747
|
// a real, caught bug (a user directly noticed "darker/farther streaks equal-or-bigger than
|
|
4748
4748
|
// lighter/closer ones"), not just a stylistic overcorrection.
|
|
4749
4749
|
vHaze = clamp(dist / uHazeDistance, 0.0, 1.0);
|
|
4750
|
-
gl_PointSize = uPixelSize / dist + vNearBlur * ${
|
|
4750
|
+
gl_PointSize = uPixelSize / dist + vNearBlur * ${T3.toFixed(1)};
|
|
4751
4751
|
}
|
|
4752
|
-
`,
|
|
4752
|
+
`,P3=`
|
|
4753
4753
|
precision mediump float;
|
|
4754
4754
|
uniform sampler2D uTexture;
|
|
4755
4755
|
uniform vec3 uColor;
|
|
@@ -4777,18 +4777,18 @@ void main() {
|
|
|
4777
4777
|
// defocus doesn't change color, only spreads+dims (see vertex shader's own gl_PointSize term) —
|
|
4778
4778
|
// both dim the alpha so a maximally blurred/hazy drop doesn't stay as visually "solid" as a sharp
|
|
4779
4779
|
// one right in the middle distance.
|
|
4780
|
-
vec3 color = mix(uColor, uHazeColor, vHaze * ${
|
|
4780
|
+
vec3 color = mix(uColor, uHazeColor, vHaze * ${R3.toFixed(2)});
|
|
4781
4781
|
float blur = max(vNearBlur, vHaze);
|
|
4782
|
-
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${
|
|
4782
|
+
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * ${C3.toFixed(2)}));
|
|
4783
4783
|
}
|
|
4784
|
-
`;function
|
|
4784
|
+
`;function I3(i){let t=i;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}}let ma;function L3(){if(ma)return ma;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createLinearGradient(0,0,i,0);n.addColorStop(0,"rgba(255,255,255,0)"),n.addColorStop(.42,"rgba(255,255,255,0)"),n.addColorStop(.47,"rgba(255,255,255,0.85)"),n.addColorStop(.5,"rgba(255,255,255,1)"),n.addColorStop(.53,"rgba(255,255,255,0.85)"),n.addColorStop(.58,"rgba(255,255,255,0)"),n.addColorStop(1,"rgba(255,255,255,0)"),e.fillStyle=n,e.fillRect(0,0,i,i);const s=e.createLinearGradient(0,0,0,i);return s.addColorStop(0,"rgba(0,0,0,1)"),s.addColorStop(.1,"rgba(0,0,0,0)"),s.addColorStop(.9,"rgba(0,0,0,0)"),s.addColorStop(1,"rgba(0,0,0,1)"),e.globalCompositeOperation="destination-out",e.fillStyle=s,e.fillRect(0,0,i,i),e.globalCompositeOperation="source-over",ma=new oi(t),ma}function N3(i){const t=I3(i.seed),e=new Float32Array(i.count*3),n=new Float32Array(i.count),s=i.radiusM;for(let l=0;l<i.count;l++){const h=t()*Math.PI*2,u=Math.sqrt(t())*i.radiusM;e[l*3]=Math.cos(h)*u,e[l*3+1]=t()*i.heightM,e[l*3+2]=Math.sin(h)*u,n[l]=.85+t()*.3}const r=new Ee;r.setAttribute("position",new le(e,3)),r.setAttribute("aSpeed",new le(n,1)),r.setDrawRange(0,i.visibleCount);const a={uTime:{value:0},uOverallSpeed:{value:i.overallSpeed},uPixelSize:{value:i.pixelSize},uOpacity:{value:i.opacity},uColor:{value:i.color},uUvSquash:{value:1},uSpeedStreak:{value:i.speedStreak},uWindOffset:{value:new Ft(0,0)},uHeight:{value:i.heightM},uBottomY:{value:i.bottomYM},uHalfWidth:{value:s},uTexture:{value:L3()},uNearFocusDistance:{value:i.nearFocusDistanceM},uHazeDistance:{value:i.hazeDistanceM},uHazeColor:{value:i.hazeColor}},o=new Be({uniforms:a,vertexShader:D3,fragmentShader:P3,transparent:!0,depthWrite:!1,depthTest:!0}),c=new Pa(r,o);return c.frustumCulled=!1,{points:c,uniforms:a}}const U3=`
|
|
4785
4785
|
varying vec3 vDir;
|
|
4786
4786
|
|
|
4787
4787
|
void main() {
|
|
4788
4788
|
vDir = normalize(position);
|
|
4789
4789
|
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
4790
4790
|
}
|
|
4791
|
-
`,
|
|
4791
|
+
`,j0=`vec3 hash3(vec3 p) {
|
|
4792
4792
|
p = vec3(dot(p, vec3(127.1, 311.7, 74.7)), dot(p, vec3(269.5, 183.3, 246.1)), dot(p, vec3(113.5, 271.9, 124.6)));
|
|
4793
4793
|
return fract(sin(p) * 43758.5453) * 2.0 - 1.0;
|
|
4794
4794
|
}
|
|
@@ -4816,7 +4816,7 @@ float fbm(vec3 p) {
|
|
|
4816
4816
|
amp *= 0.55;
|
|
4817
4817
|
}
|
|
4818
4818
|
return sum;
|
|
4819
|
-
}`,
|
|
4819
|
+
}`,F3=`
|
|
4820
4820
|
float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
|
|
4821
4821
|
if (coverage <= 0.0 || dir.y <= 0.02) return 0.0;
|
|
4822
4822
|
vec3 planePos = dir * (layerHeight / max(dir.y, 0.04));
|
|
@@ -4836,7 +4836,7 @@ float cirrusCoverAt(vec3 dir, float layerHeight, float coverage) {
|
|
|
4836
4836
|
// is what makes a halo brighter along one arc than another even under total cover.
|
|
4837
4837
|
return present * (0.30 + 0.70 * smoothstep(0.25, 0.85, shape));
|
|
4838
4838
|
}
|
|
4839
|
-
`,
|
|
4839
|
+
`,O3=`
|
|
4840
4840
|
precision highp float;
|
|
4841
4841
|
uniform vec3 sunDir;
|
|
4842
4842
|
uniform vec3 sunColor;
|
|
@@ -4854,7 +4854,7 @@ varying vec3 vDir;
|
|
|
4854
4854
|
uniform float layerHeight;
|
|
4855
4855
|
uniform float fibrous;
|
|
4856
4856
|
|
|
4857
|
-
${
|
|
4857
|
+
${j0}
|
|
4858
4858
|
|
|
4859
4859
|
// Cellular (Worley) noise — distance to the nearest of 27 randomly-jittered cell points. Unlike
|
|
4860
4860
|
// fbm's smooth interpolated blobs, this has genuinely sharp valleys between cells, reading as
|
|
@@ -4958,20 +4958,23 @@ void main() {
|
|
|
4958
4958
|
|
|
4959
4959
|
gl_FragColor = vec4(color, alpha);
|
|
4960
4960
|
}
|
|
4961
|
-
`;function
|
|
4961
|
+
`;function td(i,t,e,n=0){const s={sunDir:{value:new F(0,1,0)},sunColor:{value:new Mt(1,1,1)},ambientColor:{value:new Mt(.5,.5,.5)},baseColor:{value:i},coverage:{value:t},layerHeight:{value:e},fibrous:{value:n}};return{material:new Be({uniforms:s,vertexShader:U3,fragmentShader:O3,transparent:!0,depthWrite:!1,depthTest:!1,side:Ce}),uniforms:s}}const z3=1.5;function ed(i){const t=Math.PI/2-z3*Math.PI/180;return new Cn(i,48,24,0,Math.PI*2,0,t)}class Ae{static OCTAVES=4;static GAIN=.55;static LACUNARITY=2.03;static fract(t){return t-Math.floor(t)}static hash3(t,e,n){const s=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[Ae.fract(Math.sin(s)*43758.5453)*2-1,Ae.fract(Math.sin(r)*43758.5453)*2-1,Ae.fract(Math.sin(a)*43758.5453)*2-1]}static noise3D(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,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=(x,m,p)=>{const[w,A,M]=Ae.hash3(s+x,r+m,a+p);return w*(o-x)+A*(c-m)+M*(l-p)},g=(x,m,p)=>x+(m-x)*p;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 s=0,r=Ae.GAIN;for(let a=0;a<Ae.OCTAVES;a++)s+=Ae.noise3D(t,e,n)*r,t*=Ae.LACUNARITY,e*=Ae.LACUNARITY,n*=Ae.LACUNARITY,r*=Ae.GAIN;return s}static worley(t,e,n){const s=Math.floor(t),r=Math.floor(e),a=Math.floor(n),o=t-s,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,x,m]=Ae.hash3(s+u,r+d,a+f),p=u+(g*.5+.5)-o,w=d+(x*.5+.5)-c,A=f+(m*.5+.5)-l;h=Math.min(h,p*p+w*w+A*A)}return Math.sqrt(h)}static alphaAt(t,e,n){if(n<=0)return 0;const s=Math.abs(t.y);if(s<.026)return 0;const r=e/Math.max(s,.04),a=t.x*r,o=t.y*r,c=t.z*r,l=a*.006,h=o*.006,u=c*.006,d=a+Ae.fbm(l+12.3,h+12.3,u+12.3)*40,f=o+Ae.fbm(l+47.1,h+47.1,u+47.1)*40,g=c+Ae.fbm(l+91.7,h+91.7,u+91.7)*40,x=Ae.fbm(d*.014,f*.014,g*.014)*.5+.5,m=1-Ae.worley(d*.011,f*.011,g*.011),p=x+(m-x)*.4,w=1-n,A=(S,b,R)=>{const _=Math.min(1,Math.max(0,(R-S)/(b-S)));return _*_*(3-2*_)},M=A(w-.08,w+.08,p);return M+(1-M)*A(.82,1,n)}}const B3=`
|
|
4962
4962
|
varying vec2 vUv;
|
|
4963
4963
|
void main() {
|
|
4964
4964
|
vUv = uv;
|
|
4965
4965
|
gl_Position = vec4(position, 1.0);
|
|
4966
4966
|
}
|
|
4967
|
-
`,
|
|
4967
|
+
`,k3=`
|
|
4968
4968
|
// Based on https://www.shadertoy.com/view/4sX3Rs
|
|
4969
4969
|
uniform float uTime;
|
|
4970
4970
|
uniform vec2 uLensPosition;
|
|
4971
4971
|
uniform vec2 uResolution;
|
|
4972
4972
|
uniform vec3 uColorGain;
|
|
4973
4973
|
uniform float uStarPoints;
|
|
4974
|
-
uniform float
|
|
4974
|
+
uniform float uTanHalfFov;
|
|
4975
|
+
uniform float uSourceRadiusDeg;
|
|
4976
|
+
uniform float uVeilStrength;
|
|
4977
|
+
uniform vec3 uDazzleColour;
|
|
4975
4978
|
uniform float uFlareSize;
|
|
4976
4979
|
uniform float uFlareSpeed;
|
|
4977
4980
|
uniform float uFlareShape;
|
|
@@ -5044,17 +5047,46 @@ vec3 drawflare(vec2 p, float intensity, float rnd, float speed, int id)
|
|
|
5044
5047
|
}
|
|
5045
5048
|
}
|
|
5046
5049
|
|
|
5047
|
-
|
|
5050
|
+
// THE DAZZLE ITSELF, and the one part of this shader that is not a look.
|
|
5051
|
+
//
|
|
5052
|
+
// A bright light does not grow. What grows around it is VEILING GLARE: a fixed small fraction of
|
|
5053
|
+
// its flux scattered sideways on its way through the eye — off the cornea, the lens, the fibres of
|
|
5054
|
+
// the vitreous — or, in a camera, off every air-glass surface in the barrel. Stiles and Crawford
|
|
5055
|
+
// measured it in the 1930s and it has been re-measured ever since, and what they found is an
|
|
5056
|
+
// INVERSE SQUARE in the angle from the source: the veil at two degrees is a quarter of the veil at
|
|
5057
|
+
// one. Nothing else in this file mattered as much as getting that exponent right. What was here
|
|
5058
|
+
// before fell off as 1/θ, whose tail is so much fatter that the Sun read as a white ball six
|
|
5059
|
+
// degrees across in broad daylight — which is what a reader saw and said was too big.
|
|
5060
|
+
//
|
|
5061
|
+
// The angle is a REAL angle between two lines of sight, not a screen distance: the same dazzle has
|
|
5062
|
+
// to be the same number of degrees wide whatever the field of view and whichever projection the
|
|
5063
|
+
// recording was made through, exactly as the halo ring is (see IceHaloEffect). Inside the source's
|
|
5064
|
+
// own disc there is no angle left to divide by, so it is held there.
|
|
5065
|
+
//
|
|
5066
|
+
// uVeilStrength is the square of the angle at which the veil reaches full white — so the radius of
|
|
5067
|
+
// the blazing core is sqrt(strength), and it shrinks as the SQUARE ROOT of the Sun's brightness.
|
|
5068
|
+
// A hundredfold weaker Sun makes a tenfold smaller blaze, which is the whole shape of a sunset.
|
|
5069
|
+
// Which way the eye is looking at this point of the frame. The frame this shader draws into is
|
|
5070
|
+
// always the RECTILINEAR one the camera renders (an equidistant recording resamples it afterwards,
|
|
5071
|
+
// which is why reading an angle off pixel distances here was wrong by half again at the edges) — so
|
|
5072
|
+
// a point of it is a direction through a pinhole, and the angle between two of them is exact under
|
|
5073
|
+
// both projections.
|
|
5074
|
+
vec3 lookAt(vec2 p)
|
|
5048
5075
|
{
|
|
5049
|
-
|
|
5076
|
+
float aspect = uResolution.x / max(uResolution.y, 1.0);
|
|
5077
|
+
return normalize(vec3(2.0 * p.x * uTanHalfFov * aspect, 2.0 * p.y * aspect * uTanHalfFov, -1.0));
|
|
5078
|
+
}
|
|
5050
5079
|
|
|
5080
|
+
float glare(vec2 uv, vec2 pos)
|
|
5081
|
+
{
|
|
5082
|
+
vec2 main = uAnimated ? rotateUV(uv-pos, uTime * 0.1) : uv-pos;
|
|
5051
5083
|
float ang = atan(main.y, main.x) * (uAnamorphic ? 1.0 : uStarPoints);
|
|
5052
|
-
float
|
|
5053
|
-
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
return
|
|
5084
|
+
float theta = max(degrees(acos(clamp(dot(lookAt(uv), lookAt(pos)), -1.0, 1.0))), uSourceRadiusDeg);
|
|
5085
|
+
float veil = uVeilStrength / (theta * theta);
|
|
5086
|
+
// The aperture's spikes ride on the veil rather than being drawn on top of it — they ARE the
|
|
5087
|
+
// same scattered light, gathered along the directions the blade edges diffract it into. With no
|
|
5088
|
+
// blades uStarPoints is zero, the angle collapses and this is exactly 1: a round dazzle.
|
|
5089
|
+
return veil * (1.0 + 0.45 * sin(ang));
|
|
5058
5090
|
}
|
|
5059
5091
|
|
|
5060
5092
|
//https://www.shadertoy.com/view/Xd2GR3
|
|
@@ -5127,13 +5159,18 @@ void LensFlare(vec2 uv, vec2 pos, out vec3 glareOut, out vec3 flareOut)
|
|
|
5127
5159
|
prot = uv - pos;
|
|
5128
5160
|
}
|
|
5129
5161
|
|
|
5130
|
-
vec3 core = vec3(glare(uv,pos
|
|
5162
|
+
vec3 core = vec3(glare(uv,pos));
|
|
5131
5163
|
vec3 rays = drawflare(prot, (uAnamorphic ? uFlareSize * 10. : uFlareSize), 0.1, uTime, 1);
|
|
5132
5164
|
vec3 ghosts;
|
|
5133
5165
|
ghosts.r = f1+f2+f4+f5+f6; ghosts.g = f1+f22+f42+f52+f62; ghosts.b = f1+f23+f43+f53+f63;
|
|
5134
5166
|
|
|
5135
5167
|
vec3 vignette = vec3(length(uvd)+.09) * 1.3;
|
|
5136
|
-
|
|
5168
|
+
// NOT on the dazzle. The reference's vignette darkens toward the middle of the frame, which is
|
|
5169
|
+
// a look and a defensible one for lens artifacts — but veiling glare is a property of the angle
|
|
5170
|
+
// between the eye and the source, not of where the source happens to be framed. Left on it, the
|
|
5171
|
+
// same Sun threw a dazzle eight times weaker in the centre of the picture than at its edge, and
|
|
5172
|
+
// no calibration in real degrees could survive that.
|
|
5173
|
+
glareOut = core + vec3(f0);
|
|
5137
5174
|
flareOut = (rays + ghosts) * vignette;
|
|
5138
5175
|
}
|
|
5139
5176
|
|
|
@@ -5298,7 +5335,11 @@ void main()
|
|
|
5298
5335
|
const float DAZZLE_COMPENSATION = 0.6;
|
|
5299
5336
|
vec3 glareColor, flareColor;
|
|
5300
5337
|
LensFlare(myUV, mouse, glareColor, flareColor);
|
|
5301
|
-
|
|
5338
|
+
// Straight through, in fractions of white: glare() already answers "how much of full white is
|
|
5339
|
+
// veiling this pixel", so multiplying it by anything but the source's own colour would be
|
|
5340
|
+
// undoing the calibration. The artifacts keep the reference implementation's own gain chain
|
|
5341
|
+
// below, because they are a look and were tuned as one.
|
|
5342
|
+
vec3 dazzle = glareColor * uDazzleColour;
|
|
5302
5343
|
vec3 artifacts = flareColor * 20.0 * uColorGain / 256.;
|
|
5303
5344
|
|
|
5304
5345
|
if(uAdditionalStreaks){
|
|
@@ -5345,13 +5386,15 @@ void main()
|
|
|
5345
5386
|
// grey smudge instead of the vivid, distinct artifact it's meant to be (dazzle-alone was
|
|
5346
5387
|
// originally chosen to stop artifacts from ever *adding* opacity on top of an already-opaque
|
|
5347
5388
|
// core — max() still does that, since near the core dazzleAlpha already dominates).
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5389
|
+
// Everything this draw contributes is carried by the COLOUR, and the alpha is left at one.
|
|
5390
|
+
// Additive blending multiplies colour by alpha, so an alpha computed from the colour squared
|
|
5391
|
+
// the dazzle — turning an inverse-square falloff into an inverse-fourth one out in the wings,
|
|
5392
|
+
// where a real dazzle still has most of its reach. The reader's own intensity dial reaches the
|
|
5393
|
+
// dazzle through uVeilStrength instead (see SceneRenderer.applyDazzleStrength), and uOpacity
|
|
5394
|
+
// stays what it always was for the optional artifacts.
|
|
5395
|
+
gl_FragColor = vec4(dazzle + artifactsContribution * uOpacity, 1.0);
|
|
5396
|
+
}
|
|
5397
|
+
`;let ga;function G3(){if(ga)return ga;const i=256,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d");e.fillStyle="rgba(60,60,60,1)",e.fillRect(0,0,i,i);const n=[[.3,.35,.22,.5],[.7,.6,.16,.35],[.55,.8,.3,.4],[.15,.7,.12,.3],[.85,.2,.18,.3]];for(const[s,r,a,o]of n){const c=e.createRadialGradient(s*i,r*i,0,s*i,r*i,a*i);c.addColorStop(0,`rgba(200,200,200,${o})`),c.addColorStop(1,"rgba(200,200,200,0)"),e.fillStyle=c,e.fillRect(0,0,i,i)}return ga=new oi(t),ga}function H3(){const i={uTime:{value:0},uResolution:{value:new Ft(1,1)},uLensPosition:{value:new Ft(0,0)},uColorGain:{value:new Mt(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 Mt(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:G3()}},t=new Be({uniforms:i,vertexShader:B3,fragmentShader:k3,transparent:!0,depthWrite:!1,depthTest:!1,blending:Ri,fog:!1,name:"LensFlareShader"}),e=new se(new qs(2,2),t);return e.frustumCulled=!1,e.renderOrder=20,{mesh:e,uniforms:i}}class Ka{static MAX_HALF_ANGLE_DEG=80;target;quadScene=new o0;quadCamera=new io(-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 Rn(this.width,this.height,{type:xn}),this.material=new Be({uniforms:{uSource:{value:this.target.texture},uHalfFovRad:{value:.5236},uAspect:{value:this.width/this.height},uSrcTanHalfFovY:{value:1},uResolution:{value:new Ft(this.width,this.height)}},vertexShader:`
|
|
5355
5398
|
varying vec2 vNdc;
|
|
5356
5399
|
void main() {
|
|
5357
5400
|
vNdc = position.xy;
|
|
@@ -5385,7 +5428,7 @@ void main()
|
|
|
5385
5428
|
if (any(greaterThan(abs(src), vec2(1.0)))) { gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0); return; }
|
|
5386
5429
|
gl_FragColor = texture2D(uSource, src * 0.5 + 0.5);
|
|
5387
5430
|
}
|
|
5388
|
-
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new rt(new Fs(2,2),this.material))}directionFor(e,t,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=e*s*r,o=t*r,l=Math.hypot(a,o);if(l<1e-6)return{x:0,y:0,z:-1};const c=Math.sin(l);return{x:a/l*c,y:o/l*c,z:-Math.cos(l)}}static cornerHalfAngleDeg(e,t){return e/2*Math.hypot(t,1)}static supports(e,t){return this.cornerHalfAngleDeg(e,t)<=this.MAX_HALF_ANGLE_DEG}resize(e,t){this.width=Math.max(1,e),this.height=Math.max(1,t),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(e,t,n,s,r){const a=this.width/this.height;this.material.uniforms.uHalfFovRad.value=s/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(s,a);const o=n.fov;n.fov=this.sourceFovDeg(s,a),n.updateProjectionMatrix(),r?.();const l=e.getRenderTarget();e.setRenderTarget(this.target),e.render(t,n),e.setRenderTarget(l),n.fov=o,n.updateProjectionMatrix(),e.render(this.quadScene,this.quadCamera)}sourceFovDeg(e,t){return Math.atan(this.sourceTanHalfFovY(e,t))*360/Math.PI}sourceTanHalfFovY(e,t){const n=Fa.cornerHalfAngleDeg(e,t)*Math.PI/180;return Math.tan(n)/Math.hypot(t,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class Xe{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const e=Xe.ICE_INDEX_RED,t=Math.sqrt((4-e*e)/3);return Math.asin(Math.min(1,t))*180/Math.PI}static minimumDeviationDeg(e,t){const n=e*Math.PI/180,s=t*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(e,t){const n=t*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(e*e-Math.sin(n)**2)/s}static parheliaDistanceDeg(e,t=Xe.ICE_INDEX_RED){const n=Xe.minimumDeviationDeg(Xe.SIDE_PRISM_ANGLE_DEG,Xe.effectiveIndex(t,e));return Number.isFinite(n)?n:void 0}static halo22(){return{id:"halo22",angleDeg:Xe.minimumDeviationDeg(Xe.SIDE_PRISM_ANGLE_DEG,Xe.ICE_INDEX_RED),redAngleDeg:Xe.minimumDeviationDeg(Xe.SIDE_PRISM_ANGLE_DEG,Xe.ICE_INDEX_RED),blueAngleDeg:Xe.minimumDeviationDeg(Xe.SIDE_PRISM_ANGLE_DEG,Xe.ICE_INDEX_BLUE)}}static halo46(){return{id:"halo46",angleDeg:Xe.minimumDeviationDeg(Xe.END_PRISM_ANGLE_DEG,Xe.ICE_INDEX_RED),redAngleDeg:Xe.minimumDeviationDeg(Xe.END_PRISM_ANGLE_DEG,Xe.ICE_INDEX_RED),blueAngleDeg:Xe.minimumDeviationDeg(Xe.END_PRISM_ANGLE_DEG,Xe.ICE_INDEX_BLUE)}}static strength(e,t){const n=Math.max(0,Math.min(1,e)),s=Math.max(0,1-Math.max(0,Math.min(1,t)));return n*s}static formsAt(e){if(e<=0)return[];const t=[Xe.halo22(),Xe.halo46()],n=Xe.parheliaDistanceDeg(e);return n!==void 0&&t.push({id:"parhelia",angleDeg:n,redAngleDeg:n,blueAngleDeg:Xe.parheliaDistanceDeg(e,Xe.ICE_INDEX_BLUE)}),e<Xe.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&t.push({id:"pillar"}),t}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class jt{constructor(e){this.radius=e;const t=jt.SEGMENTS*jt.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const n=new yt;n.setAttribute("position",new ct(this.positions,3)),n.setAttribute("color",new ct(this.colors,3)),n.setDrawRange(0,0),this.object=new rt(n,new Hi({vertexColors:!0,transparent:!0,blending:Bi,depthWrite:!1,fog:!1,side:vn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=jt.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(jt.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(e,t,n){this.head=e&&cn(e.altitudeDeg,e.azimuthDeg,1),this.tip=t&&cn(t.altitudeDeg,t.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const e=this.object.geometry,t=this.head,n=this.tip;if(!t||!n||this.brightness<=0){e.setDrawRange(0,0);return}const s=this.angleBetween(t,n);if(s<=0){e.setDrawRange(0,0);return}const r=s*jt.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(t,n,h),this.radius),o=h=>this.radius*(jt.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),l=h=>this.brightness*(1-h)**jt.FADE_POWER;let c=0;for(let h=1;h<jt.POINTS;h++){const u=(h-1)/jt.SEGMENTS,d=h/jt.SEGMENTS;c=this.pushBand(c,a(u),a(d),o(u),o(d),l(u),l(d))}e.setDrawRange(0,c),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}pushBand(e,t,n,s,r,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<jt.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),p=this.across(n,l,r,h),g=this.across(t,l,s,u),x=this.across(n,l,r,u),m=(f,w)=>f===0?w:0;e=this.push(e,d,m(h,a)),e=this.push(e,p,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,p,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.55,this.colors[s+1]=r*.75,this.colors[s+2]=r,e+1}slerp(e,t,n){const s=this.angleBetweenRadians(e,t);if(s<1e-9)return e;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:e.x*a+t.x*o,y:e.y*a+t.y*o,z:e.z*a+t.z*o}}angleBetween(e,t){return this.angleBetweenRadians(e,t)*180/Math.PI}angleBetweenRadians(e,t){const n=e.x*t.x+e.y*t.y+e.z*t.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class $c{static RADIUS=880;object;material;constructor(){this.material=new Ft({uniforms:{uSource:{value:new U(0,1,0)},uUp:{value:new U(0,1,0)},uStrength:{value:0},uHaloInner:{value:0},uHaloOuter:{value:0},uParhelion:{value:0},uPillar:{value:0},uTint:{value:new U(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1}},vertexShader:`
|
|
5431
|
+
`,depthTest:!1,depthWrite:!1}),this.quadScene.add(new se(new qs(2,2),this.material))}directionFor(t,e,n){const s=this.width/this.height,r=n/2*Math.PI/180,a=t*s*r,o=e*r,c=Math.hypot(a,o);if(c<1e-6)return{x:0,y:0,z:-1};const l=Math.sin(c);return{x:a/c*l,y:o/c*l,z:-Math.cos(c)}}static cornerHalfAngleDeg(t,e){return t/2*Math.hypot(e,1)}static supports(t,e){return this.cornerHalfAngleDeg(t,e)<=this.MAX_HALF_ANGLE_DEG}resize(t,e){this.width=Math.max(1,t),this.height=Math.max(1,e),this.target.setSize(this.width,this.height),this.material.uniforms.uResolution.value.set(this.width,this.height),this.material.uniforms.uAspect.value=this.width/this.height}render(t,e,n,s,r){const a=this.width/this.height;this.material.uniforms.uHalfFovRad.value=s/2*Math.PI/180,this.material.uniforms.uSrcTanHalfFovY.value=this.sourceTanHalfFovY(s,a);const o=n.fov;n.fov=this.sourceFovDeg(s,a),n.updateProjectionMatrix(),r?.();const c=t.getRenderTarget();t.setRenderTarget(this.target),t.render(e,n),t.setRenderTarget(c),n.fov=o,n.updateProjectionMatrix(),t.render(this.quadScene,this.quadCamera)}sourceFovDeg(t,e){return Math.atan(this.sourceTanHalfFovY(t,e))*360/Math.PI}sourceTanHalfFovY(t,e){const n=Ka.cornerHalfAngleDeg(t,e)*Math.PI/180;return Math.tan(n)/Math.hypot(e,1)}dispose(){this.target.dispose(),this.material.dispose(),this.quadScene.clear()}}class $t{static ICE_INDEX_RED=1.3067;static ICE_INDEX_BLUE=1.317;static SIDE_PRISM_ANGLE_DEG=60;static END_PRISM_ANGLE_DEG=90;static get PARHELIA_MAX_SUN_ALTITUDE_DEG(){const t=$t.ICE_INDEX_RED,e=Math.sqrt((4-t*t)/3);return Math.asin(Math.min(1,e))*180/Math.PI}static minimumDeviationDeg(t,e){const n=t*Math.PI/180,s=e*Math.sin(n/2);return s>1?Number.NaN:(2*Math.asin(s)-n)*180/Math.PI}static effectiveIndex(t,e){const n=e*Math.PI/180,s=Math.cos(n);return s<=0?Number.POSITIVE_INFINITY:Math.sqrt(t*t-Math.sin(n)**2)/s}static parheliaAzimuthDeg(t,e=$t.ICE_INDEX_RED){const n=$t.minimumDeviationDeg($t.SIDE_PRISM_ANGLE_DEG,$t.effectiveIndex(e,t));return Number.isFinite(n)?n:void 0}static parheliaDistanceDeg(t,e=$t.ICE_INDEX_RED){const n=$t.parheliaAzimuthDeg(t,e);if(n===void 0)return;const s=t*Math.PI/180,r=Math.sin(s)**2,a=Math.cos(s)**2*Math.cos(n*Math.PI/180);return Math.acos(Math.max(-1,Math.min(1,r+a)))*180/Math.PI}static get PLATE_END_FACE_LIMIT_DEG(){const t=$t.ICE_INDEX_RED;return Math.asin(Math.min(1,Math.sqrt(t*t-1)))*180/Math.PI}static circumzenithalAltitudeDeg(t,e=$t.ICE_INDEX_RED){if(t<0||t>90-$t.PLATE_END_FACE_LIMIT_DEG)return;const n=Math.cos(t*Math.PI/180),s=Math.sqrt(e*e-n*n);if(!(s>=1))return Math.asin(s)*180/Math.PI}static DECK_HEIGHT_M=8e3;static deckLitUntilDeg(t){return Math.acos(6371e3/(6371e3+Math.max(0,t)))*180/Math.PI}static halo22(){return $t.ringOf("halo22",$t.SIDE_PRISM_ANGLE_DEG)}static halo46(){return $t.ringOf("halo46",$t.END_PRISM_ANGLE_DEG)}static ringOf(t,e){const n=$t.minimumDeviationDeg(e,$t.ICE_INDEX_RED),s=$t.minimumDeviationDeg(e,$t.ICE_INDEX_BLUE);return{id:t,angleDeg:(n+s)/2,redAngleDeg:n,blueAngleDeg:s}}static strength(t,e,n=90,s=0){const r=Math.max(0,Math.min(1,t)),a=Math.max(0,1-Math.max(0,Math.min(1,e))),o=n>=0?1:s<=0?0:Math.max(0,1+n/s);return r*a*o}static formsAt(t,e=0){if(t<=-e)return[];const n=[$t.halo22(),$t.halo46()],s=t>0?$t.parheliaDistanceDeg(t):void 0;s!==void 0&&n.push({id:"parhelia",angleDeg:s,redAngleDeg:s,blueAngleDeg:$t.parheliaDistanceDeg(t,$t.ICE_INDEX_BLUE)}),n.push({id:"tangentArc",angleDeg:$t.halo22().angleDeg}),t>0&&n.push({id:"parhelicCircle",angleDeg:t});const r=$t.circumzenithalAltitudeDeg(t);return r!==void 0&&n.push({id:"circumzenithal",angleDeg:r}),t>$t.PLATE_END_FACE_LIMIT_DEG&&n.push({id:"circumhorizontal"}),t<$t.PILLAR_MAX_SOURCE_ALTITUDE_DEG&&n.push({id:"pillar"}),n}static PILLAR_MAX_SOURCE_ALTITUDE_DEG=20}class Za{static reflectance(t,e,n){const r=e/n*Math.sqrt(Math.max(0,1-t*t));if(r>=1)return 1;const a=Math.sqrt(Math.max(0,1-r*r)),o=(n*t-e*a)/(n*t+e*a),c=(e*t-n*a)/(e*t+n*a);return(o*o+c*c)/2}}class Oe{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3312;static ANCHOR_BLUE=1.3404;static B=(Oe.ANCHOR_BLUE-Oe.ANCHOR_RED)/(1/(Oe.BLUE_NM*Oe.BLUE_NM)-1/(Oe.RED_NM*Oe.RED_NM));static A=Oe.ANCHOR_RED-Oe.B/(Oe.RED_NM*Oe.RED_NM);static indexAt(t){return Oe.A+Oe.B/(t*t)}}class Bs{static MAX_CHORDS=4;index=1.333;set refractiveIndex(t){this.index=t}trace(t,e){const n=Math.min(1,Math.max(0,t)),s=Math.sqrt(Math.max(0,1-n*n)),r=n/this.index,a=Math.sqrt(Math.max(0,1-r*r)),o=Math.asin(n),c=Math.asin(r),l=Za.reflectance(s,1,this.index);let h=0;e[h].chords=0,e[h].scatteringAngle=Bs.folded(Math.PI-2*o),e[h].weight=l,h++;const u=Za.reflectance(a,this.index,1);let d=1-l;for(let f=1;f<=Bs.MAX_CHORDS&&h<e.length;f++){const g=2*(o-c)+(f-1)*(Math.PI-2*c);e[h].chords=f,e[h].scatteringAngle=Bs.folded(g),e[h].weight=d*(1-u),h++,d*=u}return h}static folded(t){const e=2*Math.PI;let n=t%e;return n<0&&(n+=e),n>Math.PI?e-n:n}}class je{static get WATER_INDEX_RED(){return Oe.indexAt(Oe.RED_NM)}static get WATER_INDEX_BLUE(){return Oe.indexAt(Oe.BLUE_NM)}static radiusDeg(t,e){const n=(e*e-1)/(t*t-1);if(n<0||n>1)return Number.NaN;const s=Math.acos(Math.sqrt(n)),r=Math.asin(Math.sin(s)/e),a=2*(s-r)+(t-1)*(Math.PI-2*r),o=2*Math.PI;let c=a%o;return c<0&&(c+=o),c>Math.PI&&(c=o-c),180-c*180/Math.PI}static primary(){return je.bowOf("primary",2,0)}static secondary(){return je.bowOf("secondary",3,0)}static bowOf(t,e,n){const s=je.radiusDeg(e,je.WATER_INDEX_RED),r=je.radiusDeg(e,je.WATER_INDEX_BLUE),a=(s+r)/2;return{id:t,radiusDeg:a,redRadiusDeg:s,violetRadiusDeg:r,topAltitudeDeg:a-n}}static alexandersBandDeg(){return{fromDeg:je.primary().redRadiusDeg,toDeg:je.secondary().redRadiusDeg}}static formsAt(t){return t<0?[]:[je.bowOf("primary",2,t),je.bowOf("secondary",3,t)].filter(e=>e.topAltitudeDeg>0)}static FULL_MOON_MAGNITUDE=-12.7;static moonlightShare(t){return Math.min(1,10**(-.4*(t-je.FULL_MOON_MAGNITUDE)))}static strength(t,e,n){if(n<=0)return 0;const s=Math.max(0,Math.min(1,t)),r=Math.max(0,1-Math.max(0,Math.min(1,e)));return s*r}}class rn{constructor(t){this.radius=t;const e=rn.SEGMENTS*rn.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const n=new Ee;n.setAttribute("position",new le(this.positions,3)),n.setAttribute("color",new le(this.colors,3)),n.setDrawRange(0,0),this.object=new se(n,new Ji({vertexColors:!0,transparent:!0,blending:Ri,depthWrite:!1,fog:!1,side:wn})),this.object.frustumCulled=!1}static POINTS=24;static SEGMENTS=rn.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(rn.ACROSS-1)*6;static HEAD_HALF_WIDTH_DEG=.15;static SPREAD_FRACTION=.05;static FADE_POWER=1.8;object;positions;colors;head;tip;brightness=0;set(t,e,n){this.head=t&&an(t.altitudeDeg,t.azimuthDeg,1),this.tip=e&&an(e.altitudeDeg,e.azimuthDeg,1),this.brightness=n,this.rebuild()}rebuild(){const t=this.object.geometry,e=this.head,n=this.tip;if(!e||!n||this.brightness<=0){t.setDrawRange(0,0);return}const s=this.angleBetween(e,n);if(s<=0){t.setDrawRange(0,0);return}const r=s*rn.SPREAD_FRACTION*Math.PI/180,a=h=>this.scale(this.slerp(e,n,h),this.radius),o=h=>this.radius*(rn.HEAD_HALF_WIDTH_DEG*Math.PI/180+r*h),c=h=>this.brightness*(1-h)**rn.FADE_POWER;let l=0;for(let h=1;h<rn.POINTS;h++){const u=(h-1)/rn.SEGMENTS,d=h/rn.SEGMENTS;l=this.pushBand(l,a(u),a(d),o(u),o(d),c(u),c(d))}t.setDrawRange(0,l),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}pushBand(t,e,n,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<rn.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),f=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(p,w)=>p===0?w:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.55,this.colors[s+1]=r*.75,this.colors[s+2]=r,t+1}slerp(t,e,n){const s=this.angleBetweenRadians(t,e);if(s<1e-9)return t;const r=Math.sin(s),a=Math.sin((1-n)*s)/r,o=Math.sin(n*s)/r;return{x:t.x*a+e.x*o,y:t.y*a+e.y*o,z:t.z*a+e.z*o}}angleBetween(t,e){return this.angleBetweenRadians(t,e)*180/Math.PI}angleBetweenRadians(t,e){const n=t.x*e.x+t.y*e.y+t.z*e.z;return Math.acos(Math.min(1,Math.max(-1,n)))}scale(t,e){return{x:t.x*e,y:t.y*e,z:t.z*e}}subtract(t,e){return{x:t.x-e.x,y:t.y-e.y,z:t.z-e.z}}cross(t,e){return{x:t.y*e.z-t.z*e.y,y:t.z*e.x-t.x*e.z,z:t.x*e.y-t.y*e.x}}normalise(t){const e=Math.hypot(t.x,t.y,t.z)||1;return{x:t.x/e,y:t.y/e,z:t.z/e}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}class Qe{static RED_NM=656.3;static BLUE_NM=435.8;static ANCHOR_RED=1.3067;static ANCHOR_BLUE=1.317;static B=(Qe.ANCHOR_BLUE-Qe.ANCHOR_RED)/(1/(Qe.BLUE_NM*Qe.BLUE_NM)-1/(Qe.RED_NM*Qe.RED_NM));static A=Qe.ANCHOR_RED-Qe.B/(Qe.RED_NM*Qe.RED_NM);static indexAt(t){return Qe.A+Qe.B/(t*t)}}class br{normals=new Float64Array(24);offsets=new Float64Array(8);radius=1;set(t,e,n,s,r,a){let o=0,c=0,l=0;Math.abs(n)<.9?(o=-e,c=t,l=0):(o=0,c=-n,l=e);const h=Math.hypot(o,c,l)||1;o/=h,c/=h,l/=h;const u=e*l-n*c,d=n*o-t*l,f=t*c-e*o,g=r/2,x=a/2;for(let m=0;m<6;m++){const p=s+m*Math.PI/3,w=Math.cos(p),A=Math.sin(p);this.normals[m*3]=o*w+u*A,this.normals[m*3+1]=c*w+d*A,this.normals[m*3+2]=l*w+f*A,this.offsets[m]=g}this.normals[18]=t,this.normals[19]=e,this.normals[20]=n,this.offsets[6]=x,this.normals[21]=-t,this.normals[22]=-e,this.normals[23]=-n,this.offsets[7]=x,this.radius=Math.hypot(g,x)}get aimRadius(){return this.radius}trace(t,e,n,s,r,a,o){let c=-e,l=t,h=0,u=Math.hypot(c,l,h);u<1e-6&&(c=1,l=0,h=0,u=1),c/=u,l/=u,h/=u;const d=e*h-n*l,f=n*c-t*h,g=t*l-e*c,x=c*s+d*r-t*this.radius*2,m=l*s+f*r-e*this.radius*2,p=h*s+g*r-n*this.radius*2;let w=-1,A=-1/0,M=1/0;for(let j=0;j<8;j++){const it=this.normals[j*3],ut=this.normals[j*3+1],kt=this.normals[j*3+2],qt=it*t+ut*e+kt*n,Bt=this.offsets[j]-(it*x+ut*m+kt*p);if(qt>1e-9){const Y=Bt/qt;Y<M&&(M=Y)}else if(qt<-1e-9){const Y=Bt/qt;Y>A&&(A=Y,w=j)}else if(Bt<0)return 0}if(w<0||A>=M)return 0;let S=0;const b=this.normals[w*3],R=this.normals[w*3+1],_=this.normals[w*3+2],E=-(b*t+R*e+_*n),D=Za.reflectance(E,1,a);o[S].x=t+2*E*b,o[S].y=e+2*E*R,o[S].z=n+2*E*_,o[S].weight=D,S++;const C=1/a,I=Math.sqrt(Math.max(0,1-C*C*(1-E*E)));let W=C*t+(C*E-I)*b,X=C*e+(C*E-I)*R,U=C*n+(C*E-I)*_,q=x+t*A,H=m+e*A,$=p+n*A,et=1-D;for(let j=0;j<br.MAX_BOUNCES&&et>br.MIN_WEIGHT;j++){let it=-1,ut=1/0;for(let z=0;z<8;z++){const bt=this.normals[z*3],Dt=this.normals[z*3+1],At=this.normals[z*3+2],_t=bt*W+Dt*X+At*U;if(_t<=1e-9)continue;const It=(this.offsets[z]-(bt*q+Dt*H+At*$))/_t;It>1e-9&&It<ut&&(ut=It,it=z)}if(it<0)break;const kt=this.normals[it*3],qt=this.normals[it*3+1],Bt=this.normals[it*3+2],Y=kt*W+qt*X+Bt*U,rt=a*Math.sqrt(Math.max(0,1-Y*Y));if(q+=W*ut,H+=X*ut,$+=U*ut,rt<1){const z=Math.sqrt(Math.max(0,1-rt*rt)),bt=Za.reflectance(Y,a,1);if(o[S].x=a*W-(a*Y-z)*kt,o[S].y=a*X-(a*Y-z)*qt,o[S].z=a*U-(a*Y-z)*Bt,o[S].weight=et*(1-bt),S++,S>=o.length)return S;et*=bt}const nt=2*Y;W-=nt*kt,X-=nt*qt,U-=nt*Bt}return S}static MAX_BOUNCES=6;static MIN_WEIGHT=1e-4}class An{static VIOLET_NM=400;static DEEP_RED_NM=700;static SAMPLES=An.build(24);static build(t){const e=[];let n=0,s=0,r=0;for(let a=0;a<t;a++){const o=An.VIOLET_NM+(a+.5)/t*(An.DEEP_RED_NM-An.VIOLET_NM),[c,l,h]=An.colourMatching(o),u={wavelengthNm:o,r:Math.max(0,3.2406*c-1.5372*l-.4986*h),g:Math.max(0,-.9689*c+1.8758*l+.0415*h),b:Math.max(0,.0557*c-.204*l+1.057*h)};n+=u.r,s+=u.g,r+=u.b,e.push(u)}for(const a of e)a.r/=n,a.g/=s,a.b/=r;return e}static colourMatching(t){const e=(n,s,r)=>{const a=(t-n)/(t<n?s:r);return Math.exp(-.5*a*a)};return[1.056*e(599.8,37.9,31)+.362*e(442,16,26.7)-.065*e(501.1,20.4,26.2),.821*e(568.8,46.9,40.5)+.286*e(530.9,16.3,31.1),1.217*e(437,11.8,36)+.681*e(459,26,13.8)]}}class fe{static AZIMUTH_BINS=512;static ALTITUDE_BINS=512;static POPULATIONS=[{orientation:"tumbling",widthMicrons:50,lengthMicrons:50,share:.52},{orientation:"plate",widthMicrons:100,lengthMicrons:15,share:.27},{orientation:"column",widthMicrons:40,lengthMicrons:120,share:.19},{orientation:"parry",widthMicrons:40,lengthMicrons:120,share:.02}];static WORST_TILT_DEG=180;static BEST_TILT_DEG=.5;static SOURCE_RADIUS_DEG=.265;static UNDEVIATED_DEG=.6;crystal=new br;emergent=Array.from({length:br.MAX_BOUNCES+2},()=>({x:0,y:0,z:0,weight:0}));tally=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);radiance=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);scratch=new Float32Array(fe.AZIMUTH_BINS*fe.ALTITUDE_BINS*3);seed=1;spare=0;hasSpare=!1;altitude=0;tilt=0;alignment=0;traced=0;begin(t,e,n=2654435769){this.seed=n>>>0||1,this.hasSpare=!1,this.tally.fill(0),this.traced=0,this.altitude=t*Math.PI/180,this.alignment=Math.min(1,Math.max(0,e));const s=fe.WORST_TILT_DEG*(fe.BEST_TILT_DEG/fe.WORST_TILT_DEG)**this.alignment;this.tilt=s*Math.PI/180}trace(t){const e=fe.AZIMUTH_BINS,n=fe.ALTITUDE_BINS,s=this.tally,r=fe.SOURCE_RADIUS_DEG*Math.PI/180,a=Math.cos(fe.UNDEVIATED_DEG*Math.PI/180),o=this.altitude;for(let c=0;c<t;c++){const l=this.pickPopulation();this.orient(l,this.tilt);const h=this.random()*2*Math.PI,u=r*Math.sqrt(this.random()),d=o+u*Math.sin(h),f=u*Math.cos(h)/Math.max(.05,Math.cos(o)),g=-Math.cos(d)*Math.cos(f),x=-Math.cos(d)*Math.sin(f),m=-Math.sin(d),p=this.crystal.aimRadius,w=(this.random()*2-1)*p,A=(this.random()*2-1)*p,M=4*p*p,S=An.SAMPLES[this.random()*An.SAMPLES.length|0],b=this.crystal.trace(g,x,m,w,A,Qe.indexAt(S.wavelengthNm),this.emergent);for(let R=0;R<b;R++){const _=this.emergent[R],E=Math.hypot(_.x,_.y,_.z);if(E<1e-9||_.weight<=0)continue;const D=_.x/E,C=_.y/E,I=_.z/E;if(D*g+C*x+I*m>a)continue;const W=Math.asin(Math.max(-1,Math.min(1,-I))),X=Math.abs(Math.atan2(-C,-D)),U=Math.min(e-1,X/Math.PI*e|0),H=(Math.min(n-1,(W+Math.PI/2)/Math.PI*n|0)*e+U)*3,$=_.weight*M*An.SAMPLES.length;s[H]+=$*S.r,s[H+1]+=$*S.g,s[H+2]+=$*S.b}}this.traced+=t}get tracedRays(){return this.traced}harvest(){const t=fe.AZIMUTH_BINS,e=fe.ALTITUDE_BINS;return this.toRadiance(t,e),this.smooth(t,e),{width:t,height:e,data:this.radiance,sourceAltitudeDeg:this.altitude*180/Math.PI,alignment:this.alignment,rays:this.traced}}compute(t,e,n,s){return this.begin(t,e,s),this.trace(n),this.harvest()}toRadiance(t,e){const n=2*Math.PI/t,s=Math.max(1,this.traced),r=4*fe.REFERENCE_MICRONS*fe.REFERENCE_MICRONS;for(let a=0;a<e;a++){const o=Math.sin(a/e*Math.PI-Math.PI/2),c=Math.sin((a+1)/e*Math.PI-Math.PI/2),l=1/(n*(c-o)*s*r);for(let h=0;h<t;h++){const u=(a*t+h)*3;this.radiance[u]=this.tally[u]*l,this.radiance[u+1]=this.tally[u+1]*l,this.radiance[u+2]=this.tally[u+2]*l}}}static REFERENCE_MICRONS=50;smooth(t,e){const n=this.scratch,s=this.radiance;n.set(s);for(let a=0;a<e;a++){const o=a*t*3;for(let c=0;c<3;c++){let l=n[o+c];for(let h=0;h<t;h++){const u=o+h*3+c,d=h+1<t?n[u+3]:n[u];s[u]=(l+2*n[u]+d)/4,l=n[u]}}}n.set(s);const r=t*3;for(let a=0;a<e;a++){const o=a>0?-r:0,c=a+1<e?r:0,l=a*r;for(let h=l;h<l+r;h++)s[h]=(n[h+o]+2*n[h]+n[h+c])/4}}pickPopulation(){const t=this.random();let e=0;for(const n of fe.POPULATIONS)if(e+=n.share,t<=e)return n;return fe.POPULATIONS[fe.POPULATIONS.length-1]}orient(t,e){const n=this.random()*2*Math.PI;let s=this.random()*2*Math.PI,r=0,a=0,o=1;switch(t.orientation){case"tumbling":{o=this.random()*2-1;const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"plate":{o=this.spreadAboutAnAxis(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n);break}case"column":case"parry":{o=this.spreadAboutAPlane(e);const c=Math.sqrt(Math.max(0,1-o*o));r=c*Math.cos(n),a=c*Math.sin(n),t.orientation==="parry"&&(s=Math.PI/2+this.gaussian()*e);break}}this.crystal.set(r,a,o,s,t.widthMicrons,t.lengthMicrons)}random(){this.seed=this.seed+1831565813>>>0;let t=this.seed;return t=Math.imul(t^t>>>15,t|1),t^=t+Math.imul(t^t>>>7,t|61),((t^t>>>14)>>>0)/4294967296}spreadAboutAnAxis(t){const e=1/Math.max(1e-6,t*t),n=Math.max(1e-12,this.random()),s=1+Math.log(n+(1-n)*Math.exp(-2*e))/e;return Math.max(-1,Math.min(1,s))}spreadAboutAPlane(t){for(let e=0;e<8;e++){const n=this.gaussian()*t;if(n>=-1&&n<=1)return n}return this.random()*2-1}gaussian(){if(this.hasSpare)return this.hasSpare=!1,this.spare;const t=Math.sqrt(-2*Math.log(Math.max(1e-12,this.random()))),e=2*Math.PI*this.random();return this.spare=t*Math.sin(e),this.hasSpare=!0,t*Math.cos(e)}}class Fn{static RADIUS=880;static RAYS=9e5;static RAYS_PER_FRAME=4e3;static FIRST_GLIMPSE_RAYS=5e4;static ALTITUDE_STEP_DEG=1;static GAIN=.55;object;material;sky=new fe;texture;texels;mappedAltitudeDeg=Number.NaN;mappedAlignment=Number.NaN;tracing=!1;everDisplayed=!1;refining=!0;nextGlimpse=Fn.FIRST_GLIMPSE_RAYS;workHandle;onRepaint;constructor(){const t=fe.AZIMUTH_BINS,e=fe.ALTITUDE_BINS;this.texels=new Uint16Array(t*e*4),this.texture=new jl(this.texels,t,e,un,xn),this.texture.minFilter=Te,this.texture.magFilter=Te,this.texture.wrapS=hn,this.texture.wrapT=hn,this.texture.needsUpdate=!0,this.material=new Be({uniforms:{uSource:{value:new F(0,1,0)},uUp:{value:new F(0,1,0)},uStrength:{value:0},uTint:{value:new F(1,.97,.92)},uIceCover:{value:0},uIceHeight:{value:1},uMap:{value:this.texture},uGain:{value:Fn.GAIN}},vertexShader:`
|
|
5389
5432
|
varying vec3 vDirection;
|
|
5390
5433
|
void main() {
|
|
5391
5434
|
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
@@ -5393,99 +5436,77 @@ void main()
|
|
|
5393
5436
|
}
|
|
5394
5437
|
`,fragmentShader:`
|
|
5395
5438
|
precision highp float;
|
|
5396
|
-
${
|
|
5397
|
-
${
|
|
5439
|
+
${j0}
|
|
5440
|
+
${F3}
|
|
5398
5441
|
varying vec3 vDirection;
|
|
5399
5442
|
uniform vec3 uSource;
|
|
5400
5443
|
uniform vec3 uUp;
|
|
5401
5444
|
uniform float uStrength;
|
|
5402
|
-
uniform float uHaloInner;
|
|
5403
|
-
uniform float uHaloOuter;
|
|
5404
|
-
uniform float uParhelion;
|
|
5405
|
-
uniform float uPillar;
|
|
5406
5445
|
uniform vec3 uTint;
|
|
5407
5446
|
uniform float uIceCover;
|
|
5408
5447
|
uniform float uIceHeight;
|
|
5448
|
+
uniform sampler2D uMap;
|
|
5449
|
+
uniform float uGain;
|
|
5409
5450
|
|
|
5410
5451
|
void main() {
|
|
5411
5452
|
vec3 dir = normalize(vDirection);
|
|
5412
|
-
// WHERE THERE ARE CRYSTALS, AND NOWHERE ELSE.
|
|
5413
|
-
// by
|
|
5414
|
-
//
|
|
5415
|
-
//
|
|
5416
|
-
//
|
|
5417
|
-
//
|
|
5453
|
+
// WHERE THERE ARE CRYSTALS, AND NOWHERE ELSE. Every part of a display is the source's own
|
|
5454
|
+
// light bent by ice, so it exists only along lines of sight that cross the veil — which is
|
|
5455
|
+
// why real displays are so rarely the complete circles a diagram shows. They are arcs,
|
|
5456
|
+
// fragments, one sundog and not the other. Sampling the same field the ice deck is drawn
|
|
5457
|
+
// from gets all of that for free, and guarantees the gaps fall where the sky has none.
|
|
5458
|
+
// It also ends the display at the horizon, which is right: the crystals are eight
|
|
5459
|
+
// kilometres up, so a line of sight that goes down never reaches any.
|
|
5418
5460
|
float ice = cirrusCoverAt(dir, uIceHeight, uIceCover);
|
|
5419
5461
|
if (ice <= 0.0) discard;
|
|
5420
|
-
vec3
|
|
5421
|
-
|
|
5422
|
-
|
|
5423
|
-
|
|
5424
|
-
//
|
|
5425
|
-
|
|
5426
|
-
|
|
5427
|
-
|
|
5428
|
-
float
|
|
5429
|
-
|
|
5430
|
-
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
5434
|
-
|
|
5435
|
-
// Red at the inner edge running to a cold white outward — the spectrum smeared across the
|
|
5436
|
-
// band rather than a single tinted circle.
|
|
5437
|
-
vec3 ringColour = mix(vec3(1.0, 0.55, 0.35), vec3(0.72, 0.80, 1.0), across);
|
|
5438
|
-
light += ring * ringColour * 0.30;
|
|
5439
|
-
|
|
5440
|
-
if (uParhelion > 0.0) {
|
|
5441
|
-
// THE SUNDOGS. Both sit at the source's own altitude, one either side, which is why
|
|
5442
|
-
// they keep station with an observer who moves: they are an angle, not a place. Built
|
|
5443
|
-
// by swinging the source's direction about the vertical rather than about the line of
|
|
5444
|
-
// sight, so they stay level with it however high it stands.
|
|
5445
|
-
vec3 east = normalize(cross(uUp, sun));
|
|
5446
|
-
vec3 alongHorizon = normalize(cross(east, uUp));
|
|
5447
|
-
float height = dot(sun, uUp);
|
|
5448
|
-
// The direction at the same height, swung by the parhelion's own azimuth offset.
|
|
5449
|
-
float span = cos(uParhelion);
|
|
5450
|
-
float cosSwing = clamp((span - height * height) / max(1.0 - height * height, 1e-4), -1.0, 1.0);
|
|
5451
|
-
float swing = acos(cosSwing);
|
|
5452
|
-
for (int side = 0; side < 2; side++) {
|
|
5453
|
-
float sign = side == 0 ? 1.0 : -1.0;
|
|
5454
|
-
vec3 dog = normalize(uUp * height + (alongHorizon * cos(swing) + east * sign * sin(swing)) * sqrt(max(1.0 - height * height, 0.0)));
|
|
5455
|
-
float apart = acos(clamp(dot(dir, dog), -1.0, 1.0));
|
|
5456
|
-
// A real parhelion is not a symmetric blob. Its SUNWARD edge is sharp, red and bright
|
|
5457
|
-
// — that is the minimum-deviation edge, with nothing closer to the Sun than it — and a
|
|
5458
|
-
// white tail streams outward from it. So the core is cut off hard on the inside and
|
|
5459
|
-
// allowed to run on the outside, and the colour follows: red at the sharp edge, white
|
|
5460
|
-
// down the tail.
|
|
5461
|
-
float fromSun = acos(clamp(dot(dir, sun), -1.0, 1.0));
|
|
5462
|
-
float beyond = fromSun - uParhelion;
|
|
5463
|
-
float core = exp(-apart * apart / 0.00028);
|
|
5464
|
-
float sunward = 1.0 - smoothstep(-0.012, -0.002, beyond);
|
|
5465
|
-
float tail = exp(-max(beyond, 0.0) / 0.055) * exp(-apart * apart / 0.0016);
|
|
5466
|
-
vec3 warm = vec3(1.0, 0.66, 0.36);
|
|
5467
|
-
vec3 pale = vec3(0.95, 0.95, 1.0);
|
|
5468
|
-
light += core * mix(warm, pale, clamp(beyond / 0.03, 0.0, 1.0)) * 1.9;
|
|
5469
|
-
light += tail * pale * 0.35 * (1.0 - sunward);
|
|
5470
|
-
}
|
|
5471
|
-
}
|
|
5472
|
-
|
|
5473
|
-
if (uPillar > 0.0) {
|
|
5474
|
-
// THE PILLAR. A reflection off the flat undersides of falling plates, so it carries no
|
|
5475
|
-
// colour of its own — the source's own tint, stretched vertically and dying away with
|
|
5476
|
-
// distance from it.
|
|
5477
|
-
vec3 east = normalize(cross(uUp, sun));
|
|
5478
|
-
float sideways = abs(dot(dir, east));
|
|
5479
|
-
float vertical = abs(dot(dir, uUp) - dot(sun, uUp));
|
|
5480
|
-
float shaft = exp(-sideways * sideways / 0.0009) * exp(-vertical * vertical / 0.03);
|
|
5481
|
-
light += shaft * uTint * uPillar * 0.5;
|
|
5482
|
-
}
|
|
5483
|
-
|
|
5462
|
+
vec3 up = normalize(uUp);
|
|
5463
|
+
vec3 source = normalize(uSource);
|
|
5464
|
+
// The map is held in the source's own frame: how far up, and how far round from its
|
|
5465
|
+
// bearing. Reading it that way is what lets one traced map serve every direction the
|
|
5466
|
+
// witness may be facing and every bearing the Sun may be on.
|
|
5467
|
+
float altitude = asin(clamp(dot(dir, up), -1.0, 1.0));
|
|
5468
|
+
vec3 sourceLevel = source - up * dot(source, up);
|
|
5469
|
+
vec3 dirLevel = dir - up * dot(dir, up);
|
|
5470
|
+
float sourceLength = length(sourceLevel);
|
|
5471
|
+
float dirLength = length(dirLevel);
|
|
5472
|
+
float around = (sourceLength < 1e-4 || dirLength < 1e-4)
|
|
5473
|
+
? 0.0
|
|
5474
|
+
: acos(clamp(dot(sourceLevel, dirLevel) / (sourceLength * dirLength), -1.0, 1.0));
|
|
5475
|
+
vec2 place = vec2(around / 3.14159265, (altitude + 1.57079633) / 3.14159265);
|
|
5476
|
+
vec3 light = texture2D(uMap, place).rgb * uGain * uTint;
|
|
5484
5477
|
// A little of the veil's own patchiness carried through rather than a hard mask, so the
|
|
5485
5478
|
// display fades at the edge of a fibre instead of ending on a cut line.
|
|
5486
5479
|
gl_FragColor = vec4(light * uStrength * (0.25 + 0.75 * ice), 1.0);
|
|
5487
5480
|
}
|
|
5488
|
-
`,transparent:!0,blending:Bi,depthWrite:!1,side:Nt,fog:!1}),this.object=new rt(new Bn($c.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(e,t,n,s,r){if(n<=0||t<=0){this.material.uniforms.uStrength.value=0,this.object.visible=!1;return}const a=c=>c*Math.PI/180,o=this.material.uniforms;o.uSource.value.set(e.x,e.y,e.z).normalize(),o.uStrength.value=n,o.uHaloInner.value=a(Xe.halo22().redAngleDeg),o.uHaloOuter.value=a(Xe.halo22().blueAngleDeg);const l=Xe.parheliaDistanceDeg(t);o.uParhelion.value=l===void 0?0:a(l),o.uPillar.value=Math.max(0,1-t/Xe.PILLAR_MAX_SOURCE_ALTITUDE_DEG),o.uTint.value.set(s[0],s[1],s[2]),o.uIceCover.value=r.cover,o.uIceHeight.value=r.layerHeight,this.object.visible=!0}dispose(){this.object.geometry.dispose(),this.material.dispose()}}class O0{constructor(e){this.state=e}next(){this.state=this.state+1831565813|0;let e=this.state;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}between(e,t){return e+this.next()*(t-e)}}class zi{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(e){const{ratePerHour:t,durationMs:n,velocityKmS:s,seed:r}=e;if(t<=0||n<=0)return[];const a=t*n/36e5,o=new O0(r),l=Math.floor(a),c=l+(o.next()<a-l?1:0),h=[];for(let u=0;u<c;u++){const d=Math.min(1,Math.max(0,(s-20)/52)),p=zi.MAX_DURATION_MS-d*(zi.MAX_DURATION_MS-zi.MIN_DURATION_MS),g=o.between(5,70);h.push({t:o.between(0,n),durationMs:p*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((x,m)=>x.t-m.t)}return h}static aliveAt(e,t){return e.filter(n=>t>=n.t&&t<=n.t+n.durationMs).map(n=>({meteor:n,progress:(t-n.t)/n.durationMs}))}}class It{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=It.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(It.ACROSS-1)*6;static RADIUS=840;static MIN_HALF_WIDTH_DEG=.05;static BRIGHT_HALF_WIDTH_DEG=.22;object;positions;colors;meteors=[];radiantAltitudeDeg=0;radiantAzimuthDeg=0;constructor(){const e=It.MAX_CONCURRENT*It.SEGMENTS*It.VERTICES_PER_SEGMENT;this.positions=new Float32Array(e*3),this.colors=new Float32Array(e*3);const t=new yt;t.setAttribute("position",new ct(this.positions,3)),t.setAttribute("color",new ct(this.colors,3)),t.setDrawRange(0,0),this.object=new rt(t,new Hi({vertexColors:!0,transparent:!0,blending:Bi,depthWrite:!1,fog:!1,side:vn})),this.object.frustumCulled=!1}get schedule(){return this.meteors}setShower(e,t,n){this.meteors=e,this.radiantAltitudeDeg=t,this.radiantAzimuthDeg=n}update(e){const t=this.object.geometry;if(this.meteors.length===0){t.setDrawRange(0,0);return}const n=zi.aliveAt(this.meteors,e).slice(0,It.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const l=cn(o.altitudeDeg,o.azimuthDeg,1),[c,h]=this.basisAround(l),u=r.fromRadiantDeg+a*r.lengthDeg,d=Math.max(r.fromRadiantDeg,u-r.lengthDeg*.6),p=Math.min(1,(1-a)*2.5),g=this.turn(c,h,r.bearingDeg),x=(.15+.85*r.brightness)*p,m=T=>x*T**1.6,f=T=>this.onSphere(l,g,d+(u-d)*T),w=T=>It.RADIUS*((It.MIN_HALF_WIDTH_DEG+It.BRIGHT_HALF_WIDTH_DEG*r.brightness*T)*Math.PI/180);for(let T=1;T<It.POINTS;T++){const M=(T-1)/It.SEGMENTS,S=T/It.SEGMENTS;s=this.pushRibbon(s,f(M),f(S),w(M),w(S),m(M),m(S))}}t.setDrawRange(0,s),t.getAttribute("position").needsUpdate=!0,t.getAttribute("color").needsUpdate=!0}midpointOf(e){const t=this.radiantOf(e);if(!t)return;const n=cn(t.altitudeDeg,t.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,r,e.bearingDeg),o=this.onSphere(n,a,e.fromRadiantDeg+e.lengthDeg/2),l=Math.hypot(o.x,o.y,o.z)||1;return{altitudeDeg:Math.asin(o.y/l)*180/Math.PI,azimuthDeg:(Math.atan2(o.x,-o.z)*180/Math.PI+360)%360}}radiantOf(e){return e.radiant?e.radiant:this.radiantAltitudeDeg>0?{altitudeDeg:this.radiantAltitudeDeg,azimuthDeg:this.radiantAzimuthDeg}:void 0}pushRibbon(e,t,n,s,r,a,o){const l=this.normalise(this.cross(this.normalise(t),this.normalise(this.subtract(n,t))));for(let c=0;c<It.ACROSS-1;c++){const h=c-1,u=c,d=this.across(t,l,s,h),p=this.across(n,l,r,h),g=this.across(t,l,s,u),x=this.across(n,l,r,u),m=(f,w)=>f===0?w:0;e=this.push(e,d,m(h,a)),e=this.push(e,p,m(h,o)),e=this.push(e,g,m(u,a)),e=this.push(e,p,m(h,o)),e=this.push(e,x,m(u,o)),e=this.push(e,g,m(u,a))}return e}across(e,t,n,s){return{x:e.x+t.x*n*s,y:e.y+t.y*n*s,z:e.z+t.z*n*s}}push(e,t,n){const s=e*3;this.positions[s]=t.x,this.positions[s+1]=t.y,this.positions[s+2]=t.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.9,this.colors[s+1]=r*.95,this.colors[s+2]=r,e+1}turn(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:e.x*r+t.x*a,y:e.y*r+t.y*a,z:e.z*r+t.z*a}}onSphere(e,t,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(e.x*r+t.x*a)*It.RADIUS,y:(e.y*r+t.y*a)*It.RADIUS,z:(e.z*r+t.z*a)*It.RADIUS}}basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=this.normalise(this.cross(e,t));return[n,this.normalise(this.cross(e,n))]}subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}dispose(){this.object.geometry.dispose(),this.object.material.dispose()}}const g3=2;function v3(i){return i==="building"||i==="vehicle"}function _3(i,e){const t=i.litKeyframes;if(!t||t.length===0)return i.lit??!1;let n=t[0];for(const s of t){if(s.t>e)break;n=s}return n.lit}function x3(i,e){return i.pattern.kind==="steady"?!0:M3(i,e,e+1)>.5}function M3(i,e,t){if(i.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:s,phase:r=0}=i.pattern,a=Math.min(Math.max(s,0),1);if(a===0||n<=0)return 0;const o=6e4/n,l=e/o+r,c=t/o+r;if(c<=l)return Math.min(Math.max(l-Math.floor(l),0),a)<a?1:0;const h=u=>Math.floor(u)*a+Math.min(u-Math.floor(u),a);return(h(c)-h(l))/(c-l)}function y3(i,e){const t=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!t||t.length===0)return n;if(t.length===1||e<=t[0].t)return Hu(t[0],i);const s=t[t.length-1];if(e>=s.t)return Hu(s,i);for(let r=0;r<t.length-1;r++){const a=t[r],o=t[r+1];if(e<a.t||e>o.t)continue;const l=o.t-a.t,c=l===0?0:(e-a.t)/l;return{eastM:a.eastM+(o.eastM-a.eastM)*c,northM:a.northM+(o.northM-a.northM)*c,altitudeM:(a.altitudeM??0)+((o.altitudeM??0)-(a.altitudeM??0))*c,headingDeg:a.headingDeg??i.headingDeg}}return n}function Hu(i,e){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??e.headingDeg}}const Vu=Math.PI/180;function Ht(i,e,t,n,s=!1){const r=s?new Hi({color:new xe(...t)}):new pr({color:new xe(...t)}),a=new rt(e,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const Wu=.25,S3=.002;function E3(i){const e=/^#([0-9a-f]{6})$/i.exec(i);if(!e)return[1,1,1];const t=parseInt(e[1],16);return[(t>>16&255)/255,(t>>8&255)/255,(t&255)/255]}const z0=[.32,.32,.3],B0=[1,.85,.5],k0=[.25,.25,.25],G0=[1,.97,.85],b3=[.55,.68,.72],Rn=.03,Cn=.05,H0={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 qt(i,e){return i?.[e]}function Dn(i,e,t,n,s,r,a,o){if(o===void 0)return;const l=new pr({color:new xe(...b3),transparent:!0,opacity:o/100}),c=new rt(new dn(e,t,n),l);c.position.set(s,r,a),i.add(c)}const on=.05,Wo=[.6,.58,.53],Xu=[.5,.5,.48];function Ss(i,e,t,n,s,r,a,o){const l=new pr({color:new xe(...o),side:Nt}),c=new rt(new dn(e,t,n),l);c.position.set(s,r,a),i.add(c)}function w3(i,e,t,n,s,r,a,o,l){const c=(n-r)/2,h=(g,x,m,f)=>{g<=0||(e?Ss(i,g,x,on,m,o+f,a,l):Ss(i,on,x,g,a,o+f,m,l))};h(t,c,0,n/2-c/2),h(t,c,0,-(n/2-c/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-t/2;for(const g of u){const m=g.center-g.main/2-d;h(m,r,d+m/2,0),d=g.center+g.main/2}const p=t/2-d;h(p,r,d+p/2,0)}function V0(i,e,t,n,s,r,a,o,l,c){const h=(n+s)/2,u=s-n,d=(p,g,x,m)=>{p.length===0?g?Ss(i,x,u,on,0,h,m,Wo):Ss(i,on,u,x,m,h,0,Wo):w3(i,g,x,u,p,r,m,h,Wo)};d(a,!0,e*2,-t+on),d(o,!0,e*2,t-on),d(l,!1,t*2,-e+on),d(c,!1,t*2,e-on),Ss(i,e*2,on,t*2,0,n+on,0,Xu),Ss(i,e*2,on,t*2,0,s-on,0,Xu)}function xc(i,e,t,n){switch(i){case"front":return{x:0,z:-(t-n)};case"behind":return{x:0,z:t-n};case"left":return{x:-(e-n),z:0};case"right":return{x:e-n,z:0};case"front-left":return{x:-(e-n),z:-Pn};case"front-right":return{x:e-n,z:-Pn};case"behind-left":return{x:-(e-n),z:Pn};case"behind-right":return{x:e-n,z:Pn}}}function W0(i,e,t,n,s,r,a){const o=Y0();o.scale.setScalar(n),o.rotation.y=H0[e];const{x:l,z:c}=xc(e,s,r,a);o.position.set(l,t,c),i.add(o)}const Mc=6,yc=6,di=3,$s=1.4,Js=di*.5,X0=1.2,q0=.35,A3=.75,T3=1.6;function R3(i,e,t,n){const s=new xn,r=Math.max(1,i+1),a=r*di;Ht(s,new dn(Mc,a,yc),[.55,.54,.5],a/2);const o=Mc/2,l=yc/2;for(let c=0;c<r;c++){const h=c*di+di/2;Dn(s,$s,Js,Cn,0,h,-l-Rn,qt(e,"front")),Dn(s,$s,Js,Cn,0,h,l+Rn,qt(e,"behind")),Dn(s,Cn,Js,$s,-o-Rn,h,0,qt(e,"left")),Dn(s,Cn,Js,$s,o+Rn,h,0,qt(e,"right"))}if(t){const c=Math.min(Math.max(n??0,0),r-1);W0(s,t,c*di,.72,o,l,X0);const h=u=>qt(e,u)!==void 0?[{main:$s,center:0}]:[];V0(s,o,l,c*di,(c+1)*di,Js,h("front"),h("behind"),h("left"),h("right"))}return s}function C3(){const i=new xn;return Ht(i,new yi(.15,.22,2,8),[.32,.22,.14],1),Ht(i,new Va(1.4,3,8),[.16,.32,.14],3.5),i}function D3(i){const e=new xn;return Ht(e,new yi(.05,.08,5,8),[.28,.28,.3],2.5),Ht(e,new Bn(.25,12,8),i?B0:z0,5.1,!0),e}const P3=[.08,.08,.08],ui=.8,_s=1,An=1.7,Xo=.6,Ri=.4,ra=1.2,ms=.7,Pn=.5,I3=An;function L3(i,e,t){const n=new xn;Ht(n,new dn(1.8,1.4,4.2),[.45,.14,.14],.7),Ht(n,new dn(ui*2,Xo,_s*2),[.4,.12,.12],An);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Ht(n,new yi(.4,.4,.3,12),P3,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?G0:k0;for(const r of[-.7,.7])Ht(n,new Bn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(Dn(n,ra,Ri,Cn,0,An,-_s-Rn,qt(e,"front")),Dn(n,ra,Ri,Cn,0,An,_s+Rn,qt(e,"behind")),Dn(n,Cn,Ri,ms,-ui-Rn,An,-Pn,qt(e,"front-left")),Dn(n,Cn,Ri,ms,-ui-Rn,An,Pn,qt(e,"behind-left")),Dn(n,Cn,Ri,ms,ui+Rn,An,-Pn,qt(e,"front-right")),Dn(n,Cn,Ri,ms,ui+Rn,An,Pn,qt(e,"behind-right")),t){W0(n,t,A3,.5,ui,_s,q0);const r=(l,c)=>{const h=[];return qt(e,l)!==void 0&&h.push({main:ms,center:-Pn}),qt(e,c)!==void 0&&h.push({main:ms,center:Pn}),h},a=qt(e,"front")!==void 0?[{main:ra,center:0}]:[],o=qt(e,"behind")!==void 0?[{main:ra,center:0}]:[];V0(n,ui,_s,An-Xo/2,An+Xo/2,Ri,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const N3=[.95,.9,.82];function Y0(){const i=new xn;Ht(i,new yi(.25,.3,1.5,10),[.3,.3,.35],.75),Ht(i,new Bn(.22,10,8),[.62,.52,.46],1.72);const e=Ht(i,new Va(.07,.16,8),N3,1.72);return e.rotation.x=-Math.PI/2,e.position.z=-.2,i}const U3=17,qu=18.5,qo=[.16,.16,.18];function F3(){const i=new xn,e=Ht(i,new yi(1.8,1.8,qu*2,10),qo,0);e.rotation.x=Math.PI/2,Ht(i,new dn(U3*2,.5,4.5),qo,0);const t=Ht(i,new dn(.4,5.5,4),qo,3);return t.position.z=-qu+2,i}class gs{static occupantView(e){const t=e.witnessSide;if(!t)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=e.kind==="vehicle"?xc(t,ui,_s,q0):xc(t,Mc/2,yc/2,X0),r=e.kind==="vehicle"?I3:(e.occupiedFloor??0)*di+T3,a=(e.headingDeg??0)-H0[t]/Vu;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(e,t){const n=e.kind==="building"?R3(e.floors??g3,e.windows,e.witnessSide,e.occupiedFloor):e.kind==="tree"?C3():e.kind==="streetlight"?D3(t):e.kind==="vehicle"?L3(t,e.windows,e.witnessSide):e.kind==="aircraft"?F3():Y0();return e.headingDeg!==void 0&&(n.rotation.y=-e.headingDeg*Vu),this.addLights(n,e.lights),e.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(e){for(const t of e.children){if(!(t instanceof rt))continue;const n=t.material;n.fog=!1,n.needsUpdate=!0}}static addLights(e,t){for(const n of t??[]){const s=Ht(e,new Bn(Wu,8,6),E3(n.color),n.offsetM.y,!0);s.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),s.userData={emissive:!0,lightId:n.id},s.visible=!1}}static setLights(e,t,n,s){if(!t||t.length===0)return;const r=new Map(t.map(o=>[o.id,o])),a=Math.max(1,s*S3/Wu);for(const o of e.children){if(!(o instanceof rt))continue;const l=o.userData.lightId;if(!l)continue;const c=r.get(l);c&&(o.visible=x3(c,n),o.scale.setScalar(a*(c.intensity??1)**.5))}}static setLit(e,t,n){const s=t==="streetlight"?n?B0:z0:n?G0:k0;for(const r of e.children){const a=r.userData;!(r instanceof rt)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(e){for(const t of e.children)t instanceof rt&&(t.geometry.dispose(),t.material.dispose())}}function O3(i,e){return i.cloudCover===e.cloudCover&&i.cloudDarkness===e.cloudDarkness&&i.cloudBaseM===e.cloudBaseM&&i.highCloudCover===e.highCloudCover&&i.lowerCloudCover===e.lowerCloudCover&&i.precipitationType===e.precipitationType&&i.precipitationIntensity===e.precipitationIntensity&&i.windDirectionDeg===e.windDirectionDeg&&i.windSpeed===e.windSpeed&&i.storm===e.storm}const aa=900,Yu=.5,sr=900,z3=6371e3,B3=3e4;function Ku(i){const e=Math.sqrt(2*z3*Math.max(i,0));return Math.max(sr,Math.min(e,B3))}const Yo=.5,k3=850,oa=850,Ko=4,Zu=1.5,G3=-1,H3=6,Sc=-4,V3=.2,la=2600,W3=.97,X3=.38,$u=Sc,q3=3,Y3=.15,K3=.6,Z3=40,$3=30,J3=[0,45,90,135,180,225,270,315],Q3={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},j3=["en","fr"],eM=880,Ju=40,tM=10,nM=1,iM=150,sM=55,Qu=.5,ju=700,rM=250/Md,aM=12,ed=5,Zo=6,Ci=[.92,.92,.95],$o=[.15,.15,.19],td={snow:{fallSpeedMPerS:2,size:.3,color:new xe(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new xe(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},xs=0,oM=0,nd=3e3,Qs=20,lM=15,id=xs,cM=40,sd=1,hM=9;function uM(i){return sd+(hM-sd)*i}const dM=new xe(.75,.82,.92),fM=10,pM=.5;function mM(i){return K0(i/fM,pM,1)}const vs=200,rd=.18,ad=.32,gM=.35,vM=new xe(.85,.9,.98),od=5,ld=.85,cd=.01;function Jo(i,e){return Math.round(i*(cd+(1-cd)*e))}const hd=230,ud=.7,dd=.05,_M=.6,xM=.7,MM=.15,fd=.35,yM=3,SM=1/12,EM=.5,pd=8,md=25,gd=.12,bM={Venus:new xe(1,.96,.85),Mars:new xe(1,.55,.4),Jupiter:new xe(.95,.87,.72),Saturn:new xe(.92,.86,.68)};class wM{renderer;scene=new Wd;camera;celestialGroup=new xn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new gm(16777215,0);celestialLightTarget=new wt;skyLight=new dm(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Co;weather=yd;observerElevationM=0;groundRadius=sr;terrainRadius=sr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new U;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;dazzleIntensity=1;sunCloudTransmission=1;lensFlareArtifactIntensity=0;sunWorldPosition=new U;sunVisible=!1;lensFlareScratch=new U;sunOcclusionRaycaster=new Co;sunOcclusionDirectionScratch=new U;ufoOcclusionRaycaster=new Co;projectionKind="rectilinear";equidistantPass;meteorSystem;cometTail;iceHalos;cometKey;onLightningFlash;constructor(e,t=qx(),n){this.renderer=new p2({canvas:e,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=ar,this.camera=new tn(60,e.width/Math.max(e.height,1),.1,aa*1.2),this.camera.position.set(0,1.6,0),this.terrainProviders=t,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(e,t){this.renderer.setSize(e,t,!1),this.camera.aspect=e/Math.max(t,1),this.camera.updateProjectionMatrix(),this.render()}setObserverPose(e){e.headingDeg!==void 0?this.camera.rotation.set(e.pitchDeg*gn,-e.headingDeg*gn,0,"YXZ"):this.camera.rotation.set(e.pitchDeg*gn,this.camera.rotation.y,0,"YXZ"),e.elevationM!==this.observerElevationM&&(this.observerElevationM=e.elevationM,this.syncCloudLayer(),Math.abs(Ku(e.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/sr),this.camera.far=Math.max(aa*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+e.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==e.fovDeg&&(this.camera.fov=e.fovDeg,this.camera.updateProjectionMatrix())}setTerrainProviders(e){this.terrainProviders=e,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.terrainBuildToken++}setTerrainOrigin(e,t,n){if(e===void 0||t===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=Wi(e,t,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<iM*(s/sr))return}this.terrainOrigin={lat:e,lng:t},this.terrainRadius=s;const r=++this.terrainBuildToken;Qx(e,t,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=nM,this.terrainMesh=a,this.terrainAttribution=o,this.scene.add(a),this.render(),n?.())}).catch(a=>{console.warn("Terrain build failed, keeping the flat ground fallback:",a),n?.()})}setShowCompass(e){this.showCompass!==e&&(this.showCompass=e,this.disposeCompassLabels(),e&&this.buildCompassLabels(),this.render())}setDazzleIntensity(e){this.dazzleIntensity!==e&&(this.dazzleIntensity=e,this.lensFlare&&(this.lensFlare.uniforms.uOpacity.value=Qu*e,this.lastSunPosition&&this.applyLensFlareTint(fs(this.lastSunPosition.altitudeDeg))),this.render())}setLensFlareArtifactIntensity(e){this.lensFlareArtifactIntensity!==e&&(this.lensFlareArtifactIntensity=e,this.lensFlare&&(this.lensFlare.uniforms.uFlareIntensity.value=e),this.render())}applyLensFlareTint(e){if(!this.lensFlare)return;const t=sM*this.dazzleIntensity*this.sunCloudTransmission;this.lensFlare.uniforms.uColorGain.value.setRGB(t*e[0],t*e[1],t*e[2])}setCompassHovered(e){this.compassHovered!==e&&(this.compassHovered=e,this.updateCompassVisibility())}setCompassForced(e){this.compassForced!==e&&(this.compassForced=e,this.updateCompassVisibility())}updateCompassVisibility(){const e=this.compassHovered||this.compassForced;for(const t of this.compassSprites)t.visible=e;this.render()}setWeather(e){O3(this.weather,e)||(this.weather=e,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=e.storm&&e.cloudDarkness>=EM,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(e){if(this.decorObjects!==e){this.decorObjects=e;for(const t of this.decorGroups.values())t.removeFromParent(),gs.dispose(t);this.decorGroups.clear(),this.streetlightLights.clear();for(const t of e){const n=gs.build(t,t.lit??!1);this.scene.add(n),this.decorGroups.set(t.id,n),t.kind==="streetlight"&&this.addStreetlightLight(t.id,n)}this.celestialLight.castShadow=this.decorGroups.size>0}}updateDecorAnchoring(e,t,n=0){const s=e?.lat!==void 0&&e.lng!==void 0&&t?.lat!==void 0&&t?.lng!==void 0?Wi(e.lat,e.lng,t.lat,t.lng):{x:0,z:0},r=this.decorObjects.find(c=>c.witnessSide!==void 0&&v3(c.kind)),a={x:0,z:0};let o=0;if(r){const c=gs.occupantView(r),h=-(r.headingDeg??0)*gn,u=c.x*Math.cos(h)+c.z*Math.sin(h),d=-c.x*Math.sin(h)+c.z*Math.cos(h),p=r.eastM+s.x,g=-r.northM+s.z;a.x=-(p+u),a.z=-(g+d),this.camera.position.y=c.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*gn,-(c.headingDeg+this.indoorLookYawDeg)*gn,0,"YXZ")}for(const c of this.decorObjects){const h=this.decorGroups.get(c.id);if(!h)continue;const u=y3(c,n);h.position.set(u.eastM+s.x+a.x,oM+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*gn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const l=Math.max(aa*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-l)>1&&(this.camera.far=l,this.camera.updateProjectionMatrix())}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(e,t){this.indoorLookYawDeg=e,this.indoorLookPitchDeg=t}updateDecorLitState(e){for(const t of this.decorObjects){const n=this.decorGroups.get(t.id);if(n&&t.lights?.length&&gs.setLights(n,t.lights,e,n.position.distanceTo(this.camera.position)),t.kind!=="streetlight"&&t.kind!=="vehicle")continue;const s=this.decorGroups.get(t.id);if(!s)continue;const r=_3(t,e);gs.setLit(s,t.kind,r);const a=this.streetlightLights.get(t.id);a&&(a.visible=r)}}addStreetlightLight(e,t){const n=t.children.find(r=>r.userData.emissive);if(!n)return;const s=new pm(16764006,Z3,$3);s.position.copy(n.position),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,t.add(s),this.streetlightLights.set(e,s)}setAstronomy(e){const t=c0(e.sun.altitudeDeg),n=t.horizon;this.baseFogColor=n,this.lastSunPosition=e.sun,this.buildSky(e.sun),this.buildGround(),this.updateCloudLighting(e.sun,n),this.updateCelestialLight(e,t.zenith,n),this.buildStars(e.stars,e.sun.altitudeDeg);const s=bu(e.sun.altitudeDeg);this.setBodyMesh("sun",e.sun,Ko,new xe(1,.96,.88),e.sun.magnitude),this.setMoonMesh(e.moon,s),this.buildPlanets(e.planets,s),this.buildComet(e.comet,s),this.buildIceHalos(e.sun,e.moon),this.scene.fog=new Oc(new xe(...n),this.groundRadius*.2,this.groundRadius),this.syncAnimationLoop(),this.render()}updateCelestialLight(e,t,n){this.skyLight.color.setRGB(t[0],t[1],t[2]),this.skyLight.groundColor.setRGB(n[0],n[1],n[2]),this.skyLight.intensity=K3;const s=e.sun.altitudeDeg>=$u,r=!s&&e.moon.altitudeDeg>=$u;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?e.sun:e.moon,{x:o,y:l,z:c}=cn(a.altitudeDeg,a.azimuthDeg,oa);this.celestialLight.position.set(o,l,c);const h=fs(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*gn));this.celestialLight.intensity=(s?q3:Y3)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(e,t,n){this.meteorSystem||(this.meteorSystem=new It,this.celestialGroup.add(this.meteorSystem.object)),this.meteorSystem.setShower(e,t,n)}get meteorSchedule(){return this.meteorSystem?.schedule??[]}meteorMidpoint(e){return this.meteorSystem?.midpointOf(e)}updateMeteors(e){this.meteorSystem?.update(e)}setProjection(e){this.projectionKind=e}render(){const e=this.usableEquidistantPass();if(!e){this.updateLensFlarePosition(),this.renderer.render(this.scene,this.camera);return}e.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition())}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const e=this.renderer.getDrawingBufferSize(new Fe);if(Fa.supports(this.camera.fov,e.x/Math.max(e.y,1)))return this.equidistantPass?this.equidistantPass.resize(e.x,e.y):this.equidistantPass=new Fa(e.x,e.y),this.equidistantPass}aimAtScreenPoint(e,t,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){e.setFromCamera(new Fe(t,n),this.camera);return}const r=s.directionFor(t,n,this.camera.fov);this.camera.updateMatrixWorld(),e.ray.origin.setFromMatrixPosition(this.camera.matrixWorld),e.ray.direction.set(r.x,r.y,r.z).applyQuaternion(this.camera.quaternion).normalize(),e.camera=this.camera}updateLensFlarePosition(){const e=this.lensFlare;if(!e)return;if(!this.sunVisible){e.mesh.visible=!1;return}if(this.camera.updateMatrixWorld(),this.lensFlareScratch.copy(this.sunWorldPosition).applyMatrix4(this.camera.matrixWorldInverse),this.lensFlareScratch.z>0){e.mesh.visible=!1;return}if(this.isSunOccluded()){e.mesh.visible=!1;return}e.mesh.visible=!0;const t=this.lensFlareScratch.copy(this.sunWorldPosition).project(this.camera);e.uniforms.uLensPosition.value.set(t.x,t.y),e.uniforms.uResolution.value.set(this.renderer.domElement.width,this.renderer.domElement.height)}isSunOccluded(){this.scene.updateMatrixWorld();const e=[];this.groundMesh&&e.push(this.groundMesh),this.terrainMesh&&e.push(this.terrainMesh);for(const r of this.decorGroups.values())e.push(r);if(e.length===0)return!1;const t=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),n=t.length();t.normalize(),this.sunOcclusionRaycaster.set(this.camera.position,t);const s=this.sunOcclusionRaycaster.intersectObjects(e,!0)[0];return s!==void 0&&s.distance<n}isScreenPointOccluded(e,t,n,s){if(s&&this.cloudMesh&&this.lowerCloudCover()>0)return!0;const r=[];for(const a of this.decorObjects){if(!a.occludesSourceIds?.includes(n))continue;const o=this.decorGroups.get(a.id);o&&r.push(o)}return r.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Yu,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(e,t,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,e,t),this.ufoOcclusionRaycaster.near=Yu;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const l=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];l&&(a.occludesSourceIds?.includes(n)?s=s===void 0?l.distance:Math.max(s,l.distance):r=r===void 0?l.distance:Math.min(r,l.distance))}return{behindM:s,inFrontM:r}}pickBodyAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[0]}pickDecorAt(e,t){this.aimAtScreenPoint(this.raycaster,e,t);const n=[...this.decorGroups.entries()],s=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!s)return;let r=s.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),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.cometTail?.dispose(),this.cometTail=void 0;for(const e of this.bodyMeshes.values())this.disposeMesh(e);this.bodyMeshes.clear();for(const e of[...this.hitAreas.keys()])this.disposeHitArea(e);for(const e of[...this.glareSprites.keys()])this.disposeGlare(e);this.disposeCompassLabels();for(const e of this.decorGroups.values())gs.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear(),this.lensFlare&&(this.lensFlare.mesh.removeFromParent(),this.lensFlare.mesh.geometry.dispose(),this.lensFlare.mesh.material.dispose(),this.lensFlare=void 0),this.renderer.dispose()}animationsRunning=!1;startTwinkle(){if(this.animationFrameId!==null||!this.needsAnimationLoop())return;let e;const t=n=>{const s=e===void 0?0:Math.min((n-e)/1e3,SM);e=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),this.render(),this.animationFrameId=requestAnimationFrame(t)};this.animationFrameId=requestAnimationFrame(t)}setAnimationsRunning(e){e!==this.animationsRunning&&(this.animationsRunning=e,e?this.nextLightningAtS=null:this.lightningFlashRemainingS>0&&(this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),e||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(e){this.disposeMesh(this.skyMesh);const t=new Bn(aa,32,16),n=t.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:l}=_2(n.getX(a),n.getY(a),n.getZ(a)),c=y2(o,l,e.azimuthDeg,e.altitudeDeg);s.push(c[0],c[1],c[2])}t.setAttribute("color",new At(s,3));const r=new Hi({vertexColors:!0,side:Nt,fog:!1,depthWrite:!1});this.skyMesh=new rt(t,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=Ku(this.observerElevationM);const e=new kc(this.groundRadius,48),t=new pr({color:new xe(Yo,Yo,Yo),fog:!0});this.groundMesh=new rt(e,t),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}cloudTransmission(e){const t=cn(e.altitudeDeg,e.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-bt.alphaAt(t,Math.abs(this.cloudLayerOffset()),s)*W3);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-bt.alphaAt(t,la,r)*X3),Math.max(0,Math.min(1,n))}setBodyMesh(e,t,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(e)),this.disposeHitArea(e),this.disposeGlare(e),t.altitudeDeg<Sc){this.bodyMeshes.delete(e),e==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:l}=cn(t.altitudeDeg,t.azimuthDeg,oa),c=fs(t.altitudeDeg),h=this.cloudTransmission(t),u=new xe(s.r*c[0]*h,s.g*c[1]*h,s.b*c[2]*h),d=new Bn(n,16,16),p=new Hi({color:u,fog:!1}),g=new rt(d,p);g.position.set(a,o,l),this.celestialGroup.add(g),this.bodyMeshes.set(e,g),this.setHitArea(e,a,o,l,n);const x=r-2.5*Math.log10(Math.max(h,.001));if(e==="sun"&&(this.sunCloudTransmission=h),e!=="sun"&&this.setGlare(e,a,o,l,x,u),e==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,l*m),this.lensFlare||(this.lensFlare=m3(),this.lensFlare.uniforms.uOpacity.value=Qu*this.dazzleIntensity,this.lensFlare.uniforms.uFlareIntensity.value=this.lensFlareArtifactIntensity,this.scene.add(this.lensFlare.mesh)),this.applyLensFlareTint(c)}}setMoonMesh(e,t){const n="moon";if(this.disposeMesh(this.bodyMeshes.get(n)),this.disposeHitArea(n),this.disposeGlare(n),e.magnitude>t||e.altitudeDeg<Sc){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=cn(e.altitudeDeg,e.azimuthDeg,oa),o=fs(e.altitudeDeg),l=new xe(o[0],o[1],o[2]),c=new er({map:UM(e.phase),color:l,fog:!1}),h=new Nr(c);h.position.set(s,r,a);const u=Ko*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,Ko),this.setGlare(n,s,r,a,e.magnitude,l)}setHitArea(e,t,n,s,r){const a=new er({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new Nr(a);o.position.set(t,n,s);const l=r*H3;o.scale.set(l,l,1),this.celestialGroup.add(o),this.hitAreas.set(e,o)}disposeHitArea(e){const t=this.hitAreas.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.hitAreas.delete(e))}setGlare(e,t,n,s,r,a){const o=E2(r);if(o<=0){this.disposeGlare(e);return}const l=A2(o),c=this.glareSprites.get(e),h=c??new Nr(new er({map:NM(),transparent:!0,blending:Bi,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=C2(o),h.position.set(t,n,s),h.scale.set(l*2,l*2,1),c||(this.celestialGroup.add(h),this.glareSprites.set(e,h))}disposeGlare(e){const t=this.glareSprites.get(e);t&&(t.removeFromParent(),t.material.dispose(),this.glareSprites.delete(e))}buildComet(e,t){const n=e&&`comet:${e.id}`;if(!e||!n||e.magnitude>t){this.disposeComet();return}this.cometKey&&this.cometKey!==n&&this.disposeComet();const s=Oo(e.magnitude),r=zo(s);this.cometKey=n,this.setBodyMesh(n,e.position,Zu*(.5+.5*s),new xe(r,r,r),e.magnitude),this.cometTail||(this.cometTail=new jt(oa),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(e.position,e.tailEnd,s)}buildIceHalos(e,t){this.iceHalos||(this.iceHalos=new $c,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:la});return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=e.altitudeDeg>0?e:t,a=Xe.strength(n,s)*(r===e?1:V3),{x:o,y:l,z:c}=cn(r.altitudeDeg,r.azimuthDeg,1),h=fs(r.altitudeDeg);this.iceHalos.update({x:o,y:l,z:c},r.altitudeDeg,a,[h[0],h[1],h[2]],{cover:n,layerHeight:la})}disposeComet(){this.cometTail?.set(void 0,void 0,0),this.cometKey&&(this.disposeMesh(this.bodyMeshes.get(this.cometKey)),this.bodyMeshes.delete(this.cometKey),this.disposeHitArea(this.cometKey),this.disposeGlare(this.cometKey),this.cometKey=void 0)}buildPlanets(e,t){const n=new Set(["sun","moon",...this.cometKey?[this.cometKey]:[]]);for(const s of e){if(s.magnitude>t)continue;n.add(s.body);const r=Oo(s.magnitude),a=zo(r),o=bM[s.body]??new xe(1,1,1),l=new xe(o.r*a,o.g*a,o.b*a),c=Zu*(.5+.5*r);this.setBodyMesh(s.body,s.position,c,l,s.magnitude)}for(const s of[...this.bodyMeshes.keys()])n.has(s)||(this.disposeMesh(this.bodyMeshes.get(s)),this.bodyMeshes.delete(s),this.disposeHitArea(s),this.disposeGlare(s))}buildStars(e,t){if(this.disposeStarTiers(),!e||e.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=e,a=bu(t),o=Qo(1337),l=[];for(let c=0;c<n.count;c++){const h=n.mag[c];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=Za(n.ra[c],n.dec[c],s,r);if(u<G3)continue;const{x:p,y:g,z:x}=cn(u,d,k3);l.push({x:p,y:g,z:x,brightness:Oo(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=h0.map((c,h)=>{const u=l.filter(M=>P2(M.brightness)===h),d=new Float32Array(u.length*3),p=new Float32Array(u.length),g=new Float32Array(u.length),x=new Float32Array(u.length);u.forEach((M,S)=>{d[S*3]=M.x,d[S*3+1]=M.y,d[S*3+2]=M.z,p[S]=M.brightness,g[S]=M.phase,x[S]=M.speedFactor});const m=new yt;m.setAttribute("position",new ct(d,3));const f=new ct(new Float32Array(u.length*3),3);m.setAttribute("color",f);const w=new Kd({vertexColors:!0,size:c.size,sizeAttenuation:!1,fog:!1});Ni.apply(w);const T=new xa(m,w);return this.celestialGroup.add(T),{points:T,colorAttribute:f,brightness:p,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(e){for(const t of this.starTiers){const n=t.colorAttribute.array;for(let s=0;s<t.brightness.length;s++){const r=N2(t.brightness[s],{phase:t.phase[s],speedFactor:t.speedFactor[s]},e),a=zo(t.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*3+2]=a}t.colorAttribute.needsUpdate=!0}}buildClouds(){this.disposeCloudSystem();const e=this.lowerCloudCover();if(e<=0)return;const t=this.weather.cloudDarkness,n=new xe(Ci[0]+($o[0]-Ci[0])*t,Ci[1]+($o[1]-Ci[1])*t,Ci[2]+($o[2]-Ci[2])*t),{material:s,uniforms:r}=ku(n,e,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=Gu(ju);this.cloudMesh=new rt(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=ed,this.celestialGroup.add(this.cloudMesh)}lowerCloudCover(){return this.weather.lowerCloudCover??this.weather.cloudCover}buildCirrus(){this.disposeCirrus();const e=this.weather.highCloudCover??0;if(e<=0)return;const{material:t,uniforms:n}=ku(new xe(...Ci),e,la,1);this.cirrusMaterial=t,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new rt(Gu(ju*1.04),t),this.cirrusMesh.renderOrder=ed-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 e=this.cloudLayerOffset();this.cloudUniforms&&(this.cloudUniforms.layerHeight.value=Math.abs(e)),this.cloudMesh&&(this.cloudMesh.scale.y=e<0?-1:1)}cloudLayerOffset(){const t=((this.weather.cloudBaseM??Md)-this.observerElevationM)*rM;return Math.sign(t||1)*Math.max(Math.abs(t),aM)}updateCloudLighting(e,t){const n=[this.cloudUniforms,this.cirrusUniforms].filter(c=>c!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=cn(e.altitudeDeg,e.azimuthDeg,1),o=fs(e.altitudeDeg),l=Math.max(0,Math.sin(Math.max(e.altitudeDeg,0)*gn));for(const c of n)c.sunDir.value.set(s,r,a),c.sunColor.value.setRGB(o[0]*l,.96*o[1]*l,.88*o[2]*l),c.ambientColor.value.setRGB(t[0],t[1],t[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 e=this.weather.precipitationType;if(e==="none")return;if(e==="rain"){this.buildRain();return}const t=td[e],n=t.poolSize,s=Qo(9001),r=new Float32Array(n*3),a=new Float32Array(n),o=new Float32Array(n),l=new Float32Array(n),c=new Float32Array(n),h=new Float32Array(n),u=new Float32Array(n),d=new Float32Array(n),p=new Float32Array(n),g=new Float32Array(n);for(let T=0;T<n;T++){const M=s()*Math.PI*2,S=s()*t.radiusM;r[T*3]=Math.cos(M)*S,r[T*3+1]=xs+s()*(t.topYM-xs),r[T*3+2]=Math.sin(M)*S,a[T]=s()*Math.PI*2,o[T]=.7+s()*.6,l[T]=.6+s()*.8,c[T]=.4+s()*1.2}const x=new yt;x.setAttribute("position",new ct(r,3)),x.setDrawRange(0,Jo(n,this.weather.precipitationIntensity));const m={uSize:{value:t.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:t.opacity},uColor:{value:t.color},uHazeColor:{value:new xe(...this.baseFogColor)},uTexture:{value:AM(e)},uNearFocusDistance:{value:od},uHazeDistance:{value:t.radiusM*ld}},f=new Ft({uniforms:m,vertexShader:IM,fragmentShader:LM,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const w=new xa(x,f);w.renderOrder=Zo,this.scene.add(w),this.precipitationPoints=w,this.precipitationPositions=r,this.precipitationPhase=a,this.precipitationSpeedJitter=o,this.precipitationWobbleFreqJitter=l,this.precipitationWobbleAmpJitter=c,this.precipitationBounceRemaining=h,this.precipitationBounceHeight=u,this.precipitationBounceDuration=d,this.precipitationBounceVelX=p,this.precipitationBounceVelZ=g}updatePrecipitation(e,t){if(!this.precipitationPoints||!this.precipitationPositions||!this.precipitationPhase||!this.precipitationSpeedJitter||(this.precipitationUniforms?.uHazeColor.value.setRGB(...this.baseFogColor),t<=0))return;const n=this.weather.precipitationType;if(n==="none"||n==="rain")return;const s=td[n],r=this.weather.windDirectionDeg*gn,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,l=this.precipitationPositions,c=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,p=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,x=this.precipitationBounceDuration,m=this.precipitationBounceVelX,f=this.precipitationBounceVelZ,w=n==="snow"&&u&&d,T=n==="hail"&&p&&g&&x&&m&&f;for(let M=0,S=0;M<l.length;M+=3,S++){if(T&&p[S]>0){if(p[S]-=t,p[S]<=0){const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(_)*E,l[M+1]=s.topYM,l[M+2]=Math.sin(_)*E,p[S]=0}else{const _=1-p[S]/x[S];l[M+1]=xs+Math.sin(Math.PI*_)*g[S],l[M]=ha(l[M]+(a+m[S])*t,s.radiusM),l[M+2]=ha(l[M+2]+(o+f[S])*t,s.radiusM)}continue}let b=0,R=0;if(w){const _=_M*u[S],E=xM*d[S];b=Math.sin(e*_*Math.PI*2+c[S])*E,R=Math.sin(e*_*Math.PI*2+c[S]+Math.PI/2)*E}if(l[M]+=(a+b)*t,l[M+1]-=s.fallSpeedMPerS*h[S]*t,l[M+2]+=(o+R)*t,l[M]=ha(l[M],s.radiusM),l[M+2]=ha(l[M+2],s.radiusM),l[M+1]<xs){if(T){g[S]=fd*(.2+Math.random()*1.6),x[S]=MM*(.5+Math.random()),p[S]=x[S];const D=Math.random()*Math.PI*2,C=yM*(g[S]/fd);m[S]=Math.cos(D)*C,f[S]=Math.sin(D)*C,l[M+1]=xs;continue}const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;l[M]=Math.cos(_)*E,l[M+1]=s.topYM,l[M+2]=Math.sin(_)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const e=uM(this.weather.precipitationIntensity);this.rainSystem=o3({count:nd,radiusM:Qs,heightM:lM,bottomYM:id,overallSpeed:cM,color:dM,opacity:.85,visibleCount:Jo(nd,this.weather.precipitationIntensity),speedStreak:mM(e),pixelSize:hd,seed:9001,nearFocusDistanceM:od,hazeDistanceM:Qs*ld,hazeColor:new xe(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=Zo,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const e=Qo(4242),t=new Float32Array(vs*3),n=new Float32Array(vs),s=new Float32Array(vs),r=new Float32Array(vs);for(let h=0;h<vs;h++){const u=e()*Math.PI*2,d=Math.sqrt(e())*Qs;t[h*3]=Math.cos(u)*d,t[h*3+1]=id,t[h*3+2]=Math.sin(u)*d,s[h]=ca(rd,ad),n[h]=e()*s[h],r[h]=n[h]/s[h]}const a=new yt;a.setAttribute("position",new ct(t,3));const o=new ct(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,Jo(vs,this.weather.precipitationIntensity));const l=new Ft({uniforms:{uMaxSize:{value:gM},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:vM},uTexture:{value:CM()}},vertexShader:DM,fragmentShader:PM,transparent:!0,depthWrite:!1}),c=new xa(a,l);c.renderOrder=Zo,this.scene.add(c),this.rainSplashSystem={points:c,positions:t,life:n,duration:s,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}updateRain(e){const t=this.rainSystem;if(!t)return;t.uniforms.uTime.value+=e,t.uniforms.uHazeColor.value.setRGB(...this.baseFogColor);const n=this.weather.windDirectionDeg*gn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=Qs,o=c=>(c%(a*2)+a*3)%(a*2)-a;t.uniforms.uWindOffset.value.set(o(t.uniforms.uWindOffset.value.x+s*e),o(t.uniforms.uWindOffset.value.y+r*e)),this.camera.getWorldDirection(this.rainCameraDirection);const l=Math.abs(this.rainCameraDirection.y);if(Math.abs(l-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=l;const c=ud+(1-ud)*(1-l),h=dd+(1-dd)*(1-l);t.uniforms.uUvSquash.value=h,t.uniforms.uPixelSize.value=hd*c*(.5+.5*h)}this.updateRainSplashes(e)}updateRainSplashes(e){const t=this.rainSplashSystem;if(!t||e<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=t,o=a.array;for(let l=0,c=0;l<n.length;l+=3,c++){if(s[c]+=e,s[c]>=r[c]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*Qs;n[l]=Math.cos(h)*u,n[l+2]=Math.sin(h)*u,r[c]=ca(rd,ad),s[c]=0}o[c]=s[c]/r[c]}t.points.geometry.attributes.position.needsUpdate=!0,a.needsUpdate=!0}updateLightning(e,t){if(this.lightningArmed){if(this.lightningFlashRemainingS>0){this.lightningFlashRemainingS=Math.max(0,this.lightningFlashRemainingS-t);const n=this.lightningFlashRemainingS/gd;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=e+ca(pd,md);return}e>=this.nextLightningAtS&&(this.lightningFlashRemainingS=gd,this.nextLightningAtS=e+ca(pd,md),this.onLightningFlash?.())}}buildCompassLabels(){const e=ka(navigator.languages,j3),t=Q3[e];this.compassSprites=J3.map((n,s)=>{const r=t[s],a=new er({map:FM(r),depthTest:!1,fog:!1}),o=new Nr(a),{x:l,y:c,z:h}=cn(0,n,eM);return o.position.set(l,c,h),o.scale.set(Ju,Ju,1),o.renderOrder=tM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o})}disposeCompassLabels(){for(const e of this.compassSprites)e.removeFromParent(),e.material.map?.dispose(),e.material.dispose();this.compassSprites=[]}disposeStarTiers(){for(const e of this.starTiers)this.disposeMesh(e.points);this.starTiers=[]}disposeMesh(e){if(!e)return;e.removeFromParent(),"geometry"in e&&e.geometry.dispose();const t=e.material;for(const n of Array.isArray(t)?t:[t]){const s=n.map;s&&s.dispose(),n.dispose()}}}const gn=Math.PI/180;function K0(i,e,t){return Math.max(e,Math.min(t,i))}function ca(i,e){return i+Math.random()*(e-i)}function ha(i,e){return(i%(e*2)+e*3)%(e*2)-e}let ua,da;function AM(i){switch(i){case"snow":return TM();case"hail":return RM()}}function TM(){if(ua)return ua;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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)"),t.fillStyle=n,t.fillRect(0,0,i,i),ua=new jn(e),ua}function RM(){if(da)return da;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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)"),t.fillStyle=n,t.fillRect(0,0,i,i),da=new jn(e),da}let fa;function CM(){if(fa)return fa;const i=64,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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)"),t.fillStyle=n,t.fillRect(0,0,i,i),fa=new jn(e),fa}const DM=`
|
|
5481
|
+
`,transparent:!0,blending:Ri,depthWrite:!1,side:Ce,fog:!1}),this.object=new se(new Cn(Fn.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,s,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(s[0],s[1],s[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)<Fn.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=Fn.FIRST_GLIMPSE_RAYS,this.scheduleWork())}pendingAltitudeDeg=Number.NaN;pendingAlignment=Number.NaN;tracingFor(t,e){return this.tracing&&Math.abs(t-this.pendingAltitudeDeg)<Fn.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(Fn.RAYS_PER_FRAME);const e=this.sky.tracedRays>=Fn.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,s=0;s<e.length;n+=4,s+=3)this.texels[n]=Us.toHalfFloat(e[s]),this.texels[n+1]=Us.toHalfFloat(e[s+1]),this.texels[n+2]=Us.toHalfFloat(e[s+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 Se{static BINS=1800;static SOURCE_RADIUS_DEG=.265;static FULL_UNTIL_DEG=60;static FADED_BY_DEG=90;static IMPACT_STEPS=4096;drop=new Bs;previous=Se.emergences();current=Se.emergences();tally=new Float32Array(Se.BINS*3);radiance=new Float32Array(Se.BINS*3);scratch=new Float32Array(Se.BINS*3);static emergences(){return Array.from({length:Bs.MAX_CHORDS+1},()=>({chords:0,scatteringAngle:0,weight:0}))}compute(){this.tally.fill(0);for(const t of An.SAMPLES)this.sweep(t);return this.toRadiance(),this.blurBySourceDisc(),{bins:Se.BINS,data:this.radiance,binDeg:180/Se.BINS}}sweep(t){this.drop.refractiveIndex=Oe.indexAt(t.wavelengthNm);const e=Se.IMPACT_STEPS;let n=this.drop.trace(0,this.previous);const s=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*s,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,s){if(n<=0)return;const r=Se.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,s);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,s)}}add(t,e,n){const s=t*3,r=e*An.SAMPLES.length;this.tally[s]+=r*n.r,this.tally[s+1]+=r*n.g,this.tally[s+2]+=r*n.b}toRadiance(){const t=Se.BINS,e=Math.PI/t;for(let n=0;n<t;n++){const s=2*Math.PI*(Math.cos(n*e)-Math.cos((n+1)*e)),r=s>0?this.backwardShare((n+.5)*(180/t))/s: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<=Se.FULL_UNTIL_DEG)return 1;if(e>=Se.FADED_BY_DEG)return 0;const n=(e-Se.FULL_UNTIL_DEG)/(Se.FADED_BY_DEG-Se.FULL_UNTIL_DEG);return Math.cos(n*Math.PI/2)**2}blurBySourceDisc(){const t=Se.BINS,e=Se.SOURCE_RADIUS_DEG*t/180,n=Math.max(1,Math.ceil(e)),s=[];let r=0;for(let a=-n;a<=n;a++){const o=Math.max(0,e*e-a*a),c=Math.sqrt(o);s.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=s[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 vr{static RADIUS=880;static GAIN=.15;static MOON_SATURATION=.15;object;material;sky=new Se;texture;texels;computed=!1;constructor(){this.texels=new Uint16Array(Se.BINS*4),this.texture=new jl(this.texels,Se.BINS,1,un,xn),this.texture.minFilter=Te,this.texture.magFilter=Te,this.texture.wrapS=hn,this.texture.wrapT=hn,this.texture.needsUpdate=!0,this.material=new Be({uniforms:{uSource:{value:new F(0,1,0)},uStrength:{value:0},uTint:{value:new F(1,1,1)},uSaturation:{value:1},uProfile:{value:this.texture},uGain:{value:vr.GAIN}},vertexShader:`
|
|
5482
|
+
varying vec3 vDirection;
|
|
5483
|
+
void main() {
|
|
5484
|
+
vDirection = normalize((modelMatrix * vec4(position, 1.0)).xyz - cameraPosition);
|
|
5485
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
|
5486
|
+
}
|
|
5487
|
+
`,fragmentShader:`
|
|
5488
|
+
precision highp float;
|
|
5489
|
+
varying vec3 vDirection;
|
|
5490
|
+
uniform vec3 uSource;
|
|
5491
|
+
uniform float uStrength;
|
|
5492
|
+
uniform vec3 uTint;
|
|
5493
|
+
uniform float uSaturation;
|
|
5494
|
+
uniform sampler2D uProfile;
|
|
5495
|
+
uniform float uGain;
|
|
5496
|
+
|
|
5497
|
+
void main() {
|
|
5498
|
+
vec3 dir = normalize(vDirection);
|
|
5499
|
+
// How far round from the source this line of sight is, which is the only thing a drop
|
|
5500
|
+
// cares about. Zero is straight at the source and half a turn is straight away from it —
|
|
5501
|
+
// the antisolar point, the centre every bow is drawn around.
|
|
5502
|
+
float scattering = acos(clamp(dot(dir, normalize(uSource)), -1.0, 1.0));
|
|
5503
|
+
vec3 light = texture2D(uProfile, vec2(scattering / 3.14159265, 0.5)).rgb * uGain * uTint;
|
|
5504
|
+
// Colour that the eye could not have resolved is taken back out — see MOON_SATURATION.
|
|
5505
|
+
float grey = dot(light, vec3(0.2126, 0.7152, 0.0722));
|
|
5506
|
+
light = mix(vec3(grey), light, uSaturation);
|
|
5507
|
+
gl_FragColor = vec4(light * uStrength, 1.0);
|
|
5508
|
+
}
|
|
5509
|
+
`,transparent:!0,blending:Ri,depthWrite:!1,side:Ce,fog:!1}),this.object=new se(new Cn(vr.RADIUS,64,32),this.material),this.object.renderOrder=-1,this.object.frustumCulled=!1,this.object.visible=!1}update(t,e,n,s){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=s?1:vr.MOON_SATURATION,this.object.visible=!0}publish(){const e=this.sky.compute().data;for(let n=0,s=0;s<e.length;n+=4,s+=3)this.texels[n]=Us.toHalfFloat(e[s]),this.texels[n+1]=Us.toHalfFloat(e[s+1]),this.texels[n+2]=Us.toHalfFloat(e[s+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 tf{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 Ki{static MIN_DURATION_MS=250;static MAX_DURATION_MS=1400;static schedule(t){const{ratePerHour:e,durationMs:n,velocityKmS:s,seed:r}=t;if(e<=0||n<=0)return[];const a=e*n/36e5,o=new tf(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,(s-20)/52)),f=Ki.MAX_DURATION_MS-d*(Ki.MAX_DURATION_MS-Ki.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((x,m)=>x.t-m.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 Fe{static MAX_CONCURRENT=24;static POINTS=8;static SEGMENTS=Fe.POINTS-1;static ACROSS=3;static VERTICES_PER_SEGMENT=(Fe.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=Fe.MAX_CONCURRENT*Fe.SEGMENTS*Fe.VERTICES_PER_SEGMENT;this.positions=new Float32Array(t*3),this.colors=new Float32Array(t*3);const e=new Ee;e.setAttribute("position",new le(this.positions,3)),e.setAttribute("color",new le(this.colors,3)),e.setDrawRange(0,0),this.object=new se(e,new Ji({vertexColors:!0,transparent:!0,blending:Ri,depthWrite:!1,fog:!1,side:wn})),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=Ki.aliveAt(this.meteors,t).slice(0,Fe.MAX_CONCURRENT);let s=0;for(const{meteor:r,progress:a}of n){const o=this.radiantOf(r);if(!o)continue;const c=an(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),x=(.15+.85*r.brightness)*f,m=A=>x*A**1.6,p=A=>this.onSphere(c,g,d+(u-d)*A),w=A=>Fe.RADIUS*((Fe.MIN_HALF_WIDTH_DEG+Fe.BRIGHT_HALF_WIDTH_DEG*r.brightness*A)*Math.PI/180);for(let A=1;A<Fe.POINTS;A++){const M=(A-1)/Fe.SEGMENTS,S=A/Fe.SEGMENTS;s=this.pushRibbon(s,p(M),p(S),w(M),w(S),m(M),m(S))}}e.setDrawRange(0,s),e.getAttribute("position").needsUpdate=!0,e.getAttribute("color").needsUpdate=!0}midpointOf(t){const e=this.radiantOf(t);if(!e)return;const n=an(e.altitudeDeg,e.azimuthDeg,1),[s,r]=this.basisAround(n),a=this.turn(s,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,s,r,a,o){const c=this.normalise(this.cross(this.normalise(e),this.normalise(this.subtract(n,e))));for(let l=0;l<Fe.ACROSS-1;l++){const h=l-1,u=l,d=this.across(e,c,s,h),f=this.across(n,c,r,h),g=this.across(e,c,s,u),x=this.across(n,c,r,u),m=(p,w)=>p===0?w:0;t=this.push(t,d,m(h,a)),t=this.push(t,f,m(h,o)),t=this.push(t,g,m(u,a)),t=this.push(t,f,m(h,o)),t=this.push(t,x,m(u,o)),t=this.push(t,g,m(u,a))}return t}across(t,e,n,s){return{x:t.x+e.x*n*s,y:t.y+e.y*n*s,z:t.z+e.z*n*s}}push(t,e,n){const s=t*3;this.positions[s]=e.x,this.positions[s+1]=e.y,this.positions[s+2]=e.z;const r=Math.max(0,Math.min(1,n));return this.colors[s]=r*.9,this.colors[s+1]=r*.95,this.colors[s+2]=r,t+1}turn(t,e,n){const s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);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 s=n*Math.PI/180,r=Math.cos(s),a=Math.sin(s);return{x:(t.x*r+e.x*a)*Fe.RADIUS,y:(t.y*r+e.y*a)*Fe.RADIUS,z:(t.z*r+e.z*a)*Fe.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 V3=2;function W3(i){return i==="building"||i==="vehicle"}function X3(i,t){const e=i.litKeyframes;if(!e||e.length===0)return i.lit??!1;let n=e[0];for(const s of e){if(s.t>t)break;n=s}return n.lit}function q3(i,t){return i.pattern.kind==="steady"?!0:Y3(i,t,t+1)>.5}function Y3(i,t,e){if(i.pattern.kind==="steady")return 1;const{perMinute:n,dutyCycle:s,phase:r=0}=i.pattern,a=Math.min(Math.max(s,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 K3(i,t){const e=i.track,n={eastM:i.eastM,northM:i.northM,altitudeM:0,headingDeg:i.headingDeg};if(!e||e.length===0)return n;if(e.length===1||t<=e[0].t)return nd(e[0],i);const s=e[e.length-1];if(t>=s.t)return nd(s,i);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??i.headingDeg}}return n}function nd(i,t){return{eastM:i.eastM,northM:i.northM,altitudeM:i.altitudeM??0,headingDeg:i.headingDeg??t.headingDeg}}const id=Math.PI/180;function Xe(i,t,e,n,s=!1){const r=s?new Ji({color:new Mt(...e)}):new Ar({color:new Mt(...e)}),a=new se(t,r);return a.position.y=n,a.userData={emissive:s},a.castShadow=!s,a.receiveShadow=!s,i.add(a),a}const sd=.25,Z3=.002;function $3(i){const t=/^#([0-9a-f]{6})$/i.exec(i);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 ef=[.32,.32,.3],nf=[1,.85,.5],sf=[.25,.25,.25],rf=[1,.97,.85],J3=[.55,.68,.72],zn=.03,Bn=.05,af={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 Ze(i,t){return i?.[t]}function kn(i,t,e,n,s,r,a,o){if(o===void 0)return;const c=new Ar({color:new Mt(...J3),transparent:!0,opacity:o/100}),l=new se(new Mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}const mn=.05,ic=[.6,.58,.53],rd=[.5,.5,.48];function Ds(i,t,e,n,s,r,a,o){const c=new Ar({color:new Mt(...o),side:Ce}),l=new se(new Mn(t,e,n),c);l.position.set(s,r,a),i.add(l)}function Q3(i,t,e,n,s,r,a,o,c){const l=(n-r)/2,h=(g,x,m,p)=>{g<=0||(t?Ds(i,g,x,mn,m,o+p,a,c):Ds(i,mn,x,g,a,o+p,m,c))};h(e,l,0,n/2-l/2),h(e,l,0,-(n/2-l/2));const u=[...s].sort((g,x)=>g.center-x.center);let d=-e/2;for(const g of u){const m=g.center-g.main/2-d;h(m,r,d+m/2,0),d=g.center+g.main/2}const f=e/2-d;h(f,r,d+f/2,0)}function of(i,t,e,n,s,r,a,o,c,l){const h=(n+s)/2,u=s-n,d=(f,g,x,m)=>{f.length===0?g?Ds(i,x,u,mn,0,h,m,ic):Ds(i,mn,u,x,m,h,0,ic):Q3(i,g,x,u,f,r,m,h,ic)};d(a,!0,t*2,-e+mn),d(o,!0,t*2,e-mn),d(c,!1,e*2,-t+mn),d(l,!1,e*2,t-mn),Ds(i,t*2,mn,e*2,0,n+mn,0,rd),Ds(i,t*2,mn,e*2,0,s-mn,0,rd)}function Ll(i,t,e,n){switch(i){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:-Gn};case"front-right":return{x:t-n,z:-Gn};case"behind-left":return{x:-(t-n),z:Gn};case"behind-right":return{x:t-n,z:Gn}}}function cf(i,t,e,n,s,r,a){const o=uf();o.scale.setScalar(n),o.rotation.y=af[t];const{x:c,z:l}=Ll(t,s,r,a);o.position.set(c,e,l),i.add(o)}const Nl=6,Ul=6,yi=3,ar=1.4,or=yi*.5,lf=1.2,hf=.35,j3=.75,tM=1.6;function eM(i,t,e,n){const s=new Tn,r=Math.max(1,i+1),a=r*yi;Xe(s,new Mn(Nl,a,Ul),[.55,.54,.5],a/2);const o=Nl/2,c=Ul/2;for(let l=0;l<r;l++){const h=l*yi+yi/2;kn(s,ar,or,Bn,0,h,-c-zn,Ze(t,"front")),kn(s,ar,or,Bn,0,h,c+zn,Ze(t,"behind")),kn(s,Bn,or,ar,-o-zn,h,0,Ze(t,"left")),kn(s,Bn,or,ar,o+zn,h,0,Ze(t,"right"))}if(e){const l=Math.min(Math.max(n??0,0),r-1);cf(s,e,l*yi,.72,o,c,lf);const h=u=>Ze(t,u)!==void 0?[{main:ar,center:0}]:[];of(s,o,c,l*yi,(l+1)*yi,or,h("front"),h("behind"),h("left"),h("right"))}return s}function nM(){const i=new Tn;return Xe(i,new Pi(.15,.22,2,8),[.32,.22,.14],1),Xe(i,new no(1.4,3,8),[.16,.32,.14],3.5),i}function iM(i){const t=new Tn;return Xe(t,new Pi(.05,.08,5,8),[.28,.28,.3],2.5),Xe(t,new Cn(.25,12,8),i?nf:ef,5.1,!0),t}const sM=[.08,.08,.08],Mi=.8,As=1,Un=1.7,sc=.6,zi=.4,va=1.2,Es=.7,Gn=.5,rM=Un;function aM(i,t,e){const n=new Tn;Xe(n,new Mn(1.8,1.4,4.2),[.45,.14,.14],.7),Xe(n,new Mn(Mi*2,sc,As*2),[.4,.12,.12],Un);for(const r of[-1.4,1.4])for(const a of[-.95,.95]){const o=Xe(n,new Pi(.4,.4,.3,12),sM,.4);o.rotation.z=Math.PI/2,o.position.x=a,o.position.z=r}const s=i?rf:sf;for(const r of[-.7,.7])Xe(n,new Cn(.15,8,6),s,.7,!0).position.set(r,.7,-2.1);if(kn(n,va,zi,Bn,0,Un,-As-zn,Ze(t,"front")),kn(n,va,zi,Bn,0,Un,As+zn,Ze(t,"behind")),kn(n,Bn,zi,Es,-Mi-zn,Un,-Gn,Ze(t,"front-left")),kn(n,Bn,zi,Es,-Mi-zn,Un,Gn,Ze(t,"behind-left")),kn(n,Bn,zi,Es,Mi+zn,Un,-Gn,Ze(t,"front-right")),kn(n,Bn,zi,Es,Mi+zn,Un,Gn,Ze(t,"behind-right")),e){cf(n,e,j3,.5,Mi,As,hf);const r=(c,l)=>{const h=[];return Ze(t,c)!==void 0&&h.push({main:Es,center:-Gn}),Ze(t,l)!==void 0&&h.push({main:Es,center:Gn}),h},a=Ze(t,"front")!==void 0?[{main:va,center:0}]:[],o=Ze(t,"behind")!==void 0?[{main:va,center:0}]:[];of(n,Mi,As,Un-sc/2,Un+sc/2,zi,a,o,r("front-left","behind-left"),r("front-right","behind-right"))}return n}const oM=[.95,.9,.82];function uf(){const i=new Tn;Xe(i,new Pi(.25,.3,1.5,10),[.3,.3,.35],.75),Xe(i,new Cn(.22,10,8),[.62,.52,.46],1.72);const t=Xe(i,new no(.07,.16,8),oM,1.72);return t.rotation.x=-Math.PI/2,t.position.z=-.2,i}const cM=17,ad=18.5,rc=[.16,.16,.18];function lM(){const i=new Tn,t=Xe(i,new Pi(1.8,1.8,ad*2,10),rc,0);t.rotation.x=Math.PI/2,Xe(i,new Mn(cM*2,.5,4.5),rc,0);const e=Xe(i,new Mn(.4,5.5,4),rc,3);return e.position.z=-ad+2,i}class bs{static occupantView(t){const e=t.witnessSide;if(!e)throw new Error("occupantView requires object.witnessSide to be set");const{x:n,z:s}=t.kind==="vehicle"?Ll(e,Mi,As,hf):Ll(e,Nl/2,Ul/2,lf),r=t.kind==="vehicle"?rM:(t.occupiedFloor??0)*yi+tM,a=(t.headingDeg??0)-af[e]/id;return{x:n,z:s,eyeY:r,headingDeg:a}}static build(t,e){const n=t.kind==="building"?eM(t.floors??V3,t.windows,t.witnessSide,t.occupiedFloor):t.kind==="tree"?nM():t.kind==="streetlight"?iM(e):t.kind==="vehicle"?aM(e,t.windows,t.witnessSide):t.kind==="aircraft"?lM():uf();return t.headingDeg!==void 0&&(n.rotation.y=-t.headingDeg*id),this.addLights(n,t.lights),t.kind==="aircraft"&&this.exemptFromFog(n),n}static exemptFromFog(t){for(const e of t.children){if(!(e instanceof se))continue;const n=e.material;n.fog=!1,n.needsUpdate=!0}}static addLights(t,e){for(const n of e??[]){const s=Xe(t,new Cn(sd,8,6),$3(n.color),n.offsetM.y,!0);s.position.set(n.offsetM.x,n.offsetM.y,n.offsetM.z),s.userData={emissive:!0,lightId:n.id},s.visible=!1}}static setLights(t,e,n,s){if(!e||e.length===0)return;const r=new Map(e.map(o=>[o.id,o])),a=Math.max(1,s*Z3/sd);for(const o of t.children){if(!(o instanceof se))continue;const c=o.userData.lightId;if(!c)continue;const l=r.get(c);l&&(o.visible=q3(l,n),o.scale.setScalar(a*(l.intensity??1)**.5))}}static setLit(t,e,n){const s=e==="streetlight"?n?nf:ef:n?rf:sf;for(const r of t.children){const a=r.userData;!(r instanceof se)||!a.emissive||a.lightId||r.material.color.setRGB(...s)}}static dispose(t){for(const e of t.children)e instanceof se&&(e.geometry.dispose(),e.material.dispose())}}function hM(i,t){return i.cloudCover===t.cloudCover&&i.cloudDarkness===t.cloudDarkness&&i.cloudBaseM===t.cloudBaseM&&i.highCloudCover===t.highCloudCover&&i.iceCrystalAlignment===t.iceCrystalAlignment&&i.lowerCloudCover===t.lowerCloudCover&&i.precipitationType===t.precipitationType&&i.precipitationIntensity===t.precipitationIntensity&&i.windDirectionDeg===t.windDirectionDeg&&i.windSpeed===t.windSpeed&&i.storm===t.storm}const _a=900,od=.5,pr=900,uM=6371e3,dM=3e4;function cd(i){const t=Math.sqrt(2*uM*Math.max(i,0));return Math.max(pr,Math.min(t,dM))}const ac=.5,fM=850,xa=850,oc=4,ld=1.5,pM=-1,mM=6,Fl=-4,hd=.2,Ma=2600,gM=.97,vM=.38,ud=Fl,_M=3,xM=.15,MM=.6,yM=40,SM=30,EM=[0,45,90,135,180,225,270,315],bM={en:["N","NE","E","SE","S","SW","W","NW"],fr:["N","NE","E","SE","S","SO","O","NO"]},wM=["en","fr"],AM=880,dd=40,TM=10,RM=1,CM=150,DM=55,PM=.5,IM=2.05,fd=.265,pd=[[0,0],...Array.from({length:8},(i,t)=>{const e=t*Math.PI/4;return[Math.cos(e)*fd,Math.sin(e)*fd]})],md=700,LM=250/Fd,NM=12,gd=5,cc=6,Bi=[.92,.92,.95],lc=[.15,.15,.19],vd={snow:{fallSpeedMPerS:2,size:.3,color:new Mt(1,1,1),driftSensitivity:1,radiusM:25,topYM:20,opacity:.75,poolSize:2400},hail:{fallSpeedMPerS:14,size:.5,color:new Mt(.95,.98,1),driftSensitivity:.25,radiusM:25,topYM:10,opacity:.95,poolSize:1200}},Ts=0,UM=0,_d=3e3,cr=20,FM=15,xd=Ts,OM=40,Md=1,zM=9;function BM(i){return Md+(zM-Md)*i}const kM=new Mt(.75,.82,.92),GM=10,HM=.5;function VM(i){return df(i/GM,HM,1)}const ws=200,yd=.18,Sd=.32,WM=.35,XM=new Mt(.85,.9,.98),Ed=5,bd=.85,wd=.01;function hc(i,t){return Math.round(i*(wd+(1-wd)*t))}const Ad=230,Td=.7,Rd=.05,qM=.6,YM=.7,KM=.15,Cd=.35,ZM=3,$M=1/12,JM=.5,Dd=8,Pd=25,Id=.12,QM={Venus:new Mt(1,.96,.85),Mars:new Mt(1,.55,.4),Jupiter:new Mt(.95,.87,.72),Saturn:new Mt(.92,.86,.68)};class jM{renderer;scene=new o0;camera;celestialGroup=new Tn;skyMesh;groundMesh;terrainMesh;terrainProviders;terrainOrigin;terrainBuildToken=0;terrainAttribution;starTiers=[];bodyMeshes=new Map;hitAreas=new Map;glareSprites=new Map;decorObjects=[];decorGroups=new Map;celestialLight=new Um(16777215,0);celestialLightTarget=new Re;skyLight=new Pm(16777215,0,0);streetlightLights=new Map;compassSprites=[];showCompass=!1;compassHovered=!1;compassForced=!1;animationFrameId=null;raycaster=new Ho;weather=Od;observerElevationM=0;groundRadius=pr;terrainRadius=pr;cloudMesh;cirrusMesh;cirrusMaterial;cirrusUniforms;cloudMaterial;cloudUniforms;precipitationPoints;precipitationPositions;precipitationPhase;precipitationSpeedJitter;precipitationWobbleFreqJitter;precipitationWobbleAmpJitter;precipitationBounceRemaining;precipitationBounceHeight;precipitationBounceDuration;precipitationBounceVelX;precipitationBounceVelZ;precipitationUniforms;rainSystem;rainSplashSystem;rainCameraDirection=new F;rainLastVerticalFacing=-1;lightningArmed=!1;nextLightningAtS=null;lightningFlashRemainingS=0;baseFogColor=[0,0,0];lastSunPosition;lensFlare;sunCloudTransmission=1;sunUnhiddenFraction=1;lensFlareArtifactIntensity=0;sunWorldPosition=new F;sunVisible=!1;lensFlareScratch=new F;sunOcclusionRaycaster=new Ho;sunOcclusionDirectionScratch=new F;sunOcclusionRightScratch=new F;sunOcclusionUpScratch=new F;ufoOcclusionRaycaster=new Ho;projectionKind="rectilinear";starPoints=0;equidistantPass;meteorSystem;cometTail;iceHalos;rainbow;cometKey;onLightningFlash;constructor(t,e=x3(),n){this.renderer=new L_({canvas:t,antialias:!0}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),this.renderer.shadowMap.enabled=!0,this.renderer.shadowMap.type=gr,this.camera=new cn(60,t.width/Math.max(t.height,1),.1,_a*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){t.headingDeg!==void 0?this.camera.rotation.set(t.pitchDeg*bn,-t.headingDeg*bn,0,"YXZ"):this.camera.rotation.set(t.pitchDeg*bn,this.camera.rotation.y,0,"YXZ"),t.elevationM!==this.observerElevationM&&(this.observerElevationM=t.elevationM,this.syncCloudLayer(),Math.abs(cd(t.elevationM)-this.groundRadius)>1&&(this.buildGround(),this.celestialGroup.scale.setScalar(this.groundRadius/pr),this.camera.far=Math.max(_a*1.2,this.groundRadius*2.5),this.camera.updateProjectionMatrix())),this.camera.position.y=1.6+t.elevationM,this.celestialGroup.position.y=this.camera.position.y,this.camera.fov!==t.fovDeg&&(this.camera.fov=t.fovDeg,this.camera.updateProjectionMatrix())}setTerrainProviders(t){this.terrainProviders=t,this.disposeMesh(this.terrainMesh),this.terrainMesh=void 0,this.terrainOrigin=void 0,this.terrainAttribution=void 0,this.terrainBuildToken++}setTerrainOrigin(t,e,n){if(t===void 0||e===void 0)return;const s=this.groundRadius;if(this.terrainOrigin&&Math.abs(this.terrainRadius-s)<s*.1){const{x:a,z:o}=ji(t,e,this.terrainOrigin.lat,this.terrainOrigin.lng);if(Math.sqrt(a*a+o*o)<CM*(s/pr))return}this.terrainOrigin={lat:t,lng:e},this.terrainRadius=s;const r=++this.terrainBuildToken;w3(t,e,this.terrainProviders,s).then(({mesh:a,attribution:o})=>{r===this.terrainBuildToken&&(this.disposeMesh(this.terrainMesh),a.renderOrder=RM,this.terrainMesh=a,this.terrainAttribution=o,this.scene.add(a),this.render(),n?.())}).catch(a=>{console.warn("Terrain build failed, keeping the flat ground fallback:",a),n?.()})}setShowCompass(t){this.showCompass!==t&&(this.showCompass=t,this.disposeCompassLabels(),t&&this.buildCompassLabels(),this.render())}setLensFlareArtifactIntensity(t){this.lensFlareArtifactIntensity!==t&&(this.lensFlareArtifactIntensity=t,this.lensFlare&&(this.lensFlare.uniforms.uFlareIntensity.value=t),this.render())}applyLensFlareTint(t){if(!this.lensFlare)return;const e=DM*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=nx(t)*this.sunCloudTransmission*this.sunUnhiddenFraction,n=Oi(t);this.lensFlare.uniforms.uDazzleColour.value.setRGB(n[0],n[1],n[2]),this.lensFlare.uniforms.uVeilStrength.value=IM**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){hM(this.weather,t)||(this.weather=t,this.buildClouds(),this.buildCirrus(),this.buildPrecipitation(),this.lightningArmed=t.storm&&t.cloudDarkness>=JM,this.lightningArmed||(this.nextLightningAtS=null,this.lightningFlashRemainingS=0,this.restoreFogColor()),this.syncAnimationLoop(),this.render())}setDecor(t){if(this.decorObjects!==t){this.decorObjects=t;for(const e of this.decorGroups.values())e.removeFromParent(),bs.dispose(e);this.decorGroups.clear(),this.streetlightLights.clear();for(const e of t){const n=bs.build(e,e.lit??!1);this.scene.add(n),this.decorGroups.set(e.id,n),e.kind==="streetlight"&&this.addStreetlightLight(e.id,n)}this.celestialLight.castShadow=this.decorGroups.size>0}}updateDecorAnchoring(t,e,n=0){const s=t?.lat!==void 0&&t.lng!==void 0&&e?.lat!==void 0&&e?.lng!==void 0?ji(t.lat,t.lng,e.lat,e.lng):{x:0,z:0},r=this.decorObjects.find(l=>l.witnessSide!==void 0&&W3(l.kind)),a={x:0,z:0};let o=0;if(r){const l=bs.occupantView(r),h=-(r.headingDeg??0)*bn,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+s.x,g=-r.northM+s.z;a.x=-(f+u),a.z=-(g+d),this.camera.position.y=l.eyeY,this.camera.rotation.set(this.indoorLookPitchDeg*bn,-(l.headingDeg+this.indoorLookYawDeg)*bn,0,"YXZ")}for(const l of this.decorObjects){const h=this.decorGroups.get(l.id);if(!h)continue;const u=K3(l,n);h.position.set(u.eastM+s.x+a.x,UM+u.altitudeM,-u.northM+s.z+a.z),u.headingDeg!==void 0&&(h.rotation.y=-u.headingDeg*bn),o=Math.max(o,h.position.distanceTo(this.camera.position))}const c=Math.max(_a*1.2,this.groundRadius*2.5,o*1.2);Math.abs(this.camera.far-c)>1&&(this.camera.far=c,this.camera.updateProjectionMatrix())}indoorLookYawDeg=0;indoorLookPitchDeg=0;setIndoorLook(t,e){this.indoorLookYawDeg=t,this.indoorLookPitchDeg=e}updateDecorLitState(t){for(const e of this.decorObjects){const n=this.decorGroups.get(e.id);if(n&&e.lights?.length&&bs.setLights(n,e.lights,t,n.position.distanceTo(this.camera.position)),e.kind!=="streetlight"&&e.kind!=="vehicle")continue;const s=this.decorGroups.get(e.id);if(!s)continue;const r=X3(e,t);bs.setLit(s,e.kind,r);const a=this.streetlightLights.get(e.id);a&&(a.visible=r)}}addStreetlightLight(t,e){const n=e.children.find(r=>r.userData.emissive);if(!n)return;const s=new Lm(16764006,yM,SM);s.position.copy(n.position),s.castShadow=!0,s.shadow.mapSize.set(512,512),s.shadow.bias=-.002,e.add(s),this.streetlightLights.set(t,s)}setAstronomy(t){const e=fl(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),this.buildStars(t.stars,t.sun.altitudeDeg);const s=zu(t.sun.altitudeDeg);this.setBodyMesh("sun",t.sun,oc,new Mt(1,.96,.88),t.sun.magnitude),this.setMoonMesh(t.moon,s),this.buildPlanets(t.planets,s),this.buildComet(t.comet,s),this.buildIceHalos(t.sun,t.moon),this.buildRainbow(t.sun,t.moon),this.scene.fog=new Jl(new Mt(...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=MM;const s=t.sun.altitudeDeg>=ud,r=!s&&t.moon.altitudeDeg>=ud;if(!s&&!r){this.celestialLight.intensity=0;return}const a=s?t.sun:t.moon,{x:o,y:c,z:l}=an(a.altitudeDeg,a.azimuthDeg,xa);this.celestialLight.position.set(o,c,l);const h=Oi(a.altitudeDeg);this.celestialLight.color.setRGB(h[0],h[1],h[2]);const u=Math.max(0,Math.sin(Math.max(a.altitudeDeg,0)*bn));this.celestialLight.intensity=(s?_M:xM)*u,this.celestialLight.castShadow=this.decorGroups.size>0}setMeteorShower(t,e,n){this.meteorSystem||(this.meteorSystem=new Fe,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=zd.starPointsOf(t);e!==this.starPoints&&(this.starPoints=e,this.lensFlare&&(this.lensFlare.uniforms.uStarPoints.value=e))}render(){const t=this.usableEquidistantPass();if(!t){this.updateLensFlarePosition(),this.renderer.render(this.scene,this.camera);return}t.render(this.renderer,this.scene,this.camera,this.camera.fov,()=>this.updateLensFlarePosition())}usableEquidistantPass(){if(this.projectionKind!=="equidistant")return;const t=this.renderer.getDrawingBufferSize(new Ft);if(Ka.supports(this.camera.fov,t.x/Math.max(t.y,1)))return this.equidistantPass?this.equidistantPass.resize(t.x,t.y):this.equidistantPass=new Ka(t.x,t.y),this.equidistantPass}aimAtScreenPoint(t,e,n){const s=this.projectionKind==="equidistant"?this.equidistantPass:void 0;if(!s){t.setFromCamera(new Ft(e,n),this.camera);return}const r=s.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}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 s=this.renderer.domElement.width,r=this.renderer.domElement.height;t.uniforms.uResolution.value.set(s,r),t.uniforms.uTanHalfFov.value=Math.tan(this.camera.fov*Math.PI/360)}sunVisibleFraction(){let t=0;for(const e of pd)this.isSunOccluded(e[0],e[1])||t++;return t/pd.length}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.decorGroups.values())n.push(o);if(n.length===0)return!1;const s=this.sunOcclusionDirectionScratch.copy(this.sunWorldPosition).sub(this.camera.position),r=s.length();if(s.normalize(),t!==0||e!==0){const o=Math.PI/180,c=this.sunOcclusionRightScratch.set(s.z,0,-s.x);c.lengthSq()<1e-9&&c.set(1,0,0),c.normalize();const l=this.sunOcclusionUpScratch.crossVectors(c,s).normalize();s.addScaledVector(c,t*o).addScaledVector(l,e*o).normalize()}this.sunOcclusionRaycaster.set(this.camera.position,s);const a=this.sunOcclusionRaycaster.intersectObjects(n,!0)[0];return a!==void 0&&a.distance<r}isScreenPointOccluded(t,e,n,s){if(s&&this.cloudMesh&&this.lowerCloudCover()>0)return!0;const r=[];for(const a of this.decorObjects){if(!a.occludesSourceIds?.includes(n))continue;const o=this.decorGroups.get(a.id);o&&r.push(o)}return r.length===0?!1:(this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=od,this.ufoOcclusionRaycaster.intersectObjects(r,!0).length>0)}decorDistancesAt(t,e,n){this.aimAtScreenPoint(this.ufoOcclusionRaycaster,t,e),this.ufoOcclusionRaycaster.near=od;let s,r;for(const a of this.decorObjects){const o=this.decorGroups.get(a.id);if(!o)continue;const c=this.ufoOcclusionRaycaster.intersectObject(o,!0)[0];c&&(a.occludesSourceIds?.includes(n)?s=s===void 0?c.distance:Math.max(s,c.distance):r=r===void 0?c.distance:Math.min(r,c.distance))}return{behindM:s,inFrontM:r}}pickBodyAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.hitAreas.entries()],s=this.raycaster.intersectObjects(n.map(([,r])=>r))[0];if(s)return n.find(([,r])=>r===s.object)?.[0]}pickDecorAt(t,e){this.aimAtScreenPoint(this.raycaster,t,e);const n=[...this.decorGroups.entries()],s=this.raycaster.intersectObjects(n.map(([,a])=>a),!0)[0];if(!s)return;let r=s.object;for(;r&&!n.some(([,a])=>a===r);)r=r.parent;return n.find(([,a])=>a===r)?.[0]}dispose(){this.stopTwinkle(),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.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())bs.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 s=t===void 0?0:Math.min((n-t)/1e3,$M);t=n,this.updateTwinkle(n/1e3),this.updatePrecipitation(n/1e3,s),this.updateRain(s),this.updateLightning(n/1e3,s),this.lensFlare&&(this.lensFlare.uniforms.uTime.value=n/1e3),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 Cn(_a,32,16),n=e.attributes.position,s=[];for(let a=0;a<n.count;a++){const{altitudeDeg:o,azimuthDeg:c}=O_(n.getX(a),n.getY(a),n.getZ(a)),l=X_(o,c,t.azimuthDeg,t.altitudeDeg);s.push(l[0],l[1],l[2])}e.setAttribute("color",new De(s,3));const r=new Ji({vertexColors:!0,side:Ce,fog:!1,depthWrite:!1});this.skyMesh=new se(e,r),this.skyMesh.renderOrder=-1,this.celestialGroup.add(this.skyMesh)}buildGround(){this.disposeMesh(this.groundMesh),this.groundRadius=cd(this.observerElevationM);const t=new eh(this.groundRadius,48),e=new Ar({color:new Mt(ac,ac,ac),fog:!0});this.groundMesh=new se(t,e),this.groundMesh.rotation.x=-Math.PI/2,this.groundMesh.position.y=0,this.groundMesh.receiveShadow=!0,this.scene.add(this.groundMesh)}cloudTransmission(t){const e=an(t.altitudeDeg,t.azimuthDeg,1);let n=1;const s=this.lowerCloudCover();s>0&&(n*=1-Ae.alphaAt(e,Math.abs(this.cloudLayerOffset()),s)*gM);const r=this.weather.highCloudCover??0;return r>0&&(n*=1-Ae.alphaAt(e,Ma,r)*vM),Math.max(0,Math.min(1,n))}setBodyMesh(t,e,n,s,r){if(this.disposeMesh(this.bodyMeshes.get(t)),this.disposeHitArea(t),this.disposeGlare(t),e.altitudeDeg<Fl){this.bodyMeshes.delete(t),t==="sun"&&(this.sunVisible=!1);return}const{x:a,y:o,z:c}=an(e.altitudeDeg,e.azimuthDeg,xa),l=Oi(e.altitudeDeg),h=this.cloudTransmission(e),u=new Mt(s.r*l[0]*h,s.g*l[1]*h,s.b*l[2]*h),d=new Cn(n,16,16),f=new Ji({color:u,fog:!1}),g=new se(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 x=r-2.5*Math.log10(Math.max(h,.001));if(t==="sun"&&(this.sunCloudTransmission=h),t!=="sun"&&this.setGlare(t,a,o,c,x,u),t==="sun"){this.sunVisible=!0;const m=this.celestialGroup.scale.x;this.sunWorldPosition.set(a*m,o*m+this.celestialGroup.position.y,c*m),this.lensFlare||(this.lensFlare=H3(),this.lensFlare.uniforms.uOpacity.value=PM,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<Fl){this.bodyMeshes.delete(n);return}const{x:s,y:r,z:a}=an(t.altitudeDeg,t.azimuthDeg,xa),o=Oi(t.altitudeDeg),c=new Mt(o[0],o[1],o[2]),l=new hr({map:ly(t.phase),color:c,fog:!1}),h=new qr(l);h.position.set(s,r,a);const u=oc*2;h.scale.set(u,u,1),this.celestialGroup.add(h),this.bodyMeshes.set(n,h),this.setHitArea(n,s,r,a,oc),this.setGlare(n,s,r,a,t.magnitude,c)}setHitArea(t,e,n,s,r){const a=new hr({transparent:!0,opacity:0,depthTest:!1,depthWrite:!1,fog:!1}),o=new qr(a);o.position.set(e,n,s);const c=r*mM;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,s,r,a){const o=K_(r);if(o<=0){this.disposeGlare(t);return}const c=J_(o),l=this.glareSprites.get(t),h=l??new qr(new hr({map:cy(),transparent:!0,blending:Ri,depthWrite:!1,fog:!1}));h.material.color.copy(a),h.material.opacity=tx(o),h.position.set(e,n,s),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 s=$o(t.magnitude),r=Jo(s);this.cometKey=n,this.setBodyMesh(n,t.position,ld*(.5+.5*s),new Mt(r,r,r),t.magnitude),this.cometTail||(this.cometTail=new rn(xa),this.celestialGroup.add(this.cometTail.object)),this.cometTail.set(t.position,t.tailEnd,s)}buildIceHalos(t,e){this.iceHalos||(this.iceHalos=new Fn,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:Ma},0);return}const s=this.weather.lowerCloudCover??this.weather.cloudCover,r=$t.deckLitUntilDeg($t.DECK_HEIGHT_M),a=t.altitudeDeg>-r?t:e,o=$t.strength(n,s,a.altitudeDeg,r)*(a===t?1:hd),{x:c,y:l,z:h}=an(a.altitudeDeg,a.azimuthDeg,1),u=Oi(a.altitudeDeg);this.iceHalos.update({x:c,y:l,z:h},a.altitudeDeg,o,[u[0],u[1],u[2]],{cover:n,layerHeight:Ma},this.weather.iceCrystalAlignment??Bf)}buildRainbow(t,e){this.rainbow||(this.rainbow=new vr,this.celestialGroup.add(this.rainbow.object));const n=this.weather.precipitationType==="rain"?this.weather.precipitationIntensity:0,s=t.altitudeDeg>0,r=s?t:e,a=this.weather.lowerCloudCover??this.weather.cloudCover,o=hd*je.moonlightShare(e.magnitude),c=je.strength(n,a,r.altitudeDeg)*(s?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}=an(r.altitudeDeg,r.azimuthDeg,1),d=Oi(r.altitudeDeg);this.rainbow.update({x:l,y:h,z:u},c,[d[0],d[1],d[2]],s)}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 s of t){if(s.magnitude>e)continue;n.add(s.body);const r=$o(s.magnitude),a=Jo(r),o=QM[s.body]??new Mt(1,1,1),c=new Mt(o.r*a,o.g*a,o.b*a),l=ld*(.5+.5*r);this.setBodyMesh(s.body,s.position,l,c,s.magnitude)}for(const s of[...this.bodyMeshes.keys()])n.has(s)||(this.disposeMesh(this.bodyMeshes.get(s)),this.bodyMeshes.delete(s),this.disposeHitArea(s),this.disposeGlare(s))}buildStars(t,e){if(this.disposeStarTiers(),!t||t.catalog.count===0){this.syncAnimationLoop();return}const{catalog:n,date:s,observer:r}=t,a=zu(e),o=uc(1337),c=[];for(let l=0;l<n.count;l++){const h=n.mag[l];if(h>a)continue;const{altitudeDeg:u,azimuthDeg:d}=co(n.ra[l],n.dec[l],s,r);if(u<pM)continue;const{x:f,y:g,z:x}=an(u,d,fM);c.push({x:f,y:g,z:x,brightness:$o(h),phase:o()*Math.PI*2,speedFactor:.7+o()*.6})}this.starTiers=T0.map((l,h)=>{const u=c.filter(M=>sx(M.brightness)===h),d=new Float32Array(u.length*3),f=new Float32Array(u.length),g=new Float32Array(u.length),x=new Float32Array(u.length);u.forEach((M,S)=>{d[S*3]=M.x,d[S*3+1]=M.y,d[S*3+2]=M.z,f[S]=M.brightness,g[S]=M.phase,x[S]=M.speedFactor});const m=new Ee;m.setAttribute("position",new le(d,3));const p=new le(new Float32Array(u.length*3),3);m.setAttribute("color",p);const w=new u0({vertexColors:!0,size:l.size,sizeAttenuation:!1,fog:!1});Wi.apply(w);const A=new Pa(m,w);return this.celestialGroup.add(A),{points:A,colorAttribute:p,brightness:f,phase:g,speedFactor:x}}),this.updateTwinkle(0),this.startTwinkle()}updateTwinkle(t){for(const e of this.starTiers){const n=e.colorAttribute.array;for(let s=0;s<e.brightness.length;s++){const r=ox(e.brightness[s],{phase:e.phase[s],speedFactor:e.speedFactor[s]},t),a=Jo(e.brightness[s])*r;n[s*3]=a,n[s*3+1]=a,n[s*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 Mt(Bi[0]+(lc[0]-Bi[0])*e,Bi[1]+(lc[1]-Bi[1])*e,Bi[2]+(lc[2]-Bi[2])*e),{material:s,uniforms:r}=td(n,t,Math.abs(this.cloudLayerOffset()));this.cloudMaterial=s,this.cloudUniforms=r,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor);const a=ed(md);this.cloudMesh=new se(a,s),this.cloudLayerOffset()<0&&(this.cloudMesh.scale.y=-1),this.cloudMesh.renderOrder=gd,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}=td(new Mt(...Bi),t,Ma,1);this.cirrusMaterial=e,this.cirrusUniforms=n,this.lastSunPosition&&this.updateCloudLighting(this.lastSunPosition,this.baseFogColor),this.cirrusMesh=new se(ed(md*1.04),e),this.cirrusMesh.renderOrder=gd-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??Fd)-this.observerElevationM)*LM;return Math.sign(e||1)*Math.max(Math.abs(e),NM)}updateCloudLighting(t,e){const n=[this.cloudUniforms,this.cirrusUniforms].filter(l=>l!==void 0);if(n.length===0)return;const{x:s,y:r,z:a}=an(t.altitudeDeg,t.azimuthDeg,1),o=Oi(t.altitudeDeg),c=Math.max(0,Math.sin(Math.max(t.altitudeDeg,0)*bn));for(const l of n)l.sunDir.value.set(s,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=vd[t],n=e.poolSize,s=uc(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 A=0;A<n;A++){const M=s()*Math.PI*2,S=s()*e.radiusM;r[A*3]=Math.cos(M)*S,r[A*3+1]=Ts+s()*(e.topYM-Ts),r[A*3+2]=Math.sin(M)*S,a[A]=s()*Math.PI*2,o[A]=.7+s()*.6,c[A]=.6+s()*.8,l[A]=.4+s()*1.2}const x=new Ee;x.setAttribute("position",new le(r,3)),x.setDrawRange(0,hc(n,this.weather.precipitationIntensity));const m={uSize:{value:e.size},uScale:{value:.5*this.renderer.domElement.height},uOpacity:{value:e.opacity},uColor:{value:e.color},uHazeColor:{value:new Mt(...this.baseFogColor)},uTexture:{value:ty(t)},uNearFocusDistance:{value:Ed},uHazeDistance:{value:e.radiusM*bd}},p=new Be({uniforms:m,vertexShader:ay,fragmentShader:oy,transparent:!0,depthWrite:!1});this.precipitationUniforms=m;const w=new Pa(x,p);w.renderOrder=cc,this.scene.add(w),this.precipitationPoints=w,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 s=vd[n],r=this.weather.windDirectionDeg*bn,a=Math.sin(r)*this.weather.windSpeed*s.driftSensitivity,o=-Math.cos(r)*this.weather.windSpeed*s.driftSensitivity,c=this.precipitationPositions,l=this.precipitationPhase,h=this.precipitationSpeedJitter,u=this.precipitationWobbleFreqJitter,d=this.precipitationWobbleAmpJitter,f=this.precipitationBounceRemaining,g=this.precipitationBounceHeight,x=this.precipitationBounceDuration,m=this.precipitationBounceVelX,p=this.precipitationBounceVelZ,w=n==="snow"&&u&&d,A=n==="hail"&&f&&g&&x&&m&&p;for(let M=0,S=0;M<c.length;M+=3,S++){if(A&&f[S]>0){if(f[S]-=e,f[S]<=0){const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E,f[S]=0}else{const _=1-f[S]/x[S];c[M+1]=Ts+Math.sin(Math.PI*_)*g[S],c[M]=Sa(c[M]+(a+m[S])*e,s.radiusM),c[M+2]=Sa(c[M+2]+(o+p[S])*e,s.radiusM)}continue}let b=0,R=0;if(w){const _=qM*u[S],E=YM*d[S];b=Math.sin(t*_*Math.PI*2+l[S])*E,R=Math.sin(t*_*Math.PI*2+l[S]+Math.PI/2)*E}if(c[M]+=(a+b)*e,c[M+1]-=s.fallSpeedMPerS*h[S]*e,c[M+2]+=(o+R)*e,c[M]=Sa(c[M],s.radiusM),c[M+2]=Sa(c[M+2],s.radiusM),c[M+1]<Ts){if(A){g[S]=Cd*(.2+Math.random()*1.6),x[S]=KM*(.5+Math.random()),f[S]=x[S];const D=Math.random()*Math.PI*2,C=ZM*(g[S]/Cd);m[S]=Math.cos(D)*C,p[S]=Math.sin(D)*C,c[M+1]=Ts;continue}const _=Math.random()*Math.PI*2,E=Math.sqrt(Math.random())*s.radiusM;c[M]=Math.cos(_)*E,c[M+1]=s.topYM,c[M+2]=Math.sin(_)*E}}this.precipitationPoints.geometry.attributes.position.needsUpdate=!0}buildRain(){const t=BM(this.weather.precipitationIntensity);this.rainSystem=N3({count:_d,radiusM:cr,heightM:FM,bottomYM:xd,overallSpeed:OM,color:kM,opacity:.85,visibleCount:hc(_d,this.weather.precipitationIntensity),speedStreak:VM(t),pixelSize:Ad,seed:9001,nearFocusDistanceM:Ed,hazeDistanceM:cr*bd,hazeColor:new Mt(...this.baseFogColor)}),this.rainLastVerticalFacing=-1,this.rainSystem.points.renderOrder=cc,this.scene.add(this.rainSystem.points),this.buildRainSplashes()}buildRainSplashes(){const t=uc(4242),e=new Float32Array(ws*3),n=new Float32Array(ws),s=new Float32Array(ws),r=new Float32Array(ws);for(let h=0;h<ws;h++){const u=t()*Math.PI*2,d=Math.sqrt(t())*cr;e[h*3]=Math.cos(u)*d,e[h*3+1]=xd,e[h*3+2]=Math.sin(u)*d,s[h]=ya(yd,Sd),n[h]=t()*s[h],r[h]=n[h]/s[h]}const a=new Ee;a.setAttribute("position",new le(e,3));const o=new le(r,1);a.setAttribute("aLife",o),a.setDrawRange(0,hc(ws,this.weather.precipitationIntensity));const c=new Be({uniforms:{uMaxSize:{value:WM},uScale:{value:.5*this.renderer.domElement.height},uColor:{value:XM},uTexture:{value:iy()}},vertexShader:sy,fragmentShader:ry,transparent:!0,depthWrite:!1}),l=new Pa(a,c);l.renderOrder=cc,this.scene.add(l),this.rainSplashSystem={points:l,positions:e,life:n,duration:s,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}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*bn,s=Math.sin(n)*this.weather.windSpeed,r=-Math.cos(n)*this.weather.windSpeed,a=cr,o=l=>(l%(a*2)+a*3)%(a*2)-a;e.uniforms.uWindOffset.value.set(o(e.uniforms.uWindOffset.value.x+s*t),o(e.uniforms.uWindOffset.value.y+r*t)),this.camera.getWorldDirection(this.rainCameraDirection);const c=Math.abs(this.rainCameraDirection.y);if(Math.abs(c-this.rainLastVerticalFacing)>.001){this.rainLastVerticalFacing=c;const l=Td+(1-Td)*(1-c),h=Rd+(1-Rd)*(1-c);e.uniforms.uUvSquash.value=h,e.uniforms.uPixelSize.value=Ad*l*(.5+.5*h)}this.updateRainSplashes(t)}updateRainSplashes(t){const e=this.rainSplashSystem;if(!e||t<=0)return;const{positions:n,life:s,duration:r,lifeAttribute:a}=e,o=a.array;for(let c=0,l=0;c<n.length;c+=3,l++){if(s[l]+=t,s[l]>=r[l]){const h=Math.random()*Math.PI*2,u=Math.sqrt(Math.random())*cr;n[c]=Math.cos(h)*u,n[c+2]=Math.sin(h)*u,r[l]=ya(yd,Sd),s[l]=0}o[l]=s[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/Id;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+ya(Dd,Pd);return}t>=this.nextLightningAtS&&(this.lightningFlashRemainingS=Id,this.nextLightningAtS=t+ya(Dd,Pd),this.onLightningFlash?.())}}buildCompassLabels(){const t=ja(navigator.languages,wM),e=bM[t];this.compassSprites=EM.map((n,s)=>{const r=e[s],a=new hr({map:hy(r),depthTest:!1,fog:!1}),o=new qr(a),{x:c,y:l,z:h}=an(0,n,AM);return o.position.set(c,l,h),o.scale.set(dd,dd,1),o.renderOrder=TM,o.visible=this.compassHovered||this.compassForced,this.celestialGroup.add(o),o})}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 s=n.map;s&&s.dispose(),n.dispose()}}}const bn=Math.PI/180;function df(i,t,e){return Math.max(t,Math.min(e,i))}function ya(i,t){return i+Math.random()*(t-i)}function Sa(i,t){return(i%(t*2)+t*3)%(t*2)-t}let Ea,ba;function ty(i){switch(i){case"snow":return ey();case"hail":return ny()}}function ey(){if(Ea)return Ea;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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,i,i),Ea=new oi(t),Ea}function ny(){if(ba)return ba;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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,i,i),ba=new oi(t),ba}let wa;function iy(){if(wa)return wa;const i=64,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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,i,i),wa=new oi(t),wa}const sy=`
|
|
5489
5510
|
uniform float uMaxSize;
|
|
5490
5511
|
uniform float uScale;
|
|
5491
5512
|
attribute float aLife;
|
|
@@ -5498,7 +5519,7 @@ void main() {
|
|
|
5498
5519
|
vOpacity = 1.0 - aLife;
|
|
5499
5520
|
gl_Position = projectionMatrix * mvPosition;
|
|
5500
5521
|
}
|
|
5501
|
-
`,
|
|
5522
|
+
`,ry=`
|
|
5502
5523
|
uniform vec3 uColor;
|
|
5503
5524
|
uniform sampler2D uTexture;
|
|
5504
5525
|
varying float vOpacity;
|
|
@@ -5509,7 +5530,7 @@ void main() {
|
|
|
5509
5530
|
if (alpha < 0.01) discard;
|
|
5510
5531
|
gl_FragColor = vec4(uColor, alpha);
|
|
5511
5532
|
}
|
|
5512
|
-
`,
|
|
5533
|
+
`,ay=`
|
|
5513
5534
|
uniform float uSize;
|
|
5514
5535
|
uniform float uScale;
|
|
5515
5536
|
uniform float uNearFocusDistance;
|
|
@@ -5535,7 +5556,7 @@ void main() {
|
|
|
5535
5556
|
gl_PointSize = max(1.0, uSize * uScale / dist + vNearBlur * 12.0);
|
|
5536
5557
|
gl_Position = projectionMatrix * mvPosition;
|
|
5537
5558
|
}
|
|
5538
|
-
`,
|
|
5559
|
+
`,oy=`
|
|
5539
5560
|
precision mediump float;
|
|
5540
5561
|
uniform sampler2D uTexture;
|
|
5541
5562
|
uniform vec3 uColor;
|
|
@@ -5550,5 +5571,5 @@ void main() {
|
|
|
5550
5571
|
float blur = max(vNearBlur, vHaze);
|
|
5551
5572
|
gl_FragColor = vec4(color, tex.a * uOpacity * (1.0 - blur * 0.5));
|
|
5552
5573
|
}
|
|
5553
|
-
`;let pa;function NM(){if(pa)return pa;const i=128,e=document.createElement("canvas");e.width=i,e.height=i;const t=e.getContext("2d"),n=t.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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)"),t.fillStyle=n,t.fillRect(0,0,i,i),pa=new jn(e),pa}function UM(i){const t=document.createElement("canvas");t.width=128,t.height=128;const n=t.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",l="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const c=K0(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*c),d=c<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=l,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,s,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,s,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new jn(t)}function FM(i){const e=document.createElement("canvas");e.width=128,e.height=128;const t=e.getContext("2d");return t.fillStyle="rgba(0, 0, 0, 0.55)",t.beginPath(),t.arc(64,64,60,0,Math.PI*2),t.fill(),t.fillStyle="#ffffff",t.font="bold 52px sans-serif",t.textAlign="center",t.textBaseline="middle",t.fillText(i,64,68),new jn(e)}function Qo(i){let e=i;return function(){e|=0,e=e+1831565813|0;let n=Math.imul(e^e>>>15,1|e);return n=n+Math.imul(n^n>>>7,61|n)^n,((n^n>>>14)>>>0)/4294967296}}const vd=new Map;function OM(i){const e=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),t=e,n=t*Float32Array.BYTES_PER_ELEMENT;return{count:e,ra:new Float32Array(i,0*n,t),dec:new Float32Array(i,1*n,t),mag:new Float32Array(i,2*n,t),ci:new Float32Array(i,3*n,t)}}function zM(i){let e=vd.get(i);return e||(e=fetch(i).then(t=>t.arrayBuffer()).then(OM),vd.set(i,e)),e}const BM=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,kM=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,GM=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,HM=20,VM=1;class WM{context;buffers=new Map;ambientSource;ambientGain;ambientKey="none";ambientToken=0;ambientVolume=0;windSource;windGain;windActive=!1;windToken=0;windVolume=0;paused=!0;requested={type:"none",intensity:0,windSpeed:0};resume(){if(!this.context){if(typeof AudioContext>"u")return;try{this.context=new AudioContext}catch(e){console.warn("WeatherAudio: Web Audio unavailable, weather sounds disabled:",e);return}}this.context.state==="suspended"&&this.context.resume()}setAmbient(e,t,n){if(this.requested={type:e,intensity:t,windSpeed:n},!this.context)return;this.paused&&(e="none",t=0,n=0);const s=e==="rain"||e==="hail"?e:"none";if(this.ambientVolume=s==="hail"?Math.min(1,t*1.3+.2):s==="rain"?t:0,s!==this.ambientKey){this.ambientKey=s;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(BM,this.ambientVolume).then(o=>this.applyIfCurrent(o,a,()=>this.ambientToken,l=>{this.ambientSource=l?.source,this.ambientGain=l?.gain,l&&(l.gain.gain.value=this.ambientVolume)}))}else this.ambientGain&&(this.ambientGain.gain.value=this.ambientVolume);this.windVolume=Math.min(n/HM,1);const r=n>VM;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(kM,this.windVolume).then(o=>this.applyIfCurrent(o,a,()=>this.windToken,l=>{this.windSource=l?.source,this.windGain=l?.gain,l&&(l.gain.gain.value=this.windVolume)}))}else this.windGain&&(this.windGain.gain.value=this.windVolume)}setPaused(e){if(e===this.paused)return;this.paused=e;const{type:t,intensity:n,windSpeed:s}=this.requested;this.setAmbient(t,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(GM,.9)}dispose(){this.ambientToken++,this.windToken++,this.stopSource(this.ambientSource,this.ambientGain),this.stopSource(this.windSource,this.windGain),this.ambientSource=void 0,this.ambientGain=void 0,this.windSource=void 0,this.windGain=void 0,this.context?.close(),this.context=void 0,this.buffers.clear()}applyIfCurrent(e,t,n,s){if(t!==n()){e?.source.stop();return}s(e)}async startLoop(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s,r.loop=!0;const a=n.createGain();return a.gain.value=t,r.connect(a).connect(n.destination),r.start(),{source:r,gain:a}}catch(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(e,t){const n=this.context;if(n)try{const s=await this.getBuffer(e),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=t,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}async getBuffer(e){const t=this.context;if(!t)throw new Error("WeatherAudio: AudioContext not ready — resume() must be called first");let n=this.buffers.get(e);return n||(n=fetch(e).then(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${e}`);return s.arrayBuffer()}).then(s=>t.decodeAudioData(s)),this.buffers.set(e,n)),n}stopSource(e,t){try{e?.stop()}catch{}e?.disconnect(),t?.disconnect()}}class Yn{constructor(e){this.elements=e;const{eccentricity:t,perihelionAu:n}=e,[s,r]=this.perifocalAxes(),a=Math.sqrt(Yn.SUN_GM_AU3_PER_DAY2*(1+t)/n);this.perihelionPosition=this.scale(s,n),this.perihelionVelocity=this.scale(r,a),this.inverseSemiMajorAxis=(1-t)/n}static SUN_GM_AU3_PER_DAY2=.0002959122082855911;static MAX_ITERATIONS=200;perihelionPosition;perihelionVelocity;inverseSemiMajorAxis;positionAt(e){const t=e-this.elements.perihelionJd,n=this.universalAnomaly(t),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*Yn.stumpffC(s),o=t-n*n*n/Math.sqrt(Yn.SUN_GM_AU3_PER_DAY2)*Yn.stumpffS(s);return{x:a*this.perihelionPosition.x+o*this.perihelionVelocity.x,y:a*this.perihelionPosition.y+o*this.perihelionVelocity.y,z:a*this.perihelionPosition.z+o*this.perihelionVelocity.z}}heliocentricDistanceAt(e){const t=this.positionAt(e);return Math.hypot(t.x,t.y,t.z)}universalAnomaly(e){if(e===0)return 0;const t=Math.sign(e),n=Math.sqrt(Yn.SUN_GM_AU3_PER_DAY2)*Math.abs(e),s=o=>{const l=this.inverseSemiMajorAxis*o*o,c=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*c)*o*o*o*Yn.stumpffS(l)+c*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<Yn.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const l=(a+r)/2;s(l)<n?a=l:r=l}return t*(a+r)/2}perifocalAxes(){const e=this.elements.ascendingNodeDeg*Math.PI/180,t=this.elements.argumentOfPerihelionDeg*Math.PI/180,n=this.elements.inclinationDeg*Math.PI/180,s=Math.cos(e),r=Math.sin(e),a=Math.cos(t),o=Math.sin(t),l=Math.cos(n),c=Math.sin(n);return[{x:s*a-r*o*l,y:r*a+s*o*l,z:o*c},{x:-s*o-r*a*l,y:-r*o+s*a*l,z:a*c}]}scale(e,t){return{x:e.x*t,y:e.y*t,z:e.z*t}}static stumpffC(e){if(Math.abs(e)<1e-6)return 1/2-e/24+e*e/720;if(e>0)return(1-Math.cos(Math.sqrt(e)))/e;const t=Math.sqrt(-e);return(Math.cosh(t)-1)/-e}static stumpffS(e){if(Math.abs(e)<1e-6)return 1/6-e/120+e*e/5040;if(e>0){const n=Math.sqrt(e);return(n-Math.sin(n))/(n*n*n)}const t=Math.sqrt(-e);return(Math.sinh(t)-t)/(t*t*t)}}const Z0=[{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 XM{static WINDOW_DAYS=200;static TWILIGHT_ELONGATION_DEG=15;static LIGHT_SPEED_AU_PER_DAY=173.144632674;static orbits=new Map;static aroundDate(e){const t=this.julianDayOf(e);return Z0.filter(n=>Math.abs(t-n.orbit.perihelionJd)<=this.WINDOW_DAYS)}static brightestAt(e,t){return this.aroundDate(e).map(n=>this.appearanceOf(n,e,t)).sort((n,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(e,t,n){const s=Ct(t),r=this.earthPositionAt(s),a=this.apparentPositionOf(e,2451545+s.tt,r),o=this.subtract(a,r),l=this.length(a),c=this.length(o),h=this.tailEndAt(e,a,r,l,s,t,n),u=this.horizontalOf(o,s,t,n);return{apparition:e,position:u,...h,heliocentricDistanceAu:l,earthDistanceAu:c,elongationDeg:this.angleBetween(o,this.subtract({x:0,y:0,z:0},r)),magnitude:this.magnitudeAt(e,l,c)}}static magnitudeAt(e,t,n){const s=e.absoluteMagnitude+5*Math.log10(n)+2.5*e.activityExponent*Math.log10(t);return Math.max(s,e.peakMagnitude)}static tailEndAt(e,t,n,s,r,a,o){if(e.tailLengthAu===void 0)return{};const l=1+e.tailLengthAu/s,c=this.subtract({x:t.x*l,y:t.y*l,z:t.z*l},n),h=this.subtract(t,n);return{tailEnd:this.horizontalOf(c,r,a,o),tailLengthDeg:this.angleBetween(h,c)}}static apparentPositionOf(e,t,n){const s=this.orbitOf(e);let r=s.positionAt(t);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(t-o)}return r}static horizontalOf(e,t,n,s){const r=Sa(Tx(),new ut(e.x,e.y,e.z,t)),a=Sa(Rx(t),r),o=sx(t,new Zc(s.lat,s.lng,s.elevationM)),l=new ut(a.x-o.x,a.y-o.y,a.z-o.z,t),c=C0(l);return Za(c.ra,c.dec,n,s)}static earthPositionAt(e){return Sa(Ax(),vi(Se.Earth,e))}static julianDayOf(e){return 2451545+Ct(e).tt}static orbitOf(e){const t=this.orbits.get(e.id);if(t)return t;const n=new Yn(e.orbit);return this.orbits.set(e.id,n),n}static subtract(e,t){return{x:e.x-t.x,y:e.y-t.y,z:e.z-t.z}}static length(e){return Math.hypot(e.x,e.y,e.z)}static angleBetween(e,t){const n=(e.x*t.x+e.y*t.y+e.z*t.z)/(this.length(e)*this.length(t)||1);return Math.acos(Math.min(1,Math.max(-1,n)))*180/Math.PI}}const qM=[{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}],Oa=6.5;class jo{static activeAt(e){return qM.flatMap(t=>{const n=this.nearness(t,e);return n<=0?[]:[{shower:t,zhr:t.peakZhr*n,nearness:n}]})}static nearness(e,t){const n=this.dayOfYear(t),s=this.dayOfYear(this.asDate(e.start)),r=this.dayOfYear(this.asDate(e.peak)),a=this.dayOfYear(this.asDate(e.end)),o=this.wrappedDelta(n,r),l=this.wrappedDelta(r,s),c=this.wrappedDelta(a,r);return o<0?o<-l?0:1+o/l:o>0?o>c?0:1-o/c:1}static observedRatePerHour(e,t,n,s=Oa){if(t<=0)return 0;const r=Oa-s;return e*Math.sin(t*Math.PI/180)/Math.pow(n,r)}static radiantPosition(e,t,n){return Za(e.radiantRaHours,e.radiantDecDeg,t,n)}static dayOfYear(e){const t=Date.UTC(e.getUTCFullYear(),0,1);return Math.floor((Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate())-t)/864e5)+1}static asDate(e){return new Date(Date.UTC(2001,e.month-1,e.day))}static wrappedDelta(e,t){const n=e-t;return n>182?n-365:n<-182?n+365:n}}class _t{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(e,t){const n=Ct(e),s=new Yc(0,nx(e).elon-90,1),r=Sa(Cx(n),R0(s,n)),a=C0(r);return Za(a.ra,a.dec,e,t)}static observedRatePerHour(e,t=Oa){const n=_t.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(e*Math.PI/180)),s=Oa-t;return(_t.QUIET_RATE_PER_HOUR+n)/Math.pow(_t.POPULATION_INDEX,s)}static schedule(e){const t=new O0(e.seed^1542469173);return zi.schedule(e).map(n=>{const s=_t.toCartesian({altitudeDeg:Math.asin(t.next())*180/Math.PI,azimuthDeg:t.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=_t.turnAround(s,t.between(0,360)),o={x:s.x*Math.cos(r)+a.x*Math.sin(r),y:s.y*Math.cos(r)+a.y*Math.sin(r),z:s.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:_t.toHorizontal(o),bearingDeg:_t.bearingFrom(o,s)}})}static turnAround(e,t){const[n,s]=_t.basisAround(e),r=t*Math.PI/180;return{x:n.x*Math.cos(r)+s.x*Math.sin(r),y:n.y*Math.cos(r)+s.y*Math.sin(r),z:n.z*Math.cos(r)+s.z*Math.sin(r)}}static bearingFrom(e,t){const[n,s]=_t.basisAround(e),r=e.x*t.x+e.y*t.y+e.z*t.z,a=_t.normalise({x:t.x-e.x*r,y:t.y-e.y*r,z:t.z-e.z*r});return(Math.atan2(a.x*s.x+a.y*s.y+a.z*s.z,a.x*n.x+a.y*n.y+a.z*n.z)*180/Math.PI%360+360)%360}static basisAround(e){const t=Math.abs(e.y)<.9?{x:0,y:1,z:0}:{x:1,y:0,z:0},n=_t.normalise(_t.cross(e,t));return[n,_t.normalise(_t.cross(e,n))]}static toHorizontal(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{altitudeDeg:Math.asin(Math.min(1,Math.max(-1,e.y/t)))*180/Math.PI,azimuthDeg:(Math.atan2(e.x,-e.z)*180/Math.PI%360+360)%360}}static appearanceOf(e){const t=_t.toCartesian(e.radiant??{altitudeDeg:90,azimuthDeg:0}),n=_t.turnAround(t,e.bearingDeg),s=e.fromRadiantDeg*Math.PI/180;return _t.toHorizontal({x:t.x*Math.cos(s)+n.x*Math.sin(s),y:t.y*Math.cos(s)+n.y*Math.sin(s),z:t.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(e){const t=e.altitudeDeg*Math.PI/180,n=e.azimuthDeg*Math.PI/180,s=Math.cos(t);return{x:s*Math.sin(n),y:Math.sin(t),z:-s*Math.cos(n)}}static cross(e,t){return{x:e.y*t.z-e.z*t.y,y:e.z*t.x-e.x*t.z,z:e.x*t.y-e.y*t.x}}static normalise(e){const t=Math.hypot(e.x,e.y,e.z)||1;return{x:e.x/t,y:e.y/t,z:e.z/t}}static TYPICAL_VELOCITY_KM_S=40}class YM{lowerM;upperM;add(e,t){if(!(e<=0)){if(t.behindM!==void 0){const n=Zt.sizeMAt(t.behindM,e);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(t.inFrontM!==void 0){const n=Zt.sizeMAt(t.inFrontM,e);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(e){return e<=0?{}:{minM:this.lowerM===void 0?void 0:Zt.distanceMAt(this.lowerM,e),maxM:this.upperM===void 0?void 0:Zt.distanceMAt(this.upperM,e)}}clear(){this.lowerM=void 0,this.upperM=void 0}}wd();const KM={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"}},ZM=["en","fr"],_d="comet:",$M={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"}},JM=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,QM={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},el={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class jM extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass","lens-flare-intensity","lens-flare-brightness"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new WM;thunderTimeoutId;handleFullscreenChange=()=>this.resizeToStage();handlePointerMove=e=>{this.sceneRenderer.setCompassHovered(!0);const t=this.ufoElement.canvasElement,n=t.getBoundingClientRect();if(n.width===0||n.height===0)return;const s=(e.clientX-n.left)/n.width*t.width,r=(e.clientY-n.top)/n.height*t.height;if(this.ufoElement.hasVisibleShapeAt(s,r)){this.hoverTooltip.hidden=!0;return}const a=(e.clientX-n.left)/n.width*2-1,o=-((e.clientY-n.top)/n.height*2-1),l=ka(navigator.languages,ZM),c=this.sceneRenderer.pickBodyAt(a,o);if(c){this.showHoverTooltip(e,this.bodyName(c,l));return}const h=this.sceneRenderer.pickDecorAt(a,o),u=h?this.ufoElement.sighting.decor.find(d=>d.id===h):void 0;if(u){this.showHoverTooltip(e,u.title||$M[u.kind][l]);return}this.hoverTooltip.hidden=!0};bodyName(e,t){const n=e.startsWith(_d)?e.slice(_d.length):void 0;return(n?Z0.find(r=>r.id===n):void 0)?.name[t]??KM[e]?.[t]??e}showHoverTooltip(e,t){this.hoverTooltip.textContent=t,this.hoverTooltip.hidden=!1;const n=this.stageElement.getBoundingClientRect();this.hoverTooltip.style.left=`${e.clientX-n.left+12}px`,this.hoverTooltip.style.top=`${e.clientY-n.top+12}px`}handlePointerLeave=()=>{this.hoverTooltip.hidden=!0,this.sceneRenderer.setCompassHovered(!1)};handleLightningFlash=()=>{clearTimeout(this.thunderTimeoutId);const e=(.5+Math.random()*3.5)*1e3;this.thunderTimeoutId=window.setTimeout(()=>this.weatherAudio.playThunder(),e)};handleFirstInteraction=()=>{this.weatherAudio.resume(),this.setWeather(hh(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=e=>{this.lastTimeMs=e.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const e=this.ufoElement.playbackState==="playing";this.sceneRenderer.setAnimationsRunning(e),this.weatherAudio.setPaused(!e),e||clearTimeout(this.thunderTimeoutId)}constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${cf}</style>${lf}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.stageElement=this.shadow.getElementById("stage"),this.frameElement=this.shadow.getElementById("frame"),this.sceneCanvas=this.shadow.getElementById("scene-canvas"),this.sceneRenderer=new wM(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(sl),this.ufoElement.classList.add("ufo-overlay"),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})}connectedCallback(){this.resizeToStage(),this.updateAstronomy(this.lastTimeMs),this.loadStars(),this.resizeObserver=new ResizeObserver(()=>this.resizeToStage()),this.resizeObserver.observe(this.frameElement),document.addEventListener("fullscreenchange",this.handleFullscreenChange);const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){this.resizeObserver?.disconnect(),document.removeEventListener("fullscreenchange",this.handleFullscreenChange),this.sceneRenderer.stopTwinkle(),clearTimeout(this.thunderTimeoutId),this.weatherAudio.dispose()}attributeChangedCallback(e,t,n){if(e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n),e==="star-catalog-src"&&n!==t&&this.isConnected&&this.loadStars(),e==="show-compass"&&n!==t&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),e==="lens-flare-intensity"&&n!==t){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setLensFlareArtifactIntensity(Number.isFinite(s)?s:0)}if(e==="lens-flare-brightness"&&n!==t){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setDazzleIntensity(Number.isFinite(s)?s:1)}}setCompassForced(e){this.sceneRenderer.setCompassForced(e)}setIndoorLook(e,t){this.sceneRenderer.setIndoorLook(e,t)}setWeather(e){this.sceneRenderer.setWeather(e),this.weatherAudio.setAmbient(e.precipitationType,e.precipitationIntensity,e.windSpeed)}pickDecorAt(e,t){return this.sceneRenderer.pickDecorAt(e,t)}resumeWeatherAudio(){this.weatherAudio.resume()}async loadFromSrc(e){const t=await fetch(e);this.sightingData=await t.json()}get sightingData(){return this.ufoElement.sightingData}set sightingData(e){this.ufoElement.sightingData=e,this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(e){this.sceneRenderer.setTerrainProviders(e)}resizeToStage(){const e=this.frameElement.getBoundingClientRect(),t=Math.max(1,Math.round(e.width)),n=Math.max(1,Math.round(e.height));this.sceneCanvas.width=t,this.sceneCanvas.height=n,this.sceneRenderer.resize(t,n)}async loadStars(){const e=this.getAttribute("star-catalog-src")??JM;this.starCatalog=await zM(e),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(e){const t=this.ufoElement.sighting;this.setWeather(hh(t,e)),this.sceneRenderer.setProjection(t.instrument.projection),this.updateMeteorShower(t,e),this.sceneRenderer.setDecor(t.decor);const n=rr(t,e);this.sceneRenderer.setObserverPose(n??el),this.sceneRenderer.updateDecorAnchoring(rr(t,0),n,e),this.sceneRenderer.updateDecorLitState(e),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??el.lat,r=n?.lng??el.lng,a=_c(t.event.time??{},r,t.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(QM);return}const o=new Date(a.getTime()+e),l={lat:s,lng:r,elevationM:n?.elevationM??0},c={...Go("Sun",o,l),magnitude:Ho("Sun",o)},h={...Go("Moon",o,l),phase:Px(o),magnitude:Ho("Moon",o)},u=Dx.map(d=>({body:d,position:Go(d,o,l),magnitude:Ho(d,o)}));this.sceneRenderer.setAstronomy({sun:c,moon:h,planets:u,comet:this.cometAt(o,l),stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:l}:void 0})}cometAt(e,t){const n=XM.brightestAt(e,t);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(e){const t=this.ufoElement.sighting;t!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=t);const n=t.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(e,a);if(!o)continue;const l=(o.bounds.x+o.bounds.width/2)/s.width*2-1,c=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(l,c,a,o.behindCloud)&&r.add(a);const h=o.angular?.widthDeg??this.projectionAt(e).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(l,c,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(e){return this.sizeEstimateOf(e).sizeRange}distanceRangeAt(e,t){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(t,e);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(t).pxToDeg(n.bounds.width);return this.sizeEstimateOf(e).distanceRangeAt(s)}sizeContradictory(e){return this.sizeEstimateOf(e).contradictory}updateMeteorShower(e,t){this.ensureMeteorSchedule(e),this.sceneRenderer.updateMeteors(t)}ensureMeteorSchedule(e){const t=this.meteorInputsOf(e);t!==this.meteorScheduleFor&&(this.meteorScheduleFor=t,this.scheduleMeteors(e))}meteorInputsOf(e){const t=e.event.place?.[0],n=e.event.time;return JSON.stringify([t?.lat,t?.lng,n?.year,n?.month,n?.day,n?.hour,n?.minute,e.event.utcOffsetHours,e.event.durationSeconds,e.timeline.duration])}scheduleMeteors(e){const t=e.event.place?.[0],n=e.event.time,s=t?.lat!==void 0&&t.lng!==void 0&&n?.year!==void 0?_c(n,t.lng,e.event.utcOffsetHours):void 0;if(!s||t?.lat===void 0||t.lng===void 0){this.sceneRenderer.setMeteorShower([],0,0);return}const r={lat:t.lat,lng:t.lng,elevationM:0},a=(e.event.durationSeconds??0)*1e3||e.timeline.duration||2e4,o=Math.round(s.getTime()/1e3)+Math.round(t.lat*1e3),l=_t.schedule({ratePerHour:_t.observedRatePerHour(_t.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:_t.TYPICAL_VELOCITY_KM_S,seed:o}),c=jo.activeAt(s).map(u=>{const d=jo.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:jo.observedRatePerHour(u.zhr,d.altitudeDeg,u.shower.populationIndex)}}).sort((u,d)=>d.rate-u.rate)[0];if(!c||c.rate<=0){this.sceneRenderer.setMeteorShower(l,0,0);return}const h=zi.schedule({ratePerHour:c.rate,durationMs:a,velocityKmS:c.entry.shower.velocityKmS,seed:o+1});this.sceneRenderer.setMeteorShower([...h,...l],c.position.altitudeDeg,c.position.azimuthDeg)}meteorByRank(e){this.ensureMeteorSchedule(this.ufoElement.sighting);const t=[...this.sceneRenderer.meteorSchedule].filter(r=>r.t+r.durationMs<=this.ufoElement.seekableDuration).sort((r,a)=>a.brightness-r.brightness);if(t.length===0)return;const n=t[e%t.length],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}projectionAt(e){const t=this.ufoElement.sighting,n=rr(t,e)?.fovDeg??bc.DEFAULT_FOV_DEG;return Es.of(t.instrument,Zt.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(e){let t=this.sizeEstimates.get(e);return t||(t=new YM,this.sizeEstimates.set(e,t)),t}}const Ec="rr0-scene";function $0(){wd(),customElements.get(Ec)||customElements.define(Ec,jM)}const J0={testimonyBy:"Testimony by",about:"About",close:"Close",observation:"Observation",date:"Date",location:"Location",case:"Case",description:"Description",tags:"Tags",credits:"Credits",editThisObservation:"Edit this observation",embed:"Embed",embedReplay:"Replay",embedEdit:"Editor",embedCopy:"Copy",embedCopied:"Copied"},ey=Object.freeze(Object.defineProperty({__proto__:null,eyewitnessMessages_en:J0},Symbol.toStringTag,{value:"Module"}));$0();const ty="“Thunder” by Jerimee",ny="https://creativecommons.org/licenses/by/3.0/",iy="CC BY 3.0",tl="https://ufoathome.org";class sy extends HTMLElement{static get observedAttributes(){return["src"]}shadow;sceneElement;toolbarElement;testimonyPrefix;witnessText;witnessSelect;infoButton;infoPanel;infoAppLink;infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;infoEmbedToggle;infoEmbedPanel;embedReplayRadio;embedEditRadio;labelEmbedReplay;labelEmbedEdit;embedMarkup;embedCopyButton;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];currentSrc;infoOpen=!1;creditsOpen=!1;embedOpen=!1;language="en";messages=J0;constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const e=document.createElement("template");e.innerHTML=`<style>${of}</style>${af}`,this.shadow.appendChild(e.content.cloneNode(!0)),this.sceneElement=document.createElement(Ec),this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.testimonyPrefix=this.shadow.getElementById("testimony-prefix"),this.witnessText=this.shadow.getElementById("witness-text"),this.witnessSelect=this.shadow.getElementById("witness"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.infoEmbedToggle=this.shadow.getElementById("info-embed-toggle"),this.infoEmbedPanel=this.shadow.getElementById("info-embed"),this.embedReplayRadio=this.shadow.getElementById("embed-kind-replay"),this.embedEditRadio=this.shadow.getElementById("embed-kind-edit"),this.labelEmbedReplay=this.shadow.getElementById("label-embed-replay"),this.labelEmbedEdit=this.shadow.getElementById("label-embed-edit"),this.embedMarkup=this.shadow.getElementById("embed-markup"),this.embedCopyButton=this.shadow.getElementById("embed-copy"),this.witnessSelect.addEventListener("change",()=>this.selectWitness(this.witnessSelect.value)),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",t=>{t.newState==="open"&&this.populateInfoPanel()}),this.infoPanel.addEventListener("toggle",t=>this.syncInfoOpen(t.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.infoEmbedToggle.addEventListener("click",()=>this.toggleEmbed());for(const t of[this.embedReplayRadio,this.embedEditRadio])t.addEventListener("change",()=>this.refreshEmbedMarkup());this.embedCopyButton.addEventListener("click",()=>void this.copyEmbedMarkup()),this.loadLocaleMessages()}async loadLocaleMessages(){this.language=ka(navigator.languages,Ed),this.language!=="en"&&(this.messages=await Zf(this.language),this.testimonyPrefix.textContent=this.messages.testimonyBy,this.infoButton.title=this.messages.about,this.infoButton.setAttribute("aria-label",this.messages.about),this.infoCloseButton.setAttribute("aria-label",this.messages.close),this.infoObservationHeading.textContent=this.messages.observation,this.infoCreditsToggle.textContent=this.messages.credits,this.infoEmbedToggle.textContent=this.messages.embed,this.labelEmbedReplay.textContent=this.messages.embedReplay,this.labelEmbedEdit.textContent=this.messages.embedEdit,this.embedCopyButton.textContent=this.messages.embedCopy,this.infoOpen&&this.populateInfoPanel(),this.updateTestimonyLine())}connectedCallback(){const e=this.getAttribute("src");e&&this.loadFromSrc(e)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(e,t,n){e==="src"&&n&&n!==t&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(e){const n=await(await fetch(e)).json();Array.isArray(n)?await this.loadWitnessUrls(n):this.setEntries([{src:e,sighting:n}])}get witnessUrls(){return this.entries.map(e=>e.src)}set witnessUrls(e){this.loadWitnessUrls(e)}async loadWitnessUrls(e){const t=await Promise.all(e.map(async n=>{const s=await fetch(n);return{src:n,sighting:await s.json()}}));this.setEntries(t)}setEntries(e){this.entries=e,this.warnOnMismatchedCaseIds(e),this.toolbarElement.hidden=e.length===0;const t=e.length>1;this.witnessSelect.hidden=!t,this.witnessText.hidden=t,this.witnessSelect.innerHTML="";for(const s of e){const r=document.createElement("option");r.value=s.src,r.textContent=this.witnessDisplayName(s.sighting.witness)??s.src,this.witnessSelect.appendChild(r)}const n=e.find(s=>s.src===this.currentSrc)??e[0];n?this.selectWitness(n.src):this.updateTestimonyLine()}editorUrl(){if(!this.currentSrc)return tl;const e=new URL(this.currentSrc,location.href);return e.origin===location.origin?`${tl}${e.pathname}`:`${tl}/?sighting=${encodeURIComponent(e.href)}`}embedMarkupFor(e){const t=e==="edit"?"rr0-ufo-recorder":"rr0-eyewitness",n=new URL(`${t}.mjs`,import.meta.url).href,s=this.currentSrc?new URL(this.currentSrc,location.href).href:"";return`<script type="module" src="${n}"><\/script>
|
|
5554
|
-
<${
|
|
5574
|
+
`;let Aa;function cy(){if(Aa)return Aa;const i=128,t=document.createElement("canvas");t.width=i,t.height=i;const e=t.getContext("2d"),n=e.createRadialGradient(i/2,i/2,0,i/2,i/2,i/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,i,i),Aa=new oi(t),Aa}function ly(i){const e=document.createElement("canvas");e.width=128,e.height=128;const n=e.getContext("2d"),s=128/2-2,r=128/2,a=128/2,o="#2e2b26",c="#f4f1e2";n.fillStyle=o,n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.fill();const l=df(i.illuminatedFraction,0,1),h=i.phaseFraction<.5,u=s*Math.abs(1-2*l),d=l<.5;return n.save(),n.beginPath(),n.arc(r,a,s,0,Math.PI*2),n.clip(),n.fillStyle=c,n.beginPath(),h?(n.arc(r,a,s,-Math.PI/2,Math.PI/2,!1),n.ellipse(r,a,u,s,0,Math.PI/2,-Math.PI/2,d)):(n.arc(r,a,s,Math.PI/2,-Math.PI/2,!1),n.ellipse(r,a,u,s,0,-Math.PI/2,Math.PI/2,d)),n.fill(),n.restore(),new oi(e)}function hy(i){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(i,64,68),new oi(t)}function uc(i){let t=i;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 Ld=new Map;function uy(i){const t=i.byteLength/(4*Float32Array.BYTES_PER_ELEMENT),e=t,n=e*Float32Array.BYTES_PER_ELEMENT;return{count:t,ra:new Float32Array(i,0*n,e),dec:new Float32Array(i,1*n,e),mag:new Float32Array(i,2*n,e),ci:new Float32Array(i,3*n,e)}}function dy(i){let t=Ld.get(i);return t||(t=fetch(i).then(e=>e.arrayBuffer()).then(uy),Ld.set(i,t)),t}const fy=new URL(""+new URL("rain-BvWZrB9h.ogg",import.meta.url).href,import.meta.url).href,py=new URL(""+new URL("wind-BjklexY7.ogg",import.meta.url).href,import.meta.url).href,my=new URL(""+new URL("thunder-DA48qs_v.wav",import.meta.url).href,import.meta.url).href,gy=20,vy=1;class _y{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 s=t==="rain"||t==="hail"?t:"none";if(this.ambientVolume=s==="hail"?Math.min(1,e*1.3+.2):s==="rain"?e:0,s!==this.ambientKey){this.ambientKey=s;const a=++this.ambientToken;this.stopSource(this.ambientSource,this.ambientGain),this.ambientSource=void 0,this.ambientGain=void 0,s!=="none"&&this.startLoop(fy,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/gy,1);const r=n>vy;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(py,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:s}=this.requested;this.setAmbient(e,n,s)}playThunder(){!this.context||this.paused||this.playOneShot(my,.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,s){if(e!==n()){t?.source.stop();return}s(t)}async startLoop(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s,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(s){console.warn("Weather ambient sound failed to load, staying silent:",s);return}}async playOneShot(t,e){const n=this.context;if(n)try{const s=await this.getBuffer(t),r=n.createBufferSource();r.buffer=s;const a=n.createGain();a.gain.value=e,r.connect(a).connect(n.destination),r.start()}catch(s){console.warn("Thunder sound failed to load:",s)}}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(s=>{if(!s.ok)throw new Error(`Audio fetch failed (${s.status}): ${t}`);return s.arrayBuffer()}).then(s=>e.decodeAudioData(s)),this.buffers.set(t,n)),n}stopSource(t,e){try{t?.stop()}catch{}t?.disconnect(),e?.disconnect()}}class ni{constructor(t){this.elements=t;const{eccentricity:e,perihelionAu:n}=t,[s,r]=this.perifocalAxes(),a=Math.sqrt(ni.SUN_GM_AU3_PER_DAY2*(1+e)/n);this.perihelionPosition=this.scale(s,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),s=this.inverseSemiMajorAxis*n*n,r=this.elements.perihelionAu,a=1-n*n/r*ni.stumpffC(s),o=e-n*n*n/Math.sqrt(ni.SUN_GM_AU3_PER_DAY2)*ni.stumpffS(s);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(ni.SUN_GM_AU3_PER_DAY2)*Math.abs(t),s=o=>{const c=this.inverseSemiMajorAxis*o*o,l=this.elements.perihelionAu;return(1-this.inverseSemiMajorAxis*l)*o*o*o*ni.stumpffS(c)+l*o};let r=Math.max(1,n/this.elements.perihelionAu);for(;s(r)<n;)r*=2;let a=0;for(let o=0;o<ni.MAX_ITERATIONS&&r-a>1e-13*Math.max(1,r);o++){const c=(a+r)/2;s(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,s=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:s*a-r*o*c,y:r*a+s*o*c,z:o*l},{x:-s*o-r*a*c,y:-r*o+s*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 ff=[{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 xy{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 ff.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,s)=>n.magnitude-s.magnitude)[0]}static appearanceOf(t,e,n){const s=Le(e),r=this.earthPositionAt(s),a=this.apparentPositionOf(t,2451545+s.tt,r),o=this.subtract(a,r),c=this.length(a),l=this.length(o),h=this.tailEndAt(t,a,r,c,s,e,n),u=this.horizontalOf(o,s,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 s=t.absoluteMagnitude+5*Math.log10(n)+2.5*t.activityExponent*Math.log10(e);return Math.max(s,t.peakMagnitude)}static tailEndAt(t,e,n,s,r,a,o){if(t.tailLengthAu===void 0)return{};const c=1+t.tailLengthAu/s,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 s=this.orbitOf(t);let r=s.positionAt(e);for(let a=0;a<2;a++){const o=this.length(this.subtract(r,n))/this.LIGHT_SPEED_AU_PER_DAY;r=s.positionAt(e-o)}return r}static horizontalOf(t,e,n,s){const r=Na(t3(),new ue(t.x,t.y,t.z,e)),a=Na(e3(e),r),o=Px(e,new hh(s.lat,s.lng,s.elevationM)),c=new ue(a.x-o.x,a.y-o.y,a.z-o.z,e),l=q0(c);return co(l.ra,l.dec,n,s)}static earthPositionAt(t){return Na(jx(),Ai(St.Earth,t))}static julianDayOf(t){return 2451545+Le(t).tt}static orbitOf(t){const e=this.orbits.get(t.id);if(e)return e;const n=new ni(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 My=[{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}],$a=6.5;class dc{static activeAt(t){return My.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),s=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,s),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,s=$a){if(e<=0)return 0;const r=$a-s;return t*Math.sin(e*Math.PI/180)/Math.pow(n,r)}static radiantPosition(t,e,n){return co(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 xe{static QUIET_RATE_PER_HOUR=2;static APEX_RATE_PER_HOUR=8;static POPULATION_INDEX=3;static apexPosition(t,e){const n=Le(t),s=new ch(0,Cx(t).elon-90,1),r=Na(n3(n),X0(s,n)),a=q0(r);return co(a.ra,a.dec,t,e)}static observedRatePerHour(t,e=$a){const n=xe.APEX_RATE_PER_HOUR*Math.max(0,Math.sin(t*Math.PI/180)),s=$a-e;return(xe.QUIET_RATE_PER_HOUR+n)/Math.pow(xe.POPULATION_INDEX,s)}static schedule(t){const e=new tf(t.seed^1542469173);return Ki.schedule(t).map(n=>{const s=xe.toCartesian({altitudeDeg:Math.asin(e.next())*180/Math.PI,azimuthDeg:e.between(0,360)}),r=n.fromRadiantDeg*Math.PI/180,a=xe.turnAround(s,e.between(0,360)),o={x:s.x*Math.cos(r)+a.x*Math.sin(r),y:s.y*Math.cos(r)+a.y*Math.sin(r),z:s.z*Math.cos(r)+a.z*Math.sin(r)};return{...n,radiant:xe.toHorizontal(o),bearingDeg:xe.bearingFrom(o,s)}})}static turnAround(t,e){const[n,s]=xe.basisAround(t),r=e*Math.PI/180;return{x:n.x*Math.cos(r)+s.x*Math.sin(r),y:n.y*Math.cos(r)+s.y*Math.sin(r),z:n.z*Math.cos(r)+s.z*Math.sin(r)}}static bearingFrom(t,e){const[n,s]=xe.basisAround(t),r=t.x*e.x+t.y*e.y+t.z*e.z,a=xe.normalise({x:e.x-t.x*r,y:e.y-t.y*r,z:e.z-t.z*r});return(Math.atan2(a.x*s.x+a.y*s.y+a.z*s.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=xe.normalise(xe.cross(t,e));return[n,xe.normalise(xe.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=xe.toCartesian(t.radiant??{altitudeDeg:90,azimuthDeg:0}),n=xe.turnAround(e,t.bearingDeg),s=t.fromRadiantDeg*Math.PI/180;return xe.toHorizontal({x:e.x*Math.cos(s)+n.x*Math.sin(s),y:e.y*Math.cos(s)+n.y*Math.sin(s),z:e.z*Math.cos(s)+n.z*Math.sin(s)})}static toCartesian(t){const e=t.altitudeDeg*Math.PI/180,n=t.azimuthDeg*Math.PI/180,s=Math.cos(e);return{x:s*Math.sin(n),y:Math.sin(e),z:-s*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 yy{lowerM;upperM;add(t,e){if(!(t<=0)){if(e.behindM!==void 0){const n=tn.sizeMAt(e.behindM,t);this.lowerM=this.lowerM===void 0?n:Math.max(this.lowerM,n)}if(e.inFrontM!==void 0){const n=tn.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:tn.distanceMAt(this.lowerM,t),maxM:this.upperM===void 0?void 0:tn.distanceMAt(this.upperM,t)}}clear(){this.lowerM=void 0,this.upperM=void 0}}Hd();const Sy={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"}},Ey=["en","fr"],Nd="comet:",by={building:{en:"Building",fr:"Bâtiment"},tree:{en:"Tree",fr:"Arbre"},streetlight:{en:"Streetlight",fr:"Lampadaire"},vehicle:{en:"Vehicle",fr:"Véhicule"},witness:{en:"Witness",fr:"Témoin"},aircraft:{en:"Aircraft",fr:"Aéronef"}},wy=new URL(""+new URL("stars-mag7.5-DDr9QasD.bin",import.meta.url).href,import.meta.url).href,Ay={sun:{altitudeDeg:-3,azimuthDeg:180,magnitude:-26.7},moon:{altitudeDeg:-90,azimuthDeg:0,phase:{phaseFraction:0,illuminatedFraction:0},magnitude:-12.7},planets:[]},fc={lat:0,lng:0,elevationM:0,headingDeg:void 0,pitchDeg:0,fovDeg:60};class Ty extends HTMLElement{static get observedAttributes(){return["src","star-catalog-src","show-compass","lens-flare-intensity"]}shadow;stageElement;frameElement;sceneCanvas;ufoElement;sceneRenderer;hoverTooltip;resizeObserver;sizeEstimates=new Map;sizeEstimatesFor;meteorScheduleFor;lastTimeMs=0;starCatalog;weatherAudio=new _y;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 s=(t.clientX-n.left)/n.width*e.width,r=(t.clientY-n.top)/n.height*e.height;if(this.ufoElement.hasVisibleShapeAt(s,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=ja(navigator.languages,Ey),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(d=>d.id===h):void 0;if(u){this.showHoverTooltip(t,u.title||by[u.kind][c]);return}this.hoverTooltip.hidden=!0};bodyName(t,e){const n=t.startsWith(Nd)?t.slice(Nd.length):void 0;return(n?ff.find(r=>r.id===n):void 0)?.name[e]??Sy[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(bh(this.ufoElement.sighting,this.lastTimeMs))};handleTimeUpdate=t=>{this.lastTimeMs=t.detail.time,this.syncAnimationsToPlayback(),this.updateAstronomy(this.lastTimeMs),this.updateUfoOcclusion(this.lastTimeMs)};syncAnimationsToPlayback(){const t=this.ufoElement.playbackState==="playing";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>${Af}</style>${wf}`,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 jM(this.sceneCanvas,void 0,this.handleLightningFlash),this.hoverTooltip=this.shadow.getElementById("hover-tooltip"),this.ufoElement=document.createElement(vc),this.ufoElement.classList.add("ufo-overlay"),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})}connectedCallback(){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){if(t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n),t==="star-catalog-src"&&n!==e&&this.isConnected&&this.loadStars(),t==="show-compass"&&n!==e&&this.sceneRenderer.setShowCompass(this.hasAttribute("show-compass")),t==="lens-flare-intensity"&&n!==e){const s=n===null?NaN:parseFloat(n);this.sceneRenderer.setLensFlareArtifactIntensity(Number.isFinite(s)?s:0)}}setCompassForced(t){this.sceneRenderer.setCompassForced(t)}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){const e=await fetch(t);this.sightingData=await e.json()}get sightingData(){return this.ufoElement.sightingData}set sightingData(t){this.ufoElement.sightingData=t,this.lastTimeMs=0,this.updateAstronomy(0)}get currentTerrainAttribution(){return this.sceneRenderer.currentTerrainAttribution}setTerrainProviders(t){this.sceneRenderer.setTerrainProviders(t)}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=this.getAttribute("star-catalog-src")??wy;this.starCatalog=await dy(t),this.updateAstronomy(this.lastTimeMs)}updateAstronomy(t){const e=this.ufoElement.sighting;this.setWeather(bh(e,t)),this.sceneRenderer.setInstrument(e.instrument),this.updateMeteorShower(e,t),this.sceneRenderer.setDecor(e.decor);const n=mr(e,t);this.sceneRenderer.setObserverPose(n??fc),this.sceneRenderer.updateDecorAnchoring(mr(e,0),n,t),this.sceneRenderer.updateDecorLitState(t),this.sceneRenderer.setTerrainOrigin(n?.lat,n?.lng);const s=n?.lat??fc.lat,r=n?.lng??fc.lng,a=Il(e.event.time??{},r,e.event.utcOffsetHours);if(!a){this.sceneRenderer.setAstronomy(Ay);return}const o=new Date(a.getTime()+t),c={lat:s,lng:r,elevationM:n?.elevationM??0},l={...tc("Sun",o,c),magnitude:ec("Sun",o)},h={...tc("Moon",o,c),phase:s3(o),magnitude:ec("Moon",o)},u=i3.map(d=>({body:d,position:tc(d,o,c),magnitude:ec(d,o)}));this.sceneRenderer.setAstronomy({sun:l,moon:h,planets:u,comet:this.cometAt(o,c),stars:this.starCatalog?{catalog:this.starCatalog,date:o,observer:c}:void 0})}cometAt(t,e){const n=xy.brightestAt(t,e);if(n)return{id:n.apparition.id,position:n.position,tailEnd:n.tailEnd,magnitude:n.magnitude}}updateUfoOcclusion(t){const e=this.ufoElement.sighting;e!==this.sizeEstimatesFor&&(this.sizeEstimates.clear(),this.sizeEstimatesFor=e);const n=e.timeline,s=this.ufoElement.canvasElement,r=new Set;for(const a of n.sourceIds){const o=n.getInterpolatedShapeAt(t,a);if(!o)continue;const c=(o.bounds.x+o.bounds.width/2)/s.width*2-1,l=-((o.bounds.y+o.bounds.height/2)/s.height*2-1);this.sceneRenderer.isScreenPointOccluded(c,l,a,o.behindCloud)&&r.add(a);const h=o.angular?.widthDeg??this.projectionAt(t).pxToDeg(o.bounds.width);this.sizeEstimateOf(a).add(h,this.sceneRenderer.decorDistancesAt(c,l,a))}this.ufoElement.setOccludedSourceIds(r)}sizeRangeOf(t){return this.sizeEstimateOf(t).sizeRange}distanceRangeAt(t,e){const n=this.ufoElement.sighting.timeline.getInterpolatedShapeAt(e,t);if(!n)return{};const s=n.angular?.widthDeg??this.projectionAt(e).pxToDeg(n.bounds.width);return this.sizeEstimateOf(t).distanceRangeAt(s)}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,s=e?.lat!==void 0&&e.lng!==void 0&&n?.year!==void 0?Il(n,e.lng,t.event.utcOffsetHours):void 0;if(!s||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(s.getTime()/1e3)+Math.round(e.lat*1e3),c=xe.schedule({ratePerHour:xe.observedRatePerHour(xe.apexPosition(s,r).altitudeDeg),durationMs:a,velocityKmS:xe.TYPICAL_VELOCITY_KM_S,seed:o}),l=dc.activeAt(s).map(u=>{const d=dc.radiantPosition(u.shower,s,r);return{entry:u,position:d,rate:dc.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=Ki.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],s=this.sceneRenderer.meteorMidpoint(n);if(s)return{t:Math.round(n.t+n.durationMs*.45),...s}}projectionAt(t){const e=this.ufoElement.sighting,n=mr(e,t)?.fovDeg??zl.DEFAULT_FOV_DEG;return Ps.of(e.instrument,tn.CANVAS_HEIGHT_PX,n)}sizeEstimateOf(t){let e=this.sizeEstimates.get(t);return e||(e=new yy,this.sizeEstimates.set(t,e)),e}}const Ol="rr0-scene";function pf(){Hd(),customElements.get(Ol)||customElements.define(Ol,Ty)}const mf={testimonyBy:"Testimony by",about:"About",close:"Close",observation:"Observation",date:"Date",location:"Location",case:"Case",description:"Description",tags:"Tags",credits:"Credits",editThisObservation:"Edit this observation",embed:"Embed",embedReplay:"Replay",embedEdit:"Editor",embedCopy:"Copy",embedCopied:"Copied"},Ry=Object.freeze(Object.defineProperty({__proto__:null,eyewitnessMessages_en:mf},Symbol.toStringTag,{value:"Module"}));pf();const Cy="“Thunder” by Jerimee",Dy="https://creativecommons.org/licenses/by/3.0/",Py="CC BY 3.0",pc="https://ufoathome.org";class Iy extends HTMLElement{static get observedAttributes(){return["src"]}shadow;sceneElement;toolbarElement;testimonyPrefix;witnessText;witnessSelect;infoButton;infoPanel;infoAppLink;infoObservationHeading;infoObservationList;infoCreditsToggle;infoCreditsList;infoCloseButton;infoEmbedToggle;infoEmbedPanel;embedReplayRadio;embedEditRadio;labelEmbedReplay;labelEmbedEdit;embedMarkup;embedCopyButton;supportsPopover=typeof HTMLElement.prototype.showPopover=="function";entries=[];currentSrc;infoOpen=!1;creditsOpen=!1;embedOpen=!1;language="en";messages=mf;constructor(){super(),this.shadow=this.attachShadow({mode:"open"});const t=document.createElement("template");t.innerHTML=`<style>${bf}</style>${Ef}`,this.shadow.appendChild(t.content.cloneNode(!0)),this.sceneElement=document.createElement(Ol),this.shadow.getElementById("ufo-slot").replaceWith(this.sceneElement),this.toolbarElement=this.shadow.getElementById("toolbar"),this.testimonyPrefix=this.shadow.getElementById("testimony-prefix"),this.witnessText=this.shadow.getElementById("witness-text"),this.witnessSelect=this.shadow.getElementById("witness"),this.infoButton=this.shadow.getElementById("info-button"),this.infoPanel=this.shadow.getElementById("info-panel"),this.infoAppLink=this.shadow.getElementById("info-app-link"),this.infoObservationHeading=this.shadow.getElementById("info-observation-heading"),this.infoObservationList=this.shadow.getElementById("info-observation-list"),this.infoCreditsToggle=this.shadow.getElementById("info-credits-toggle"),this.infoCreditsList=this.shadow.getElementById("info-credits-list"),this.infoCloseButton=this.shadow.getElementById("info-close"),this.infoEmbedToggle=this.shadow.getElementById("info-embed-toggle"),this.infoEmbedPanel=this.shadow.getElementById("info-embed"),this.embedReplayRadio=this.shadow.getElementById("embed-kind-replay"),this.embedEditRadio=this.shadow.getElementById("embed-kind-edit"),this.labelEmbedReplay=this.shadow.getElementById("label-embed-replay"),this.labelEmbedEdit=this.shadow.getElementById("label-embed-edit"),this.embedMarkup=this.shadow.getElementById("embed-markup"),this.embedCopyButton=this.shadow.getElementById("embed-copy"),this.witnessSelect.addEventListener("change",()=>this.selectWitness(this.witnessSelect.value)),this.supportsPopover?(this.infoPanel.setAttribute("popover","auto"),this.infoPanel.removeAttribute("hidden"),this.infoButton.setAttribute("popovertarget","info-panel"),this.infoPanel.addEventListener("beforetoggle",e=>{e.newState==="open"&&this.populateInfoPanel()}),this.infoPanel.addEventListener("toggle",e=>this.syncInfoOpen(e.newState==="open"))):this.infoButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCloseButton.addEventListener("click",()=>this.toggleInfoPanel()),this.infoCreditsToggle.addEventListener("click",()=>this.toggleCredits()),this.infoEmbedToggle.addEventListener("click",()=>this.toggleEmbed());for(const e of[this.embedReplayRadio,this.embedEditRadio])e.addEventListener("change",()=>this.refreshEmbedMarkup());this.embedCopyButton.addEventListener("click",()=>void this.copyEmbedMarkup()),this.loadLocaleMessages()}async loadLocaleMessages(){this.language=ja(navigator.languages,kd),this.language!=="en"&&(this.messages=await dp(this.language),this.testimonyPrefix.textContent=this.messages.testimonyBy,this.infoButton.title=this.messages.about,this.infoButton.setAttribute("aria-label",this.messages.about),this.infoCloseButton.setAttribute("aria-label",this.messages.close),this.infoObservationHeading.textContent=this.messages.observation,this.infoCreditsToggle.textContent=this.messages.credits,this.infoEmbedToggle.textContent=this.messages.embed,this.labelEmbedReplay.textContent=this.messages.embedReplay,this.labelEmbedEdit.textContent=this.messages.embedEdit,this.embedCopyButton.textContent=this.messages.embedCopy,this.infoOpen&&this.populateInfoPanel(),this.updateTestimonyLine())}connectedCallback(){const t=this.getAttribute("src");t&&this.loadFromSrc(t)}disconnectedCallback(){document.removeEventListener("click",this.handleOutsideClick)}attributeChangedCallback(t,e,n){t==="src"&&n&&n!==e&&this.isConnected&&this.loadFromSrc(n)}async loadFromSrc(t){const n=await(await fetch(t)).json();Array.isArray(n)?await this.loadWitnessUrls(n):this.setEntries([{src:t,sighting:n}])}get witnessUrls(){return this.entries.map(t=>t.src)}set witnessUrls(t){this.loadWitnessUrls(t)}async loadWitnessUrls(t){const e=await Promise.all(t.map(async n=>{const s=await fetch(n);return{src:n,sighting:await s.json()}}));this.setEntries(e)}setEntries(t){this.entries=t,this.warnOnMismatchedCaseIds(t),this.toolbarElement.hidden=t.length===0;const e=t.length>1;this.witnessSelect.hidden=!e,this.witnessText.hidden=e,this.witnessSelect.innerHTML="";for(const s of t){const r=document.createElement("option");r.value=s.src,r.textContent=this.witnessDisplayName(s.sighting.witness)??s.src,this.witnessSelect.appendChild(r)}const n=t.find(s=>s.src===this.currentSrc)??t[0];n?this.selectWitness(n.src):this.updateTestimonyLine()}editorUrl(){if(!this.currentSrc)return pc;const t=new URL(this.currentSrc,location.href);return t.origin===location.origin?`${pc}${t.pathname}`:`${pc}/?sighting=${encodeURIComponent(t.href)}`}embedMarkupFor(t){const e=t==="edit"?"rr0-ufo-recorder":"rr0-eyewitness",n=new URL(`${e}.mjs`,import.meta.url).href,s=this.currentSrc?new URL(this.currentSrc,location.href).href:"";return`<script type="module" src="${n}"><\/script>
|
|
5575
|
+
<${e} src="${s}"></${e}>`}refreshEmbedMarkup(){this.embedMarkup.value=this.embedMarkupFor(this.embedEditRadio.checked?"edit":"replay")}async copyEmbedMarkup(){try{await navigator.clipboard.writeText(this.embedMarkup.value),this.embedCopyButton.textContent=this.messages.embedCopied,window.setTimeout(()=>this.embedCopyButton.textContent=this.messages.embedCopy,1500)}catch{this.embedMarkup.select()}}warnOnMismatchedCaseIds(t){const e=new Set(t.map(n=>n.sighting.caseId).filter(n=>n!==void 0));e.size>1&&console.warn(`<rr0-eyewitness>: witnesses declare different case ids (${[...e].join(", ")}) — they may not belong to the same case.`)}selectWitness(t){const e=this.entries.find(n=>n.src===t);e&&(this.currentSrc=t,this.witnessSelect.value=t,this.sceneElement.sightingData=e.sighting,this.updateTestimonyLine(),this.infoOpen&&this.populateInfoPanel())}updateTestimonyLine(){const t=this.entries.find(e=>e.src===this.currentSrc);t&&(this.witnessText.textContent=this.witnessDisplayName(t.sighting.witness)??t.src)}witnessDisplayName(t){if(!t)return;const e=[...t.firstNames??[],t.lastName].filter(Boolean).join(" ");return t.title||e||t.id||t.dirName}formatDate(t){const e=t.place?.[0],n=Il(t.time??{},e?.lng??0,t.utcOffsetHours);if(!n)return;const s=n.getTime()+this.utcOffsetHoursOf(t,e?.lng??0)*36e5;return new Intl.DateTimeFormat(this.language==="fr"?"fr-FR":"en-US",{dateStyle:"long",timeStyle:"short",timeZone:"UTC"}).format(new Date(s))}utcOffsetHoursOf(t,e){return t.utcOffsetHours??Math.round(e/15)}formatLocation(t){const e=t.place?.[0];if(e)return`${e.lat.toFixed(4)}, ${e.lng.toFixed(4)}`}toggleInfoPanel(){const t=!this.infoOpen;if(this.supportsPopover){const e=this.infoPanel.matches(":popover-open");t&&!e?this.infoPanel.showPopover():!t&&e&&this.infoPanel.hidePopover();return}this.syncInfoOpen(t),this.infoPanel.hidden=!t,t?document.addEventListener("click",this.handleOutsideClick):document.removeEventListener("click",this.handleOutsideClick)}syncInfoOpen(t){t!==this.infoOpen&&(this.infoOpen=t,this.infoButton.setAttribute("aria-expanded",String(t)),t?this.supportsPopover||this.populateInfoPanel():(this.creditsOpen=!1,this.infoCreditsList.hidden=!0,this.infoCreditsToggle.setAttribute("aria-expanded","false"),this.embedOpen=!1,this.infoEmbedPanel.hidden=!0,this.infoEmbedToggle.setAttribute("aria-expanded","false")))}handleOutsideClick=t=>{const e=t.composedPath();!e.includes(this.infoPanel)&&!e.includes(this.infoButton)&&this.toggleInfoPanel()};toggleCredits(){this.creditsOpen=!this.creditsOpen,this.infoCreditsList.hidden=!this.creditsOpen,this.infoCreditsToggle.setAttribute("aria-expanded",String(this.creditsOpen)),this.creditsOpen&&this.revealInPanel(this.infoCreditsList)}toggleEmbed(){this.embedOpen=!this.embedOpen,this.infoEmbedPanel.hidden=!this.embedOpen,this.infoEmbedToggle.setAttribute("aria-expanded",String(this.embedOpen)),this.embedOpen&&(this.refreshEmbedMarkup(),this.revealInPanel(this.infoEmbedPanel))}revealInPanel(t){t.scrollIntoView?.({block:"nearest"})}populateInfoPanel(){const t=this.entries.find(r=>r.src===this.currentSrc);if(this.infoObservationList.innerHTML="",t){const r=this.formatDate(t.sighting);r&&this.appendInfoRow(this.infoObservationList,this.messages.date,r);const a=this.formatLocation(t.sighting);a&&this.appendInfoRow(this.infoObservationList,this.messages.location,a),t.sighting.caseId&&this.appendInfoRow(this.infoObservationList,this.messages.case,t.sighting.caseId),t.sighting.description&&this.appendInfoRow(this.infoObservationList,this.messages.description,t.sighting.description),t.sighting.tags&&t.sighting.tags.length>0&&this.appendInfoRow(this.infoObservationList,this.messages.tags,t.sighting.tags.join(", "))}this.refreshEmbedMarkup(),this.infoAppLink.href=this.editorUrl(),this.infoAppLink.textContent="UFO@home v0.32.0",this.infoAppLink.title=this.messages.editThisObservation,this.infoAppLink.setAttribute("aria-label",this.messages.editThisObservation),this.infoCreditsList.innerHTML="";const e=this.sceneElement.currentTerrainAttribution;if(e){const r=document.createElement("li");r.textContent=e,this.infoCreditsList.appendChild(r)}const n=document.createElement("li");n.textContent=`${Cy} (`;const s=document.createElement("a");s.href=Dy,s.target="_blank",s.rel="noopener",s.textContent=Py,n.appendChild(s),n.appendChild(document.createTextNode(")")),this.infoCreditsList.appendChild(n)}appendInfoRow(t,e,n){const s=document.createElement("dt");s.textContent=e;const r=document.createElement("dd");r.textContent=n,t.appendChild(s),t.appendChild(r)}}const Ud="rr0-eyewitness";function Ly(){pf(),customElements.get(Ud)||customElements.define(Ud,Iy)}Ly();
|